Beispiel #1
0
        public void TestAddMultilineEntry2()
        {
            var logFile = new InMemoryLogSource();

            logFile.AddEntry("Hello, World!", LevelFlags.Debug);
            var t1 = new DateTime(2017, 11, 26, 11, 56, 0);

            logFile.AddMultilineEntry(LevelFlags.Info, t1, "foo", "bar");
            logFile.Count.Should().Be(3);
            var entry1 = logFile.GetEntry(0);

            entry1.Index.Should().Be(0);
            entry1.LogEntryIndex.Should().Be(0);
            entry1.RawContent.Should().Be("Hello, World!");
            entry1.LogLevel.Should().Be(LevelFlags.Debug);
            entry1.Timestamp.Should().Be(null);

            var entry2 = logFile.GetEntry(1);

            entry2.Index.Should().Be(1);
            entry2.LogEntryIndex.Should().Be(1);
            entry2.RawContent.Should().Be("foo");
            entry2.LogLevel.Should().Be(LevelFlags.Info);
            entry2.Timestamp.Should().Be(t1);

            var entry3 = logFile.GetEntry(2);

            entry3.Index.Should().Be(2);
            entry3.LogEntryIndex.Should().Be(1);
            entry3.RawContent.Should().Be("bar");
            entry3.LogLevel.Should().Be(LevelFlags.Info);
            entry3.Timestamp.Should().Be(t1);
        }
Beispiel #2
0
        public void TestMergeMultiline4()
        {
            var source = new InMemoryLogSource();
            var merged = new MergedLogSource(_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.GetProperty(Core.Properties.LogEntryCount).Should().Be(2);

            var entries = merged.GetEntries(new[] { new LogLineIndex(0), new LogLineIndex(1) },
                                            new IColumnDescriptor[]
            {
                Core.Columns.LineNumber, Core.Columns.LogEntryIndex, Core.Columns.Timestamp,
                Core.Columns.RawContent
            });
            var line = entries[0];

            line.GetValue(Core.Columns.LineNumber).Should().Be(1);
            line.GetValue(Core.Columns.LogEntryIndex).Should().Be(0);
            line.RawContent.Should().Be("2017-12-03 11:59:30 Hello, ");

            line = entries[1];
            line.GetValue(Core.Columns.LineNumber).Should().Be(2);
            line.GetValue(Core.Columns.LogEntryIndex).Should().Be(0);
            line.RawContent.Should().Be("World!");
        }
Beispiel #3
0
        public void TestMergeMultiline3()
        {
            var source1   = new InMemoryLogSource();
            var source1Id = new LogEntrySourceId(0);
            var source2   = new InMemoryLogSource();
            var source2Id = new LogEntrySourceId(1);
            var merged    = new MergedLogSource(_taskScheduler, TimeSpan.Zero, source1, source2);

            var t1 = new DateTime(2017, 11, 26, 11, 45, 0);

            source1.AddEntry("Foo", LevelFlags.Info, t1);
            _taskScheduler.RunOnce();

            var t3 = new DateTime(2017, 11, 26, 11, 45, 2);

            source1.AddEntry("bar", LevelFlags.Warning, t3);
            _taskScheduler.RunOnce();

            var t2 = new DateTime(2017, 11, 26, 11, 45, 1);

            source2.AddMultilineEntry(LevelFlags.Debug, t2, "Hello,", "World!");
            _taskScheduler.RunOnce();

            merged.GetProperty(Core.Properties.LogEntryCount).Should().Be(4);
            var entries = merged.GetEntries(new LogSourceSection(0, 4));

            merged.GetProperty(Core.Properties.LogEntryCount).Should().Be(4);
            entries[0].Index.Should().Be(0);
            entries[0].LogEntryIndex.Should().Be(0);
            entries[0].GetValue(Core.Columns.SourceId).Should().Be(source1Id);
            entries[0].RawContent.Should().Be("Foo");
            entries[0].LogLevel.Should().Be(LevelFlags.Info);
            entries[0].Timestamp.Should().Be(t1);
            entries[1].Index.Should().Be(1);
            entries[1].LogEntryIndex.Should().Be(1);
            entries[1].GetValue(Core.Columns.SourceId).Should().Be(source2Id);
            entries[1].RawContent.Should().Be("Hello,");
            entries[1].LogLevel.Should().Be(LevelFlags.Debug);
            entries[1].Timestamp.Should().Be(t2);
            entries[2].Index.Should().Be(2);
            entries[2].LogEntryIndex.Should().Be(1);
            entries[2].GetValue(Core.Columns.SourceId).Should().Be(source2Id);
            entries[2].RawContent.Should().Be("World!");
            entries[2].LogLevel.Should().Be(LevelFlags.Debug);
            entries[2].Timestamp.Should().Be(t2);
            entries[3].Index.Should().Be(3);
            entries[3].LogEntryIndex.Should().Be(2);
            entries[3].GetValue(Core.Columns.SourceId).Should().Be(source1Id);
            entries[3].RawContent.Should().Be("bar");
            entries[3].LogLevel.Should().Be(LevelFlags.Warning);
            entries[3].Timestamp.Should().Be(t3);
        }
Beispiel #4
0
        public void TestAddMultilineEntry4()
        {
            var logFile = new InMemoryLogSource();

            logFile.AddListener(_listener.Object, TimeSpan.Zero, 2);

            var t1 = new DateTime(2017, 11, 26, 11, 56, 0);

            logFile.AddMultilineEntry(LevelFlags.Info, t1, "foo", "bar");

            _modifications.Should().Equal(new object[]
            {
                LogSourceModification.Reset(),
                LogSourceModification.Appended(0, 2)
            });
        }
Beispiel #5
0
        public void TestAddMultilineEntry1()
        {
            var logFile = new InMemoryLogSource();

            logFile.AddMultilineEntry(LevelFlags.Debug, null, "foo", "bar");
            logFile.Count.Should().Be(2);
            var entry1 = logFile.GetEntry(0);

            entry1.Index.Should().Be(0);
            entry1.LogEntryIndex.Should().Be(0);
            entry1.RawContent.Should().Be("foo");
            entry1.LogLevel.Should().Be(LevelFlags.Debug);
            entry1.Timestamp.Should().Be(null);

            var entry2 = logFile.GetEntry(1);

            entry2.Index.Should().Be(1);
            entry2.LogEntryIndex.Should().Be(0);
            entry2.RawContent.Should().Be("bar");
            entry2.LogLevel.Should().Be(LevelFlags.Debug);
            entry2.Timestamp.Should().Be(null);
        }
Beispiel #6
0
        public void TestAddMultilineEntry3()
        {
            var logFile = new InMemoryLogSource();
            var t1      = new DateTime(2017, 11, 26, 11, 56, 0);

            logFile.AddMultilineEntry(LevelFlags.Info, t1, "foo", "bar");
            var t2 = new DateTime(2017, 11, 26, 11, 57, 0);

            logFile.AddMultilineEntry(LevelFlags.Warning, t2, "H", "e", "l", "l", "o");
            logFile.Count.Should().Be(7);

            var entry1 = logFile.GetEntry(0);

            entry1.Index.Should().Be(0);
            entry1.LogEntryIndex.Should().Be(0);
            entry1.RawContent.Should().Be("foo");
            entry1.LogLevel.Should().Be(LevelFlags.Info);
            entry1.Timestamp.Should().Be(t1);

            var entry2 = logFile.GetEntry(1);

            entry2.Index.Should().Be(1);
            entry2.LogEntryIndex.Should().Be(0);
            entry2.RawContent.Should().Be("bar");
            entry2.LogLevel.Should().Be(LevelFlags.Info);
            entry2.Timestamp.Should().Be(t1);

            var entry3 = logFile.GetEntry(2);

            entry3.Index.Should().Be(2);
            entry3.LogEntryIndex.Should().Be(1);
            entry3.RawContent.Should().Be("H");
            entry3.LogLevel.Should().Be(LevelFlags.Warning);
            entry3.Timestamp.Should().Be(t2);

            var entry4 = logFile.GetEntry(3);

            entry4.Index.Should().Be(3);
            entry4.LogEntryIndex.Should().Be(1);
            entry4.RawContent.Should().Be("e");
            entry4.LogLevel.Should().Be(LevelFlags.Warning);
            entry4.Timestamp.Should().Be(t2);

            var entry5 = logFile.GetEntry(4);

            entry5.Index.Should().Be(4);
            entry5.LogEntryIndex.Should().Be(1);
            entry5.RawContent.Should().Be("l");
            entry5.LogLevel.Should().Be(LevelFlags.Warning);
            entry5.Timestamp.Should().Be(t2);

            var entry6 = logFile.GetEntry(5);

            entry6.Index.Should().Be(5);
            entry6.LogEntryIndex.Should().Be(1);
            entry6.RawContent.Should().Be("l");
            entry6.LogLevel.Should().Be(LevelFlags.Warning);
            entry6.Timestamp.Should().Be(t2);

            var entry7 = logFile.GetEntry(6);

            entry7.Index.Should().Be(6);
            entry7.LogEntryIndex.Should().Be(1);
            entry7.RawContent.Should().Be("o");
            entry7.LogLevel.Should().Be(LevelFlags.Warning);
            entry7.Timestamp.Should().Be(t2);
        }