public void CanHandleNullDataValue()
 {
     var logManager = new LogManager();
     var log = logManager.GetLoggerForCallingType();
     var lb = log.Data("a", null);
     var s = new DefaultStringConverter().Convert(lb.Entry);
     Assert.True(s.Contains("a: null"));
 }
        public void TestDataIndention()
        {
            var logManager = new LogManager();
            var log = logManager.GetLoggerForCallingType();

            var lb = log.Data("a","happy test").Data("test", "abc\r\nxyz\r\n123").Data("test2", "abc\r\nxyz\r\n123").Data("test3", "abc\r\nxyz\r\n123");

            var s = new DefaultStringConverter().Convert(lb.Entry);

            Console.WriteLine(s);
        }
        public void CanHandleAnonTypes()
        {
            using (var logManager = new LogManager(new[]{new ConsoleTarget()}))
            {
                logManager.UnhandledLoggingException += (s, e) => Console.WriteLine(e.Exception.ToString());

                var log = logManager.GetLoggerForCallingType();

                log.Info(new { Abc = 123 });
                log.Info(new { Abc = 123 }.ToString());
                log.Info("{0}", new { Abc = 123 });
            }
        }
Ejemplo n.º 4
0
        public void BasicEmail()
        {
            var email = new EmailTarget
            {
                From = "*****@*****.**",
                To = "*****@*****.**",
                Interval = LoggingInterval.Parse("1 second")
            };

            var mgr = new LogManager(new[] { email });
            mgr.UnhandledLoggingException += (sender, args) => { throw args.Exception; };

            var log = mgr.GetLoggerForCallingType();

            for (var i = 0; i < 10000; i++)
                log.Info("test");

            mgr.Dispose();
        }
Ejemplo n.º 5
0
        public void CanLogToRAM()
        {
            var memoryTarget = new MemoryTarget { Capacity = 2 };
            var mgr = new LogManager(new[] { memoryTarget, });
            mgr.UnhandledLoggingException += UnhandledException;
            var log = mgr.GetLoggerForCallingType();
            log.Info("Test");
            log.Warn("something bad");
            log.Fatal("ALERT!");
            mgr.Dispose();

            Console.WriteLine(memoryTarget.View());
        }
Ejemplo n.º 6
0
        public void WhatsWRongWithThisCOnfig()
        {
            var mgr = new LogManager();
            var mail =
                new EmailTarget
                {
                    To = "*****@*****.**",
                    Subject = "WTF",
                    //Interval = LoggingInterval.Parse("1 minute")
                };

            mgr.Targets.Add(mail);

            var log = mgr.GetLoggerForCallingType();

            log.Info("test");
            Thread.Sleep(1000);
            mgr.Dispose();
        }
Ejemplo n.º 7
0
        public void LogToFilesInterval()
        {
            var fileTarget = new FileTarget();
            var mgr = new LogManager(new[] { fileTarget });

            fileTarget.Configure(XElement.Parse(@"<target path=""C:\Users\roverby\Desktop\logtest"" interval=""5 second"" archivecount=""3"" />"));

            Assert.AreEqual(3, fileTarget.ArchiveCount);
            Assert.AreEqual(TimeSpan.FromSeconds(5), fileTarget.Interval.Duration);

            mgr.UnhandledLoggingException += (sender, args) => { throw args.Exception; };
            var log = mgr.GetLoggerForCallingType();
            for (var i = 0; i < 1000 * 1000; i++)
            {
                log.Info("test");
                log.Warn("YIKE!");
            }

            mgr.Dispose();
        }
Ejemplo n.º 8
0
        public void LogToFileInDirectory()
        {
            var fileTarget = new FileTarget { Path = @"C:\Users\roverby\Desktop\mylogz.xxx\" };
            var mgr = new LogManager(new[] { fileTarget });
            mgr.UnhandledLoggingException += (sender, args) => { throw args.Exception; };
            var log = mgr.GetLoggerForCallingType();

            for (var i = 0; i < 10000; i++)
            {
                log.Info("test");
                log.Warn("YIKE!");
            }

            mgr.Dispose();
        }
Ejemplo n.º 9
0
        public void LogToFile()
        {
            var fileTarget = new FileTarget
            {
                Path = @"C:\Users\roverby\Desktop\log.test.txt",
                //Interval= LoggingInterval.Parse("5 second"),
                //ArchiveCount= 3,
                KeepFileOpen = true

            };
            var mgr = new LogManager(new[] { fileTarget });
            mgr.UnhandledLoggingException += (sender, args) => { throw args.Exception; };
            var log = mgr.GetLoggerForCallingType();

            for (var i = 0; i < 10000; i++)
            {
                log.Info("test");
                log.Warn("YIKE!");
            }

            mgr.Dispose();
        }
Ejemplo n.º 10
0
        public void eventvwr()
        {
            var email = new EventLogTarget()
            {
                EventLogSource = "Poopy"
            };

            var mgr = new LogManager(new[] { email });
            mgr.UnhandledLoggingException += (sender, args) => { throw args.Exception; };

            var log = mgr.GetLoggerForCallingType();

            for (var i = 0; i < 10; i++)
                log.Info("test");

            mgr.Dispose();
        }