Exemplo n.º 1
0
        public void TestFilter2()
        {
            using (var file = new LogFile(_scheduler, File20Mb))
            {
                file.Property(x => x.Count).ShouldEventually().Be(165342, TimeSpan.FromSeconds(5));

                using (FilteredLogFile filtered = file.AsFiltered(_scheduler, Filter.Create("info")))
                {
                    var listener = new Mock<ILogFileListener>();
                    var sections = new List<LogFileSection>();
                    listener.Setup(x => x.OnLogFileModified(It.IsAny<ILogFile>(), It.IsAny<LogFileSection>()))
                            .Callback((ILogFile logFile, LogFileSection section) => sections.Add(section));

                    filtered.Property(x => x.Count).ShouldEventually().Be(5, TimeSpan.FromSeconds(5));

                    filtered.AddListener(listener.Object, TimeSpan.Zero, 1);

                    sections.Should().Equal(new object[]
                        {
                            LogFileSection.Reset,
                            new LogFileSection(0, 1),
                            new LogFileSection(1, 1),
                            new LogFileSection(2, 1),
                            new LogFileSection(3, 1),
                            new LogFileSection(4, 1)
                        });
                }
            }
        }
Exemplo n.º 2
0
        public void TestClear1()
        {
            const string fname = "TestClear1.log";
            using (FileStream stream = File.OpenWrite(fname))
            using (var writer = new StreamWriter(stream))
            {
                stream.SetLength(0);
                writer.WriteLine("Test");
            }

            using (var logFile = new LogFile(_scheduler, fname))
            {
                logFile.Property(x => x.Count).ShouldEventually().Be(1, TimeSpan.FromSeconds(5));

                logFile.Count.Should().Be(1);

                using (var stream = new FileStream(fname, FileMode.Open, FileAccess.Write, FileShare.ReadWrite))
                using (var writer = new StreamWriter(stream))
                {
                    stream.SetLength(0);

                    logFile.Property(x => x.Count).ShouldEventually().Be(0, TimeSpan.FromSeconds(5));
                    logFile.Count.Should().Be(0);

                    writer.WriteLine("Hello World!");
                    writer.Flush();

                    logFile.Property(x => x.Count).ShouldEventually().Be(1, TimeSpan.FromSeconds(5));
                    logFile.Entries.Should().Equal(new[]
                        {
                            new LogLine(0, "Hello World!", LevelFlags.None)
                        });
                }
            }
        }
Exemplo n.º 3
0
 public SingleDataSource(ITaskScheduler taskScheduler, DataSource settings, TimeSpan maximumWaitTime)
     : base(taskScheduler, settings, maximumWaitTime)
 {
     var logFile = new LogFile(taskScheduler, settings.File);
     _unfilteredLogFile = logFile;
     CreateFilteredLogFile();
 }
Exemplo n.º 4
0
        public void Test2SmallSources()
        {
            using (var source1 = new LogFile(_scheduler, LogFileTest.File2Entries))
            using (var source2 = new LogFile(_scheduler, LogFileTest.File2Lines))
            using (var merged = new MergedLogFile(_scheduler, TimeSpan.Zero, source1, source2))
            {
                source1.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue();

                source2.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue();

                merged.Property(x => x.Count).ShouldEventually().Be(8, TimeSpan.FromSeconds(5),
                                                                    "Because the merged file should've been finished");
                merged.Property(x => x.FileSize).ShouldEventually().Be(source1.FileSize + source2.FileSize);
                merged.Property(x => x.StartTimestamp).ShouldEventually().Be(source1.StartTimestamp);

                LogLine[] source1Lines = source1.GetSection(new LogFileSection(0, source1.Count));
                LogLine[] source2Lines = source2.GetSection(new LogFileSection(0, source2.Count));
                LogLine[] mergedLines = merged.GetSection(new LogFileSection(0, merged.Count));

                mergedLines[0].Should().Be(new LogLine(0, 0, source1Lines[0]));
                mergedLines[1].Should().Be(new LogLine(1, 0, source1Lines[1]));
                mergedLines[2].Should().Be(new LogLine(2, 0, source1Lines[2]));
                mergedLines[3].Should().Be(new LogLine(3, 1, source2Lines[0]));
                mergedLines[4].Should().Be(new LogLine(4, 2, source1Lines[3]));
                mergedLines[5].Should().Be(new LogLine(5, 2, source1Lines[4]));
                mergedLines[6].Should().Be(new LogLine(6, 2, source1Lines[5]));
                mergedLines[7].Should().Be(new LogLine(7, 3, source2Lines[1]));
            }
        }
 public void Test()
 {
     using (var source1 = new LogFile(_scheduler, LogFileTest.File2Entries))
     using (var source2 = new LogFile(_scheduler, LogFileTest.File2Lines))
     {
         var sources = new List<ILogFile> {source1, source2};
         using (var merged = new MergedLogFile(_scheduler, TimeSpan.FromMilliseconds(10), sources))
         {
             var filter = new SubstringFilter("foo", true);
             using (var filtered = new FilteredLogFile(_scheduler, TimeSpan.FromMilliseconds(10), merged, filter))
             {
                 filtered.Property(x => x.Count).ShouldEventually().Be(1, TimeSpan.FromSeconds(5));
             }
         }
     }
 }
        public void TestSearch1()
        {
            var settings = new DataSource(LogFileTest.File2Mb) { Id = Guid.NewGuid() };
            using (var logFile = new LogFile(_taskScheduler, LogFileTest.File2Mb))
            using (var dataSource = new SingleDataSource(_taskScheduler, settings, logFile, TimeSpan.Zero))
            {
                var model = new SingleDataSourceViewModel(dataSource);

                logFile.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue();

                model.Update();
                model.TotalCount.Should().Be(16114);

                model.SearchTerm = "RPC #12";
                var search = dataSource.Search;
                search.Property(x => x.Count).ShouldEventually().Be(334);

                model.Update();
                model.SearchResultCount.Should().Be(334);
                model.CurrentSearchResultIndex.Should().Be(0);
            }
        }
Exemplo n.º 7
0
        public void TestFilter1()
        {
            using (var file = new LogFile(_scheduler, File20Mb))
            {
                file.Property(x => x.Count).ShouldEventually().Be(165342, TimeSpan.FromSeconds(5));

                using (FilteredLogFile filtered = file.AsFiltered(_scheduler, Filter.Create("info")))
                {
                    filtered.Property(x => x.Count).ShouldEventually().Be(5, TimeSpan.FromSeconds(5));
                    filtered.StartTimestamp.Should().Be(new DateTime(2015, 10, 7, 19, 50, 58, 982));

                    LogLine[] section = filtered.GetSection(new LogFileSection(0, 5));
                    section.Should().Equal(new[]
                        {
                            new LogLine(0, 0,
                                        "2015-10-07 19:50:58,982 [8092, 1] INFO  SharpRemote.Hosting.OutOfProcessSiloServer (null) - Silo Server starting, args (1): \"14056\", without custom type resolver",
                                        LevelFlags.Info,
                                        new DateTime(2015, 10, 7, 19, 50, 58, 982, DateTimeKind.Unspecified)),
                            new LogLine(1, 5,
                                        "2015-10-07 19:50:59,081 [8092, 1] INFO  SharpRemote.SocketRemotingEndPointServer (null) - EndPoint '<Unnamed>' listening on 0.0.0.0:49152",
                                        LevelFlags.Info,
                                        new DateTime(2015, 10, 7, 19, 50, 59, 081)),
                            new LogLine(2, 7,
                                        "2015-10-07 19:50:59,171 [8092, 6] INFO  SharpRemote.AbstractIPSocketRemotingEndPoint (null) - <Unnamed>: Connected to 127.0.0.1:10348",
                                        LevelFlags.Info,
                                        new DateTime(2015, 10, 7, 19, 50, 59, 171)),
                            new LogLine(3, 165340,
                                        "2015-10-07 19:51:42,481 [8092, EndPoint '<Unnamed>' Socket Reading] INFO  SharpRemote.AbstractSocketRemotingEndPoint (null) - Disconnecting socket '<Unnamed>' from 127.0.0.1:10348: ReadFailure",
                                        LevelFlags.Info,
                                        new DateTime(2015, 10, 7, 19, 51, 42, 481)),
                            new LogLine(4, 165341,
                                        "2015-10-07 19:51:42,483 [8092, 6] INFO  SharpRemote.Hosting.OutOfProcessSiloServer (null) - Parent process terminated unexpectedly (exit code: -1), shutting down...",
                                        LevelFlags.Info,
                                        new DateTime(2015, 10, 7, 19, 51, 42, 483))
                        });
                }
            }
        }
Exemplo n.º 8
0
        public void Test20Mb()
        {
            using (var source = new LogFile(_scheduler, LogFileTest.File20Mb))
            using (var merged = new MergedLogFile(_scheduler, TimeSpan.FromMilliseconds(1), source))
            {
                source.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue();

                merged.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue();

                merged.Count.Should().Be(source.Count);
                merged.FileSize.Should().Be(source.FileSize);
                merged.StartTimestamp.Should().Be(source.StartTimestamp);

                LogLine[] sourceLines = source.GetSection(new LogFileSection(0, source.Count));
                LogLine[] mergedLines = merged.GetSection(new LogFileSection(0, merged.Count));
                for (int i = 0; i < source.Count; ++i)
                {
                    LogLine mergedLine = mergedLines[i];
                    LogLine sourceLine = sourceLines[i];
                    mergedLine.Should().Be(sourceLine);
                }
            }
        }
Exemplo n.º 9
0
        public void TestExists()
        {
            LogFile logFile = null;
            try
            {
                new Action(() => logFile = new LogFile(_scheduler, File2Lines)).ShouldNotThrow();

                logFile.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue(TimeSpan.FromSeconds(5));
                logFile.Property(x => x.Exists).ShouldEventually().BeTrue(TimeSpan.FromSeconds(5));

                logFile.Exists.Should().BeTrue("Because the specified file does exist");
            }
            finally
            {
                if (logFile != null)
                    logFile.Dispose();
            }
        }
Exemplo n.º 10
0
        public void TestReadAll2()
        {
            using (var file = new LogFile(_scheduler, File20Mb))
            {
                var listener = new Mock<ILogFileListener>();
                var sections = new List<LogFileSection>();
                listener.Setup(x => x.OnLogFileModified(It.IsAny<ILogFile>(), It.IsAny<LogFileSection>()))
                        .Callback((ILogFile logFile, LogFileSection section) => sections.Add(section));

                file.AddListener(listener.Object, TimeSpan.Zero, 1);

                file.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue(TimeSpan.FromSeconds(20));
                file.Count.Should().Be(165342);

                sections[0].Should().Be(LogFileSection.Reset);
                for (int i = 1; i < sections.Count; ++i)
                {
                    LogFileSection change = sections[i];
                    change.Index.Should().Be((LogLineIndex) (i - 1));
                    change.Count.Should().Be(1);
                }
            }
        }
Exemplo n.º 11
0
        public void TestLive2()
        {
            const string fname = "TestLive2.log";

            if (File.Exists(fname))
                File.Delete(fname);

            using (var logger = new Logger(fname))
            using (var logFile = new LogFile(_scheduler, fname))
            {
                logFile.Count.Should().Be(0);

                Log.Info("Hello");
                logFile.Property(x => x.Count).ShouldEventually().Be(1, TimeSpan.FromSeconds(5));

                Log.Info("world!");
                logFile.Property(x => x.Count).ShouldEventually().Be(2, TimeSpan.FromSeconds(5));
            }
        }
Exemplo n.º 12
0
        public void TestGetSection1()
        {
            using (var file = new LogFile(_scheduler, File20Mb))
            {
                file.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue(TimeSpan.FromSeconds(20), "because we should be able to read the entire file in a few seconds");
                file.Count.Should().Be(165342);
                file.StartTimestamp.Should().Be(new DateTime(2015, 10, 7, 19, 50, 58, 982));

                LogLine[] section = file.GetSection(new LogFileSection(0, 10));
                section.Should().Equal(new[]
                    {
                        new LogLine(0,
                                    "2015-10-07 19:50:58,982 [8092, 1] INFO  SharpRemote.Hosting.OutOfProcessSiloServer (null) - Silo Server starting, args (1): \"14056\", without custom type resolver",
                                    LevelFlags.Info,
                                    new DateTime(2015, 10, 7, 19, 50, 58, 982)),
                        new LogLine(1,
                                    "2015-10-07 19:50:58,998 [8092, 1] DEBUG SharpRemote.Hosting.OutOfProcessSiloServer (null) - Args.Length: 1",
                                    LevelFlags.Debug,
                                    new DateTime(2015, 10, 7, 19, 50, 58, 998)),
                        new LogLine(2,
                                    "2015-10-07 19:50:59,013 [8092, 1] DEBUG SharpRemote.AbstractSocketRemotingEndPoint (null) - Creating new servant (#18446744073709551613) 'SharpRemote.Heartbeat' implementing 'SharpRemote.IHeartbeat'",
                                    LevelFlags.Debug,
                                    new DateTime(2015, 10, 7, 19, 50, 59, 013)),
                        new LogLine(3,
                                    "2015-10-07 19:50:59,062 [8092, 1] DEBUG SharpRemote.AbstractSocketRemotingEndPoint (null) - Creating new servant (#18446744073709551614) 'SharpRemote.Latency' implementing 'SharpRemote.ILatency'",
                                    LevelFlags.Debug,
                                    new DateTime(2015, 10, 7, 19, 50, 59, 062)),
                        new LogLine(4,
                                    "2015-10-07 19:50:59,067 [8092, 1] DEBUG SharpRemote.AbstractSocketRemotingEndPoint (null) - Creating new servant (#18446744073709551615) 'SharpRemote.Hosting.SubjectHost' implementing 'SharpRemote.Hosting.ISubjectHost'",
                                    LevelFlags.Debug,
                                    new DateTime(2015, 10, 7, 19, 50, 59, 067)),
                        new LogLine(5,
                                    "2015-10-07 19:50:59,081 [8092, 1] INFO  SharpRemote.SocketRemotingEndPointServer (null) - EndPoint '<Unnamed>' listening on 0.0.0.0:49152",
                                    LevelFlags.Info,
                                    new DateTime(2015, 10, 7, 19, 50, 59, 081)),
                        new LogLine(6,
                                    "2015-10-07 19:50:59,141 [8092, 6] DEBUG SharpRemote.SocketRemotingEndPointServer (null) - Incoming connection from '127.0.0.1:10348', starting handshake...",
                                    LevelFlags.Debug,
                                    new DateTime(2015, 10, 7, 19, 50, 59, 141)),
                        new LogLine(7,
                                    "2015-10-07 19:50:59,171 [8092, 6] INFO  SharpRemote.AbstractIPSocketRemotingEndPoint (null) - <Unnamed>: Connected to 127.0.0.1:10348",
                                    LevelFlags.Info,
                                    new DateTime(2015, 10, 7, 19, 50, 59, 171)),
                        new LogLine(8,
                                    "2015-10-07 19:50:59,181 [8092, 10] DEBUG SharpRemote.AbstractSocketRemotingEndPoint (null) - 0.0.0.0:49152 to 127.0.0.1:10348: sending RPC #1 to 18446744073709551611.Beat",
                                    LevelFlags.Debug,
                                    new DateTime(2015, 10, 7, 19, 50, 59, 181)),
                        new LogLine(9,
                                    "2015-10-07 19:50:59,182 [8092, 11] DEBUG SharpRemote.AbstractSocketRemotingEndPoint (null) - 0.0.0.0:49152 to 127.0.0.1:10348: sending RPC #2 to 18446744073709551612.Roundtrip",
                                    LevelFlags.Debug,
                                    new DateTime(2015, 10, 7, 19, 50, 59, 182))
                    });
            }
        }
Exemplo n.º 13
0
        public void TestFilter3()
        {
            const string fname = "TestFilter3.log";
            using (FileStream stream = File.OpenWrite(fname))
            using (var writer = new StreamWriter(stream))
            {
                stream.SetLength(0);
                writer.WriteLine("INFO - Test");
            }

            using (var file = new LogFile(_scheduler, fname))
            {
                file.Property(x => x.Count).ShouldEventually().Be(1, TimeSpan.FromSeconds(5));

                file.Property(x=> x.Count).ShouldEventually().Be(1, TimeSpan.FromSeconds(5));

                using (FilteredLogFile filtered = file.AsFiltered(_scheduler, Filter.Create("e", LevelFlags.All), TimeSpan.Zero))
                {
                    var listener = new Mock<ILogFileListener>();
                    var sections = new List<LogFileSection>();
                    listener.Setup(x => x.OnLogFileModified(It.IsAny<ILogFile>(), It.IsAny<LogFileSection>()))
                            .Callback((ILogFile logFile, LogFileSection section) => sections.Add(section));
                    filtered.AddListener(listener.Object, TimeSpan.FromHours(1), 1000);

                    filtered.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue(TimeSpan.FromSeconds(5));
                    filtered.GetSection(new LogFileSection(0, filtered.Count)).Should().Equal(new[]
                        {
                            new LogLine(0, "INFO - Test", LevelFlags.Info)
                        });

                    using (var stream = new FileStream(fname, FileMode.Open, FileAccess.Write, FileShare.ReadWrite))
                    {
                        stream.SetLength(0);
                    }

                    filtered.Property(x => x.Count).ShouldEventually().Be(0, TimeSpan.FromSeconds(5));
                    filtered.EndOfSourceReached.Should().BeTrue();
                    sections.Should().EndWith(LogFileSection.Reset);
                }
            }
        }
Exemplo n.º 14
0
        public void TestOpenBeforeCreate()
        {
            LogFile logFile = null;
            try
            {
                string fileName = Path.GetTempFileName();
                if (File.Exists(fileName))
                    File.Delete(fileName);

                new Action(() => logFile = new LogFile(_scheduler, fileName)).ShouldNotThrow();

                logFile.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue(TimeSpan.FromSeconds(5));
                logFile.Property(x => x.Exists).ShouldEventually().BeFalse(TimeSpan.FromSeconds(5),
                                                                           "Because the specified file doesn't exist");

                File.WriteAllText(fileName, "Hello World!");

                logFile.Property(x => x.Exists).ShouldEventually().BeTrue(TimeSpan.FromSeconds(5),
                                                                          "Because the file has been created now");
                logFile.Property(x => x.Count).ShouldEventually().Be(1, TimeSpan.FromSeconds(5),
                                                                          "Because one line was written to the file");

                logFile.GetLine(0).Should().Be(new LogLine(0, 0, "Hello World!", LevelFlags.None));
            }
            finally
            {
                if (logFile != null)
                    logFile.Dispose();
            }
        }
Exemplo n.º 15
0
        public void TestClear2()
        {
            const string fname = "TestClear2.log";
            using (FileStream stream = File.OpenWrite(fname))
            using (var writer = new StreamWriter(stream))
            {
                stream.SetLength(0);
                writer.WriteLine("Test");
            }

            using (var logFile = new LogFile(_scheduler, fname))
            {
                var listener = new Mock<ILogFileListener>();
                var sections = new List<LogFileSection>();
                listener.Setup(x => x.OnLogFileModified(It.IsAny<ILogFile>(), It.IsAny<LogFileSection>()))
                        .Callback((ILogFile log, LogFileSection section) => sections.Add(section));
                logFile.AddListener(listener.Object, TimeSpan.Zero, 2);

                logFile.Property(x => x.Count).ShouldEventually().Be(1, TimeSpan.FromSeconds(5));

                using (var stream = new FileStream(fname, FileMode.Open, FileAccess.Write, FileShare.ReadWrite))
                {
                    stream.SetLength(0);

                    logFile.Property(x => x.Count).ShouldEventually().Be(0, TimeSpan.FromSeconds(5));
                    sections.Should().EndWith(LogFileSection.Reset);
                }
            }
        }
Exemplo n.º 16
0
        public void TestRead2Lines()
        {
            using (var file = new LogFile(_scheduler, File2Lines))
            {
                var listener = new Mock<ILogFileListener>();
                var changes = new List<LogFileSection>();
                listener.Setup(x => x.OnLogFileModified(It.IsAny<ILogFile>(), It.IsAny<LogFileSection>()))
                        .Callback((ILogFile logFile, LogFileSection section) => changes.Add(section));

                file.AddListener(listener.Object, TimeSpan.Zero, 1);

                changes.Property(x => x.Count).ShouldEventually().Be(3, TimeSpan.FromSeconds(5));
                changes.Should().Equal(new[]
                    {
                        LogFileSection.Reset,
                        new LogFileSection(0, 1),
                        new LogFileSection(1, 1)
                    });
            }
        }
Exemplo n.º 17
0
        public void TestDelete1()
        {
            const string fname = "TestDelete1.log";
            File.WriteAllText(fname, "Test");

            using (var logFile = new LogFile(_scheduler, fname))
            {
                logFile.Property(x => x.Count).ShouldEventually().Be(1, TimeSpan.FromSeconds(5));

                new Action(() =>
                    {
                        for (int i = 0; i < 10; ++i)
                        {
                            try
                            {
                                File.Delete(fname);
                                return;
                            }
                            catch (IOException)
                            {
                            }
                        }

                        File.Delete(fname);
                    }).ShouldNotThrow();
            }
        }
Exemplo n.º 18
0
        public void TestRead2LogEntries()
        {
            using (var file = new LogFile(_scheduler, File2Entries))
            {
                var listener = new Mock<ILogFileListener>();
                var changes = new List<LogFileSection>();
                listener.Setup(x => x.OnLogFileModified(It.IsAny<ILogFile>(), It.IsAny<LogFileSection>()))
                        .Callback((ILogFile logFile, LogFileSection section) => changes.Add(section));

                file.AddListener(listener.Object, TimeSpan.Zero, 1);

                changes.Property(x => x.Count).ShouldEventually().Be(7, TimeSpan.FromSeconds(5));

                changes.Should().Equal(new[]
                    {
                        LogFileSection.Reset,
                        new LogFileSection(0, 1),
                        new LogFileSection(1, 1),
                        new LogFileSection(2, 1),
                        new LogFileSection(3, 1),
                        new LogFileSection(4, 1),
                        new LogFileSection(5, 1)
                    });

                file.StartTimestamp.Should().Be(new DateTime(2015, 10, 7, 19, 50, 58, 982));

                LogLine[] lines = file.GetSection(new LogFileSection(0, 6));
                lines.Should().Equal(new[]
                    {
                        new LogLine(0, 0,
                                    "2015-10-07 19:50:58,982 [8092, 1] INFO  SharpRemote.Hosting.OutOfProcessSiloServer (null) - Silo Server starting, args (1): \"14056\", without custom type resolver",
                                    LevelFlags.Info, new DateTime(2015, 10, 7, 19, 50, 58, 982)),
                        new LogLine(1, 0, "Foobar", LevelFlags.Info, new DateTime(2015, 10, 7, 19, 50, 58, 982)),
                        new LogLine(2, 0, "Some more info", LevelFlags.Info, new DateTime(2015, 10, 7, 19, 50, 58, 982)),
                        new LogLine(3, 1,
                                    "2015-10-07 19:50:58,998 [8092, 1] DEBUG SharpRemote.Hosting.OutOfProcessSiloServer (null) - Args.Length: 1",
                                    LevelFlags.Debug, new DateTime(2015, 10, 7, 19, 50, 58, 998)),
                        new LogLine(4, 1, "Hey look at me", LevelFlags.Debug, new DateTime(2015, 10, 7, 19, 50, 58, 998)),
                        new LogLine(5, 1, "dwadawdadw", LevelFlags.Debug, new DateTime(2015, 10, 7, 19, 50, 58, 998))
                    });
            }
        }
Exemplo n.º 19
0
        public void TestReadAll1()
        {
            using (var file = new LogFile(_scheduler, File20Mb))
            {
                file.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue(TimeSpan.FromSeconds(20));

                file.Dispose();

                file.StartTimestamp.Should().Be(new DateTime(2015, 10, 7, 19, 50, 58, 982));

                List<LogLine> entries = file.Entries.ToList();
                entries.Count.Should().Be(165342);
                entries[0].Should()
                          .Be(new LogLine(0,
                                          "2015-10-07 19:50:58,982 [8092, 1] INFO  SharpRemote.Hosting.OutOfProcessSiloServer (null) - Silo Server starting, args (1): \"14056\", without custom type resolver",
                                          LevelFlags.Info, new DateTime(2015, 10, 7, 19, 50, 58, 982)));
                entries[entries.Count - 1].Should()
                                          .Be(new LogLine(165341,
                                                          "2015-10-07 19:51:42,483 [8092, 6] INFO  SharpRemote.Hosting.OutOfProcessSiloServer (null) - Parent process terminated unexpectedly (exit code: -1), shutting down...",
                                                          LevelFlags.Info, new DateTime(2015, 10, 7, 19, 51, 42, 483)));
            }
        }
Exemplo n.º 20
0
        public void TestLive1And2()
        {
            using (var source1 = new LogFile(_scheduler, LogFileTest.FileTestLive1))
            using (var source2 = new LogFile(_scheduler, LogFileTest.FileTestLive2))
            using (var merged = new MergedLogFile(_scheduler, TimeSpan.Zero, source1, source2))
            {
                merged.Property(x => x.Count).ShouldEventually().Be(19, TimeSpan.FromSeconds(5),
                                                                    "Because the merged file should've been finished");
                merged.Property(x => x.FileSize).ShouldEventually().Be(source1.FileSize + source2.FileSize);
                merged.Property(x => x.StartTimestamp).ShouldEventually().Be(source1.StartTimestamp);

                LogLine[] mergedLines = merged.GetSection(new LogFileSection(0, merged.Count));

                mergedLines[0].Should()
                              .Be(new LogLine(0, 0,
                                              "2016-02-17 22:57:51,449 [CurrentAppDomainHost.ExecuteNodes] INFO  Tailviewer.Test.BusinessLogic.LogFileTest - Test",
                                              LevelFlags.Info, new DateTime(2016, 2, 17, 22, 57, 51, 449)));
                mergedLines[1].Should()
                              .Be(new LogLine(1, 1,
                                              "2016-02-17 22:57:51,559 [CurrentAppDomainHost.ExecuteNodes] INFO  Tailviewer.Test.BusinessLogic.LogFileTest - Hello",
                                              LevelFlags.Info, new DateTime(2016, 2, 17, 22, 57, 51, 559)));
                mergedLines[2].Should()
                              .Be(new LogLine(2, 2,
                                              "2016-02-17 22:57:51,560 [CurrentAppDomainHost.ExecuteNodes] INFO  Tailviewer.Test.BusinessLogic.LogFileTest - Hello",
                                              LevelFlags.Info, new DateTime(2016, 2, 17, 22, 57, 51, 560)));
                mergedLines[3].Should()
                              .Be(new LogLine(3, 3,
                                              "2016-02-17 22:57:51,664 [CurrentAppDomainHost.ExecuteNodes] INFO  Tailviewer.Test.BusinessLogic.LogFileTest - world!",
                                              LevelFlags.Info, new DateTime(2016, 2, 17, 22, 57, 51, 664)));
                mergedLines[4].Should()
                              .Be(new LogLine(4, 4,
                                              "2016-02-17 22:57:51,665 [CurrentAppDomainHost.ExecuteNodes] INFO  Tailviewer.Test.BusinessLogic.LogFileTest - world!",
                                              LevelFlags.Info, new DateTime(2016, 2, 17, 22, 57, 51, 665)));
                mergedLines[5].Should()
                              .Be(new LogLine(5, 5,
                                              "2016-02-17 22:57:59,284 [CurrentAppDomainHost.ExecuteNodes] WARN  Tailviewer.Settings.DataSources - Selected item '00000000-0000-0000-0000-000000000000' not found in data-sources, ignoring it...",
                                              LevelFlags.Warning, new DateTime(2016, 2, 17, 22, 57, 59, 284)));
                mergedLines[6].Should()
                              .Be(new LogLine(6, 6,
                                              "2016-02-17 22:57:59,284 [CurrentAppDomainHost.ExecuteNodes] WARN  Tailviewer.Settings.DataSources - Selected item '00000000-0000-0000-0000-000000000000' not found in data-sources, ignoring it...",
                                              LevelFlags.Warning, new DateTime(2016, 2, 17, 22, 57, 59, 284)));
                mergedLines[7].Should()
                              .Be(new LogLine(7, 7,
                                              "2016-02-17 22:57:59,299 [CurrentAppDomainHost.ExecuteNodes] WARN  Tailviewer.Settings.DataSources - Selected item '00000000-0000-0000-0000-000000000000' not found in data-sources, ignoring it...",
                                              LevelFlags.Warning, new DateTime(2016, 2, 17, 22, 57, 59, 299)));
                mergedLines[8].Should()
                              .Be(new LogLine(8, 8,
                                              "2016-02-17 22:57:59,299 [CurrentAppDomainHost.ExecuteNodes] WARN  Tailviewer.Settings.DataSources - Selected item '00000000-0000-0000-0000-000000000000' not found in data-sources, ignoring it...",
                                              LevelFlags.Warning, new DateTime(2016, 2, 17, 22, 57, 59, 299)));
                mergedLines[9].Should()
                              .Be(new LogLine(9, 9,
                                              @"2016-02-17 22:57:59,302 [CurrentAppDomainHost.ExecuteNodes] INFO  Tailviewer.Settings.DataSource - Data Source 'E:\Code\Tailviewer\bin\Debug\TestClear1.log' doesn't have an ID yet, setting it to: b62ea0a3-c495-4f3f-b7c7-d1a0a66e361e",
                                              LevelFlags.Info, new DateTime(2016, 2, 17, 22, 57, 59, 302)));
                mergedLines[10].Should()
                               .Be(new LogLine(10, 10,
                                               @"2016-02-17 22:57:59,303 [CurrentAppDomainHost.ExecuteNodes] INFO  Tailviewer.Settings.DataSource - Data Source 'E:\Code\Tailviewer\bin\Debug\TestClear1.log' doesn't have an ID yet, setting it to: b62ea0a3-c495-4f3f-b7c7-d1a0a66e361e",
                                               LevelFlags.Info, new DateTime(2016, 2, 17, 22, 57, 59, 303)));
                mergedLines[11].Should()
                               .Be(new LogLine(11, 11,
                                               @"2016-02-17 22:57:59,304 [CurrentAppDomainHost.ExecuteNodes] INFO  Tailviewer.Settings.DataSource - Data Source 'E:\Code\Tailviewer\bin\Debug\TestClear2.log' doesn't have an ID yet, setting it to: 0ff1c032-0754-405f-8193-2fa4dbfb7d07",
                                               LevelFlags.Info, new DateTime(2016, 2, 17, 22, 57, 59, 304)));
                mergedLines[12].Should()
                               .Be(new LogLine(12, 12,
                                               @"2016-02-17 22:57:59,305 [CurrentAppDomainHost.ExecuteNodes] INFO  Tailviewer.Settings.DataSource - Data Source 'E:\Code\Tailviewer\bin\Debug\TestClear2.log' doesn't have an ID yet, setting it to: 0ff1c032-0754-405f-8193-2fa4dbfb7d07",
                                               LevelFlags.Info, new DateTime(2016, 2, 17, 22, 57, 59, 305)));
                mergedLines[13].Should()
                               .Be(new LogLine(13, 13,
                                               "2016-02-17 22:57:59,306 [CurrentAppDomainHost.ExecuteNodes] WARN  Tailviewer.Settings.DataSources - Selected item '00000000-0000-0000-0000-000000000000' not found in data-sources, ignoring it...",
                                               LevelFlags.Warning, new DateTime(2016, 2, 17, 22, 57, 59, 306)));
                mergedLines[14].Should()
                               .Be(new LogLine(14, 14,
                                               "2016-02-17 22:57:59,307 [CurrentAppDomainHost.ExecuteNodes] WARN  Tailviewer.Settings.DataSources - Selected item '00000000-0000-0000-0000-000000000000' not found in data-sources, ignoring it...",
                                               LevelFlags.Warning, new DateTime(2016, 2, 17, 22, 57, 59, 307)));
                mergedLines[15].Should()
                               .Be(new LogLine(15, 15,
                                               "2016-02-17 22:57:59,310 [CurrentAppDomainHost.ExecuteNodes] WARN  Tailviewer.Settings.DataSources - Selected item '00000000-0000-0000-0000-000000000000' not found in data-sources, ignoring it...",
                                               LevelFlags.Warning, new DateTime(2016, 2, 17, 22, 57, 59, 310)));
                mergedLines[16].Should()
                               .Be(new LogLine(16, 16,
                                               "2016-02-17 22:57:59,311 [CurrentAppDomainHost.ExecuteNodes] WARN  Tailviewer.Settings.DataSources - Selected item '00000000-0000-0000-0000-000000000000' not found in data-sources, ignoring it...",
                                               LevelFlags.Warning, new DateTime(2016, 2, 17, 22, 57, 59, 311)));
                mergedLines[17].Should()
                               .Be(new LogLine(17, 17,
                                               @"2016-02-17 22:57:59,863 [CurrentAppDomainHost.ExecuteNodes] WARN  Tailviewer.BusinessLogic.DataSources - DataSource 'foo (ec976867-195b-4adf-a819-a1427f0d9aac)' is assigned a parent 'f671f235-7084-4e57-b06a-d253f750fae6' but we don't know that one",
                                               LevelFlags.Warning, new DateTime(2016, 2, 17, 22, 57, 59, 863)));
                mergedLines[18].Should()
                               .Be(new LogLine(18, 18,
                                               @"2016-02-17 22:57:59,864 [CurrentAppDomainHost.ExecuteNodes] WARN  Tailviewer.BusinessLogic.DataSources - DataSource 'foo (ec976867-195b-4adf-a819-a1427f0d9aac)' is assigned a parent 'f671f235-7084-4e57-b06a-d253f750fae6' but we don't know that one",
                                               LevelFlags.Warning, new DateTime(2016, 2, 17, 22, 57, 59, 864)));
            }
        }
Exemplo n.º 21
0
        public void TestReadAll3()
        {
            using (var file = new LogFile(_scheduler, File20Mb))
            {
                file.MaxCharactersPerLine.Should().Be(0);

                file.Property(x => x.EndOfSourceReached).ShouldEventually().BeTrue(TimeSpan.FromSeconds(20));

                file.Count.Should().Be(165342);
                file.MaxCharactersPerLine.Should().Be(218);
            }
        }