public void TestLog()
        {
            var conf = new MonitorConfiguration()
            {
                LogLevel = "Info"
            };
            var logWriter = new TestLogWriter();
            Logger.Init(conf, new LogWriter[] { logWriter });

            Logger.Verbose("Trival");
            Assert.IsNull(logWriter.Msg);

            Logger.Info("Formated information: {0}", "Nothing");
            Assert.IsTrue(logWriter.Msg.Contains("Formated information"));
            Assert.AreEqual(LogLevel.Info, logWriter.Level);
            Console.WriteLine(logWriter.Msg);

            try
            {
                RaiseException();
            }
            catch(Exception e)
            {
                Logger.Error(e);
                //Check call stack is logged.
                Assert.IsTrue(logWriter.Msg.Contains("at UnitTest.LoggerTest.TestLog()"));
                Console.WriteLine(logWriter.Msg);
            }
        }
Ejemplo n.º 2
0
        public void TestLog()
        {
            var conf = new MonitorConfiguration()
            {
                LogLevel = "Info"
            };
            var logWriter = new TestLogWriter();

            Logger.Init(conf, new LogWriter[] { logWriter });

            Logger.Verbose("Trival");
            Assert.IsNull(logWriter.Msg);

            Logger.Info("Formated information: {0}", "Nothing");
            Assert.IsTrue(logWriter.Msg.Contains("Formated information"));
            Assert.AreEqual(LogLevel.Info, logWriter.Level);
            Console.WriteLine(logWriter.Msg);

            try
            {
                RaiseException();
            }
            catch (Exception e)
            {
                Logger.Error(e);
                //Check call stack is logged.
                Assert.IsTrue(logWriter.Msg.Contains("at UnitTest.LoggerTest.TestLog()"));
                Console.WriteLine(logWriter.Msg);
            }
        }
 public void TestLogLevelConfigure()
 {
     var conf = new MonitorConfiguration()
     {
         LogLevel = "Infoasdfasdf"
     };
     var logWriter = new TestLogWriter();
     Logger.Init(conf, new LogWriter[] { logWriter });
     Logger.Info("Test");
     Assert.AreEqual(LogLevel.Info, logWriter.Level);
 }
Ejemplo n.º 4
0
        public void TestLogLevelConfigure()
        {
            var conf = new MonitorConfiguration()
            {
                LogLevel = "Infoasdfasdf"
            };
            var logWriter = new TestLogWriter();

            Logger.Init(conf, new LogWriter[] { logWriter });
            Logger.Info("Test");
            Assert.AreEqual(LogLevel.Info, logWriter.Level);
        }