示例#1
0
        public void TestGetLogger()
        {
            var manager = new LogManagerBase(new LoggingConfiguration());

            var logger = manager.GetLogger("Foobar");
            Assert.NotNull(logger);
        }
示例#2
0
        public void TestGetLoggerByType()
        {
            var manager = new LogManagerBase(new LoggingConfiguration());

            var logger = manager.GetLogger<LogManagerBaseTests>();
            Assert.NotNull(logger);
        }
示例#3
0
        public void TestGetLoggerByType()
        {
            var manager = new LogManagerBase(new LoggingConfiguration());

            var logger = manager.GetLogger <LogManagerBaseTests>();

            Assert.NotNull(logger);
        }
示例#4
0
        public void TestGetLogger()
        {
            var manager = new LogManagerBase(new LoggingConfiguration());

            var logger = manager.GetLogger("Foobar");

            Assert.NotNull(logger);
        }
示例#5
0
        public void TestLoggerCreated()
        {
            bool called = false;
            var manager = new LogManagerBase(new LoggingConfiguration());
            manager.LoggerCreated += (sender, args) =>
            {
                called = true;
            };

            // call...
            var logger = manager.GetLogger<LogManagerBaseTests>();
            
            // check...
            Assert.True(called);
        }
示例#6
0
        public void TestIsFatalEnabled()
        {
            var target = new LogManagerBase(new LoggingConfiguration());

            // get a logger...
            var logger = target.GetLogger("foo");

            // check...
            Assert.False(logger.IsTraceEnabled);
            Assert.False(logger.IsDebugEnabled);
            Assert.False(logger.IsInfoEnabled);
            Assert.False(logger.IsErrorEnabled);
            Assert.False(logger.IsErrorEnabled);
            Assert.False(logger.IsFatalEnabled);
        }
示例#7
0
        public void TestLoggerCreated()
        {
            bool called  = false;
            var  manager = new LogManagerBase(new LoggingConfiguration());

            manager.LoggerCreated += (sender, args) =>
            {
                called = true;
            };

            // call...
            var logger = manager.GetLogger <LogManagerBaseTests>();

            // check...
            Assert.True(called);
        }
示例#8
0
        public async Task TestBrokenTarget()
        {
            var testTarget = new TestTarget();

            var config = new LoggingConfiguration();
            config.AddTarget(LogLevel.Trace, LogLevel.Fatal, new BrokenTarget());
            config.AddTarget(LogLevel.Trace, LogLevel.Fatal, testTarget);

            var target = new LogManagerBase(config);

            // this should ignore errors in the broken target and flip down to the working target...
            var logger = (Logger)target.GetLogger("Foobar");
            await logger.TraceAsync("Hello, world.");

            // check...
            Assert.Equal(1, testTarget.NumWritten);
            Assert.Equal(LogLevel.Trace, testTarget.LastWritten.Level);
            Assert.Null(testTarget.LastWritten.Exception);
        }
示例#9
0
        public async Task TestBrokenTarget()
        {
            var testTarget = new TestTarget();

            var config = new LoggingConfiguration();

            config.AddTarget(LogLevel.Trace, LogLevel.Fatal, new BrokenTarget());
            config.AddTarget(LogLevel.Trace, LogLevel.Fatal, testTarget);

            var target = new LogManagerBase(config);

            // this should ignore errors in the broken target and flip down to the working target...
            var logger = (Logger)target.GetLogger("Foobar");
            await logger.TraceAsync("Hello, world.");

            // check...
            Assert.Equal(1, testTarget.NumWritten);
            Assert.Equal(LogLevel.Trace, testTarget.LastWritten.Level);
            Assert.Null(testTarget.LastWritten.Exception);
        }
示例#10
0
        public async Task TestGetZipNetFile()
        {

            var manager = new LogManagerBase(LogManagerFactory.CreateLibraryDefaultSettings());
            manager.DefaultConfiguration.AddTarget(LogLevel.Trace, LogLevel.Fatal, new StreamingFileTarget());

            var logger = (ILoggerAsync)manager.GetLogger("test");
            // send through a log entry...
            await logger.DebugAsync("Test Message");

            var str = await manager.GetCompressedLogs();

            var file =
              new FileInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory, Environment.SpecialFolderOption.None), "logs.zip"));



            using (var stream = file.Create())
            {
                await str.CopyToAsync(stream);
            }
        }
示例#11
0
        public async Task TestGetZipNetFile()
        {
            var manager = new LogManagerBase(LogManagerFactory.CreateLibraryDefaultSettings());

            manager.DefaultConfiguration.AddTarget(LogLevel.Trace, LogLevel.Fatal, new StreamingFileTarget());

            var logger = (ILoggerAsync)manager.GetLogger("test");
            // send through a log entry...
            await logger.DebugAsync("Test Message");

            var str = await manager.GetCompressedLogs();

            var file =
                new FileInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory, Environment.SpecialFolderOption.None), "logs.zip"));



            using (var stream = file.Create())
            {
                await str.CopyToAsync(stream);
            }
        }
示例#12
0
        public void TestIsFatalEnabled()
        {
            var target = new LogManagerBase(new LoggingConfiguration());

            // get a logger...
            var logger = target.GetLogger("foo");

            // check...
            Assert.False(logger.IsTraceEnabled);
            Assert.False(logger.IsDebugEnabled);
            Assert.False(logger.IsInfoEnabled);
            Assert.False(logger.IsErrorEnabled);
            Assert.False(logger.IsErrorEnabled);
            Assert.False(logger.IsFatalEnabled);
        }