public void FileLogger_Log() { var timeStamp = DateTimeOffset.MinValue; var logWriter = new StatefulQueuedLogWriter(); var logger = new FileLogger(logWriter, "category", new FileLoggerOptions { TimeStampFactory = () => timeStamp }); logger.LogInformation("Test"); var expectedMessage = $"{timeStamp:yyyy-MM-dd HH:mm:ss} [Information] category: Test{Environment.NewLine}"; Assert.AreEqual(expectedMessage, logWriter.LastMessage.Message); }
public void FileLogger_Log_Enabled() { var logWriter = new StatefulQueuedLogWriter(); var logger = new FileLogger(logWriter, "category", new FileLoggerOptions { MinimumLogLevel = LogLevel.Information }); logger.LogDebug("foo"); Assert.IsNull(logWriter.LastMessage); logger.LogError("something went horribly wrong, call the police!"); Assert.IsNotNull(logWriter.LastMessage); }