コード例 #1
0
        private void Parse(string entry)
        {
            // giving CPU a break every so often
            if (_syslogEntryCount % 10 == 0)
            {
                _syslogEntryCount = 0;
                Thread.Yield();
            }

            // Transform to RFC
            var text = $"<{_defaultPriority}> {entry}";

            // Begin parsing using Microsoft.Syslog
            var ctx = new ParserContext(text);

            if (_syslogParser.TryParse(ctx))
            {
                var serverEntry = new ServerSyslogEntry()
                {
                    Payload            = entry,
                    Entry              = ctx.Entry,
                    ParseErrorMessages = ctx.ErrorMessages
                };

                var dict = SyslogEntryToDictionaryConverter.Convert(serverEntry);
                _eventStream.Broadcast(dict);
            }
        }
コード例 #2
0
 private void ConvertToDictionary(ServerSyslogEntry serverEntry)
 {
     _eventStream.Broadcast(SyslogEntryToDictionaryConverter.Convert(serverEntry));
 }