/// <summary> /// This will call all available methods on the ILogger /// </summary> public static void TestAllLogMethods(ILogger loggerUnderTest) { var logSource = LogSource.ForCustomSource(Guid.NewGuid().ToString()); logSource.LogTo(loggerUnderTest); try { AssertLogLevels(logSource, loggerUnderTest); AssertWriteLines(logSource); } finally { LoggerMapper.DeRegisterLoggerFor(logSource, loggerUnderTest); } }
public void TestMapping() { var defaultLogger = LogSettings.RegisterDefaultLogger <StringWriterLogger>(); var differentLogSource = LogSource.ForCustomSource("Test"); var logger = new StringWriterLogger(); LoggerMapper.RegisterLoggerFor("Test", logger); const string visibleMessage = "Should be visible"; const string notVisibleMessage = "Should be NOT visible in logger, but arrive in the defaultLogger"; differentLogSource.Info().WriteLine(visibleMessage); Log.Info().WriteLine(notVisibleMessage); Assert.Contains(visibleMessage, logger.Output); Assert.DoesNotContain(notVisibleMessage, logger.Output); Assert.Contains(notVisibleMessage, defaultLogger.Output); defaultLogger.Clear(); LoggerMapper.DeRegisterLoggerFor("Test", logger); differentLogSource.Info().WriteLine(notVisibleMessage); Assert.DoesNotContain(notVisibleMessage, logger.Output); Assert.Contains(notVisibleMessage, defaultLogger.Output); }