public void TestMergeMultiline4() { var source = new InMemoryLogFile(); var merged = new MergedLogFile(_taskScheduler, TimeSpan.Zero, source); source.AddMultilineEntry(LevelFlags.Other, new DateTime(2017, 12, 3, 11, 59, 30), new [] { "2017-12-03 11:59:30 Hello, ", "World!" }); _taskScheduler.RunOnce(); merged.Count.Should().Be(2); var entries = merged.GetEntries(new[] { new LogLineIndex(0), new LogLineIndex(1) }, new ILogFileColumn[] { LogFileColumns.LineNumber, LogFileColumns.LogEntryIndex, LogFileColumns.Timestamp, LogFileColumns.RawContent }); var line = entries[0]; line.GetValue(LogFileColumns.LineNumber).Should().Be(1); line.GetValue(LogFileColumns.LogEntryIndex).Should().Be(0); line.RawContent.Should().Be("2017-12-03 11:59:30 Hello, "); line = entries[1]; line.GetValue(LogFileColumns.LineNumber).Should().Be(2); line.GetValue(LogFileColumns.LogEntryIndex).Should().Be(0); line.RawContent.Should().Be("World!"); }
public void TestMultilineNoLogLevels() { using (var source0 = new TextLogFile(_scheduler, TextLogFileAcceptanceTest.MultilineNoLogLevel1, new CustomTimestampParser())) using (var source1 = new TextLogFile(_scheduler, TextLogFileAcceptanceTest.MultilineNoLogLevel2, new CustomTimestampParser())) using (var multi0 = new MultiLineLogFile(_scheduler, source0, TimeSpan.Zero)) using (var multi1 = new MultiLineLogFile(_scheduler, source1, TimeSpan.Zero)) using (var merged = new MergedLogFile(_scheduler, TimeSpan.Zero, multi0, multi1)) { merged.Property(x => x.EndOfSourceReached).ShouldAfter(TimeSpan.FromSeconds(10)).BeTrue(); var entries = merged.GetEntries(new LogFileSection(0, 11), LogFileColumns.Timestamp, LogFileColumns.LogEntryIndex, LogFileColumns.LineNumber, LogFileColumns.RawContent, LogFileColumns.OriginalDataSourceName); var line = entries[0]; line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 176)); line.RawContent.Should().Be("18/03/2019 14:09:54:176 1 Information BTPVM3372 05:30:00 6060"); line.LogEntryIndex.Should().Be(new LogEntryIndex(0)); line.GetValue(LogFileColumns.OriginalDataSourceName).Should().Be(@"TestData\Multiline\Log2.txt"); line = entries[1]; line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 177)); line.RawContent.Should() .Be("2019-03-18 14:09:54:177 1 00:00:00:0000000 Information Initialize Globals"); line.LogEntryIndex.Should().Be(new LogEntryIndex(1)); line.GetValue(LogFileColumns.OriginalDataSourceName).Should().Be(@"TestData\Multiline\Log1.txt"); line = entries[2]; line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 177)); line.RawContent.Should().Be("Started BTPVM3372 05:30:00 6060"); line.LogEntryIndex.Should().Be(new LogEntryIndex(1)); line.GetValue(LogFileColumns.OriginalDataSourceName).Should().Be(@"TestData\Multiline\Log1.txt"); line = entries[3]; line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 178)); line.RawContent.Should().Be("18/03/2019 14:09:54:178 1 Information Loading preferences Started"); line.LogEntryIndex.Should().Be(new LogEntryIndex(2)); line.GetValue(LogFileColumns.OriginalDataSourceName).Should().Be(@"TestData\Multiline\Log2.txt"); line = entries[4]; line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 178)); line.RawContent.Should().Be("BTPVM3372 05:30:00 6060"); line.LogEntryIndex.Should().Be(new LogEntryIndex(2)); line.GetValue(LogFileColumns.OriginalDataSourceName).Should().Be(@"TestData\Multiline\Log2.txt"); line = entries[5]; line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 313)); line.RawContent.Should().Be("2019-03-18 14:09:54:313 1 00:00:00:0000000 Information Loading"); line.LogEntryIndex.Should().Be(new LogEntryIndex(3)); line.GetValue(LogFileColumns.OriginalDataSourceName).Should().Be(@"TestData\Multiline\Log1.txt"); line = entries[6]; line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 313)); line.RawContent.Should().Be("preferences Started BTPVM3372 05:30:00 6060"); line.LogEntryIndex.Should().Be(new LogEntryIndex(3)); line.GetValue(LogFileColumns.OriginalDataSourceName).Should().Be(@"TestData\Multiline\Log1.txt"); line = entries[7]; line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 550)); line.RawContent.Should() .Be("18/03/2019 14:09:54:550 1 Information RMClientURL: BTPVM3372 05:30:00"); line.LogEntryIndex.Should().Be(new LogEntryIndex(4)); line.GetValue(LogFileColumns.OriginalDataSourceName).Should().Be(@"TestData\Multiline\Log2.txt"); line = entries[8]; line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 550)); line.RawContent.Should().Be("6060"); line.LogEntryIndex.Should().Be(new LogEntryIndex(4)); line.GetValue(LogFileColumns.OriginalDataSourceName).Should().Be(@"TestData\Multiline\Log2.txt"); line = entries[9]; line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 551)); line.RawContent.Should().Be("2019-03-18 14:09:54:551 1 00:00:00:0000000 Information RMClientURL:"); line.LogEntryIndex.Should().Be(new LogEntryIndex(5)); line.GetValue(LogFileColumns.OriginalDataSourceName).Should().Be(@"TestData\Multiline\Log1.txt"); line = entries[10]; line.Timestamp.Should().Be(new DateTime(2019, 3, 18, 14, 9, 54, 551)); line.RawContent.Should().Be("BTPVM3372 05:30:00 6060"); line.LogEntryIndex.Should().Be(new LogEntryIndex(5)); line.GetValue(LogFileColumns.OriginalDataSourceName).Should().Be(@"TestData\Multiline\Log1.txt"); } }