Example #1
0
        public void TestDetermineLevelsFromLine1()
        {
            var parser = new LogLevelParser();

            new Action(() => parser.DetermineLevelFromLine(null)).Should().NotThrow();
            parser.DetermineLevelFromLine(null).Should().Be(LevelFlags.Other);
        }
Example #2
0
        public void TestDetermineLevelsFromLine4()
        {
            var parser = new LogLevelParser();

            parser.DetermineLevelFromLine("TRACE DEBUG INFO WARNING ERROR FATAL").Should().Be(LevelFlags.Trace);
            parser.DetermineLevelFromLine("DEBUG TRACE INFO WARNING ERROR FATAL").Should().Be(LevelFlags.Debug);
            parser.DetermineLevelFromLine("INFO WARNING ERROR FATAL DEBUG TRACE").Should().Be(LevelFlags.Info);
            parser.DetermineLevelFromLine("WARN INFO ERROR FATAL TRACE DEBUG").Should().Be(LevelFlags.Warning);
            parser.DetermineLevelFromLine("ERROR INFO WARNING TRACE DEBUG FATAL").Should().Be(LevelFlags.Error);
            parser.DetermineLevelFromLine("FATAL ERROR WARNING INFO DEBUG TRACE").Should().Be(LevelFlags.Fatal);
        }
Example #3
0
        public void TestDetermineLevelsFromLine3()
        {
            var parser = new LogLevelParser();

            parser.DetermineLevelFromLine("trace").Should().Be(LevelFlags.Other);
            parser.DetermineLevelFromLine("debug").Should().Be(LevelFlags.Other);
            parser.DetermineLevelFromLine("info").Should().Be(LevelFlags.Other);
            parser.DetermineLevelFromLine("warn").Should().Be(LevelFlags.Other);
            parser.DetermineLevelFromLine("error").Should().Be(LevelFlags.Other);
            parser.DetermineLevelFromLine("fatal").Should().Be(LevelFlags.Other);
        }
Example #4
0
        public void TestDetermineLevelsFromLine2()
        {
            var parser = new LogLevelParser();

            parser.DetermineLevelFromLine("TRACE").Should().Be(LevelFlags.Trace);
            parser.DetermineLevelFromLine("DEBUG").Should().Be(LevelFlags.Debug);
            parser.DetermineLevelFromLine("INFO").Should().Be(LevelFlags.Info);
            parser.DetermineLevelFromLine("WARN").Should().Be(LevelFlags.Warning);
            parser.DetermineLevelFromLine("ERROR").Should().Be(LevelFlags.Error);
            parser.DetermineLevelFromLine("FATAL").Should().Be(LevelFlags.Fatal);
        }
        public Task <LogMessageResponse> Handle(LoggingRequestCommand request, CancellationToken cancellationToken)
        {
            var messages = request.LogMessages;
            var items    = messages.Select(message =>
            {
                return(new LogItem
                {
                    LogLevel = LogLevelParser.GetLogLevelFromMessage(message.Message),
                    Message = LogLevelParser.GetMessageWithoutLogLevel(message.Message),
                    Date = TimeSpan.FromTicks(message.Log_date),
                    Application = message.Application
                });
            });

            logsQueue.QueueLogItems(items);

            return(Task.FromResult(new LogMessageResponse("Logs were succesfully queued")));
        }
Example #6
0
 public GenericTextLogEntryParser(ITimestampParser timestampParser)
 {
     _timestampParser = timestampParser ?? throw new ArgumentNullException(nameof(timestampParser));
     _logLevelParser  = new LogLevelParser();
     _columns         = new IColumnDescriptor[] { Core.Columns.Timestamp, Core.Columns.LogLevel };
 }