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);
        }
Beispiel #2
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();
        }