예제 #1
0
        protected override void OnSingleLineChanged()
        {
            _multiLineLogSource?.Dispose();

            if (!IsSingleLine)
            {
                _multiLineLogSource = new MultiLineLogSource(TaskScheduler, _originalLogSource, MaximumWaitTime);
                _unfilteredLogSource.InnerLogSource = _multiLineLogSource;
            }
            else
            {
                _unfilteredLogSource.InnerLogSource = _originalLogSource;
            }
        }
예제 #2
0
        public void Test2SmallSources()
        {
            using (var source0 = Create(AbstractTextLogSourceAcceptanceTest.File2Entries))
                using (var source1 = Create(AbstractTextLogSourceAcceptanceTest.File2Lines))
                    using (var multi0 = new MultiLineLogSource(_taskScheduler, source0, TimeSpan.Zero))
                        using (var multi1 = new MultiLineLogSource(_taskScheduler, source1, TimeSpan.Zero))
                            using (var merged = new MergedLogSource(_taskScheduler, TimeSpan.Zero, multi0, multi1))
                            {
                                source0.Property(x => x.GetProperty(Properties.PercentageProcessed)).ShouldEventually().Be(Percentage.HundredPercent);
                                source1.Property(x => x.GetProperty(Properties.PercentageProcessed)).ShouldEventually().Be(Percentage.HundredPercent);

                                multi0.Property(x => x.GetProperty(Properties.PercentageProcessed)).ShouldEventually().Be(Percentage.HundredPercent);
                                multi1.Property(x => x.GetProperty(Properties.PercentageProcessed)).ShouldEventually().Be(Percentage.HundredPercent);

                                merged.Property(x => x.GetProperty(Properties.LogEntryCount)).ShouldAfter(TimeSpan.FromSeconds(5)).Be(8, "Because the merged file should've been finished");
                                merged.Property(x => x.GetProperty(Properties.Size)).ShouldEventually().Be(source0.GetProperty(Properties.Size) + source1.GetProperty(Properties.Size));
                                merged.Property(x => x.GetProperty(Properties.StartTimestamp)).ShouldEventually().Be(source1.GetProperty(Properties.StartTimestamp));

                                var source0Lines = multi0.GetEntries(new LogSourceSection(0, source0.GetProperty(Properties.LogEntryCount)));
                                var source1Lines = multi1.GetEntries(new LogSourceSection(0, source1.GetProperty(Properties.LogEntryCount)));
                                var mergedLines  = merged.GetEntries(new LogSourceSection(0, merged.GetProperty(Properties.LogEntryCount)));

                                mergedLines[0].Index.Should().Be(0);
                                mergedLines[0].LogEntryIndex.Should().Be(0);
                                mergedLines[0].GetValue(Columns.SourceId).Should().Be(new LogEntrySourceId(1));
                                mergedLines[0].RawContent.Should().Be(source1Lines[0].RawContent);

                                mergedLines[1].Index.Should().Be(1);
                                mergedLines[1].LogEntryIndex.Should().Be(1);
                                mergedLines[1].GetValue(Columns.SourceId).Should().Be(new LogEntrySourceId(0));
                                mergedLines[1].RawContent.Should().Be(source0Lines[0].RawContent);

                                mergedLines[2].Index.Should().Be(2);
                                mergedLines[2].LogEntryIndex.Should().Be(1);
                                mergedLines[2].GetValue(Columns.SourceId).Should().Be(new LogEntrySourceId(0));
                                mergedLines[2].RawContent.Should().Be(source0Lines[1].RawContent);

                                mergedLines[3].Index.Should().Be(3);
                                mergedLines[3].LogEntryIndex.Should().Be(1);
                                mergedLines[3].GetValue(Columns.SourceId).Should().Be(new LogEntrySourceId(0));
                                mergedLines[3].RawContent.Should().Be(source0Lines[2].RawContent);

                                mergedLines[4].Index.Should().Be(4);
                                mergedLines[4].LogEntryIndex.Should().Be(2);
                                mergedLines[4].GetValue(Columns.SourceId).Should().Be(new LogEntrySourceId(1));
                                mergedLines[4].RawContent.Should().Be(source1Lines[1].RawContent);

                                mergedLines[5].Index.Should().Be(5);
                                mergedLines[5].LogEntryIndex.Should().Be(3);
                                mergedLines[5].GetValue(Columns.SourceId).Should().Be(new LogEntrySourceId(0));
                                mergedLines[5].RawContent.Should().Be(source0Lines[3].RawContent);

                                mergedLines[6].Index.Should().Be(6);
                                mergedLines[6].LogEntryIndex.Should().Be(3);
                                mergedLines[6].GetValue(Columns.SourceId).Should().Be(new LogEntrySourceId(0));
                                mergedLines[6].RawContent.Should().Be(source0Lines[4].RawContent);

                                mergedLines[7].Index.Should().Be(7);
                                mergedLines[7].LogEntryIndex.Should().Be(3);
                                mergedLines[7].GetValue(Columns.SourceId).Should().Be(new LogEntrySourceId(0));
                                mergedLines[7].RawContent.Should().Be(source0Lines[5].RawContent);
                            }
        }
예제 #3
0
        public void TestMultilineNoLogLevels()
        {
            using (var source0 = Create(AbstractTextLogSourceAcceptanceTest.MultilineNoLogLevel1, new CustomTimestampParser()))
                using (var source1 = Create(AbstractTextLogSourceAcceptanceTest.MultilineNoLogLevel2, new CustomTimestampParser()))
                    using (var multi0 = new MultiLineLogSource(_taskScheduler, source0, TimeSpan.Zero))
                        using (var multi1 = new MultiLineLogSource(_taskScheduler, source1, TimeSpan.Zero))
                            using (var merged = new MergedLogSource(_taskScheduler, TimeSpan.Zero, multi0, multi1))
                            {
                                // TODO: Fix - the percentage gets reset because a log file implementation has a slightly botched Percetage calculation
                                merged.Property(x => x.GetProperty(Properties.PercentageProcessed)).ShouldAfter(TimeSpan.FromSeconds(10)).Be(Percentage.HundredPercent);

                                var entries = merged.GetEntries(new LogSourceSection(0, 11),
                                                                new IColumnDescriptor[]
                                {
                                    Columns.Timestamp,
                                    Columns.LogEntryIndex,
                                    Columns.LineNumber,
                                    Columns.RawContent,
                                    Columns.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(Columns.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(Columns.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(Columns.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(Columns.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(Columns.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(Columns.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(Columns.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(Columns.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(Columns.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(Columns.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(Columns.OriginalDataSourceName).Should().Be(@"TestData\Multiline\Log1.txt");
                            }
        }