public void TestGetLogger() { var manager = new LogManagerBase(new LoggingConfiguration()); var logger = manager.GetLogger("Foobar"); Assert.NotNull(logger); }
public void TestGetLoggerByType() { var manager = new LogManagerBase(new LoggingConfiguration()); var logger = manager.GetLogger<LogManagerBaseTests>(); Assert.NotNull(logger); }
public void TestGetLoggerByType() { var manager = new LogManagerBase(new LoggingConfiguration()); var logger = manager.GetLogger <LogManagerBaseTests>(); Assert.NotNull(logger); }
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); }
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); }
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); }
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); }
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); } }