public void TestFiltering()
        {
            var inMemoryProvider = new InMemoryDatabaseProvider();

            TheLog.AddProvider(inMemoryProvider, LogLevel.Info);

            TheLog.Info("Test");
            TheLog.Trace("Test2");
            TheLog.Error("Test");

            Assert.AreEqual(2, inMemoryProvider.Messages.Count);
        }
        public void TestFramework()
        {
            var inMemoryProvider = new InMemoryDatabaseProvider();

            TheLog.AddProvider(inMemoryProvider, LogLevel.Trace);

            TheLog.Info("Test");
            TheLog.Trace("Test2");
            TheLog.Error("Test");

            Assert.AreEqual(3, inMemoryProvider.Messages.Count);

            inMemoryProvider.ClearLog();
            Assert.AreEqual(0, inMemoryProvider.Messages.Count);

            TheLog.Log(LogLevel.Info, "Message");
            Assert.AreEqual(1, inMemoryProvider.Messages.Count);
        }
        public void TestLogLevel()
        {
            var database = new InMemoryDatabaseProvider();

            TheLog.FilterThreshold = LogLevel.Trace;
            TheLog.AddProvider(database, LogLevel.Trace);

            TheLog.Trace("Test");
            Assert.AreEqual(LogLevel.Trace, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel);
            TheLog.Debug("Test");
            Assert.AreEqual(LogLevel.Debug, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel);
            TheLog.Info("Test");
            Assert.AreEqual(LogLevel.Info, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel);
            TheLog.Warn("Test");
            Assert.AreEqual(LogLevel.Warn, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel);
            TheLog.Error("Test");
            Assert.AreEqual(LogLevel.Error, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel);
            TheLog.Fatal("Test");
            Assert.AreEqual(LogLevel.Fatal, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel);
        }
Example #4
0
        static void Main(string[] args)
        {
            TheLog.AddProvider(new ConsoleProvider(), LogLevel.Trace);
            TheLog.AddProvider(new FileProvider("test.log", true), LogLevel.Info);
            TheLog.Trace("Not added");
            Thread.Sleep(100);
            TheLog.Debug("This is a debug message");
            Thread.Sleep(80);
            TheLog.Info("We have an info message.");
            Thread.Sleep(80);
            TheLog.Warn("We have a warn");
            Thread.Sleep(80);
            TheLog.Error("Error Occured....");
            Thread.Sleep(80);
            TheLog.Fatal("We have to quit the application due to loss of O².");
            Thread.Sleep(80);
            new WorkingMan().Work();

            System.Console.WriteLine("Press key");
            System.Console.ReadKey();
        }