public void ValidAppsettingsFilter() { var configSection = LoggerConfigSectionSetup("ValidAppsettingsFilter.json", null).GetSection("LogLevel"); if (!(configSection != null && configSection.GetChildren().Count() > 0)) { configSection = null; } var categoryName = typeof(TestFilter).GetTypeInfo().FullName; var coreLogger = new FakeCoreLogger(); var logger = new AWSLogger( categoryName, coreLogger, AWSLoggerProvider.CreateConfigSectionFilter(configSection, categoryName)); logger.LogTrace("trace"); logger.LogDebug("debug"); logger.LogInformation("information"); logger.LogWarning("warning"); logger.LogError("error"); logger.LogCritical("critical"); Assert.Equal(5, coreLogger.ReceivedMessages.Count); Assert.True(coreLogger.ReceivedMessages.Contains("warning\r\n")); Assert.True(coreLogger.ReceivedMessages.Contains("error\r\n")); Assert.True(coreLogger.ReceivedMessages.Contains("critical\r\n")); }
public void DefaultFilterCheck() { var configSection = LoggerConfigSectionSetup("DefaultFilterCheck.json", null).GetSection("LogLevel"); if (!(configSection != null && configSection.GetChildren().Count() > 0)) { configSection = null; } var categoryName = "AWS.Log"; var coreLogger = new FakeCoreLogger(); var logger = new AWSLogger( categoryName, coreLogger, AWSLoggerProvider.CreateConfigSectionFilter(configSection, categoryName)); logger.LogTrace("trace"); logger.LogDebug("debug"); logger.LogInformation("information"); logger.LogWarning("warning"); logger.LogError("error"); logger.LogCritical("critical"); Assert.Equal(5, coreLogger.ReceivedMessages.Count); Assert.True(coreLogger.ReceivedMessages.Contains("warning")); Assert.True(coreLogger.ReceivedMessages.Contains("error")); Assert.True(coreLogger.ReceivedMessages.Contains("critical")); }
public void MissingLogLevelCheck() { var configSection = LoggerConfigSectionSetup("MissingLogLevelCheck.json", null).GetSection("LogLevel"); if (!(configSection != null && configSection.GetChildren().Count() > 0)) { configSection = null; } var categoryName = typeof(TestFilter).GetTypeInfo().FullName; var coreLogger = new FakeCoreLogger(); var logger = new AWSLogger( categoryName, coreLogger, AWSLoggerProvider.CreateConfigSectionFilter(configSection, categoryName)); logger.LogTrace("trace"); logger.LogDebug("debug"); logger.LogInformation("information"); logger.LogWarning("warning"); logger.LogError("error"); logger.LogCritical("critical"); Assert.Equal(6, coreLogger.ReceivedMessages.Count); Assert.Contains($"[Warning] AWS.Logger.AspNetCore.Tests.TestFilter: warning{Environment.NewLine}", coreLogger.ReceivedMessages); Assert.Contains($"[Error] AWS.Logger.AspNetCore.Tests.TestFilter: error{Environment.NewLine}", coreLogger.ReceivedMessages); Assert.Contains($"[Critical] AWS.Logger.AspNetCore.Tests.TestFilter: critical{Environment.NewLine}", coreLogger.ReceivedMessages); }
public void FilterLogLevel() { var coreLogger = new FakeCoreLogger(); var logger = new AWSLogger("FilterLogLevel", coreLogger, AWSLoggerProvider.CreateLogLevelFilter(LogLevel.Warning)); logger.LogTrace("trace"); logger.LogDebug("debug"); logger.LogInformation("information"); logger.LogWarning("warning"); logger.LogError("error"); logger.LogCritical("critical"); Assert.Equal(3, coreLogger.ReceivedMessages.Count); Assert.True(coreLogger.ReceivedMessages.Contains("warning\r\n")); Assert.True(coreLogger.ReceivedMessages.Contains("error\r\n")); Assert.True(coreLogger.ReceivedMessages.Contains("critical\r\n")); }
public void FilterLogLevel() { var coreLogger = new FakeCoreLogger(); var logger = new AWSLogger("FilterLogLevel", coreLogger, AWSLoggerProvider.CreateLogLevelFilter(LogLevel.Warning)); logger.LogTrace("trace"); logger.LogDebug("debug"); logger.LogInformation("information"); logger.LogWarning("warning"); logger.LogError("error"); logger.LogCritical("critical"); Assert.Equal(3, coreLogger.ReceivedMessages.Count); Assert.Contains($"[Warning] FilterLogLevel: warning{Environment.NewLine}", coreLogger.ReceivedMessages); Assert.Contains($"[Error] FilterLogLevel: error{Environment.NewLine}", coreLogger.ReceivedMessages); Assert.Contains($"[Critical] FilterLogLevel: critical{Environment.NewLine}", coreLogger.ReceivedMessages); }