public void LogFilterTypeCategoryBlock() { BasicAmbientSettingsSet settings = new BasicAmbientSettingsSet(nameof(LogFilterTypeCategoryBlock)); settings.ChangeSetting(nameof(LogFilterTypeCategoryBlock) + "-" + nameof(AmbientLogFilter) + "-LogLevel", AmbientLogLevel.Information.ToString()); settings.ChangeSetting(nameof(LogFilterTypeCategoryBlock) + "-" + nameof(AmbientLogFilter) + "-TypeAllow", null); settings.ChangeSetting(nameof(LogFilterTypeCategoryBlock) + "-" + nameof(AmbientLogFilter) + "-TypeBlock", ".*[Bb]lock.*"); settings.ChangeSetting(nameof(LogFilterTypeCategoryBlock) + "-" + nameof(AmbientLogFilter) + "-CategoryAllow", null); settings.ChangeSetting(nameof(LogFilterTypeCategoryBlock) + "-" + nameof(AmbientLogFilter) + "-CategoryBlock", ".*[Bb]lock.*"); AmbientLogFilter filter = new AmbientLogFilter(nameof(LogFilterTypeCategoryBlock), settings); Assert.AreEqual(AmbientLogLevel.Information, filter.LogLevel); Assert.IsFalse(filter.IsTypeBlocked("test")); Assert.IsTrue(filter.IsTypeBlocked("testblock")); Assert.IsFalse(filter.IsCategoryBlocked("test")); Assert.IsTrue(filter.IsCategoryBlocked("testblock")); }
public void AmbientSettingsInfo() { AmbientLogFilter filter = AmbientLogFilter.Default; filter.IsBlocked(AmbientLogLevel.Critical, "TestType", "TestCategory"); int ambientLogFilterSettings = 0; string settingsDescriptions = ""; foreach (IAmbientSettingInfo info in AmbientSettings.AmbientSettingsInfo) { if (info.Key.StartsWith(filter.Name + "-" + nameof(AmbientLogFilter))) { ++ambientLogFilterSettings; } settingsDescriptions += $"{info.Key}:{info.Description} @{info.LastUsed.ToShortDateString()} {info.LastUsed.ToShortTimeString()}" + Environment.NewLine; } Assert.AreEqual(5, ambientLogFilterSettings); }
public void LogFilterBlock() { BasicAmbientSettingsSet settings = new BasicAmbientSettingsSet(nameof(LogFilterBlock)); settings.ChangeSetting(nameof(LogFilterBlock) + "-" + nameof(AmbientLogFilter) + "-LogLevel", AmbientLogLevel.Information.ToString()); settings.ChangeSetting(nameof(LogFilterBlock) + "-" + nameof(AmbientLogFilter) + "-TypeBlock", ".*[Bb]lock.*"); settings.ChangeSetting(nameof(LogFilterBlock) + "-" + nameof(AmbientLogFilter) + "-CategoryBlock", ".*[Bb]lock.*"); AmbientLogFilter filter = new AmbientLogFilter(nameof(LogFilterBlock), settings); Assert.IsFalse(filter.IsBlocked(AmbientLogLevel.Information, "test", "test")); Assert.IsTrue(filter.IsBlocked(AmbientLogLevel.Trace, "test", "test")); Assert.IsTrue(filter.IsBlocked(AmbientLogLevel.Information, "testBlock", "test")); Assert.IsTrue(filter.IsBlocked(AmbientLogLevel.Trace, "testBlock", "test")); Assert.IsTrue(filter.IsBlocked(AmbientLogLevel.Information, "test", "testBlock")); Assert.IsTrue(filter.IsBlocked(AmbientLogLevel.Trace, "test", "testBlock")); Assert.IsTrue(filter.IsBlocked(AmbientLogLevel.Information, "testBlock", "testBlock")); Assert.IsTrue(filter.IsBlocked(AmbientLogLevel.Trace, "testBlock", "testBlock")); Assert.IsFalse(filter.IsBlocked(AmbientLogLevel.Information, "test", null)); Assert.IsTrue(filter.IsBlocked(AmbientLogLevel.Trace, "test", null)); Assert.IsTrue(filter.IsBlocked(AmbientLogLevel.Information, "testBlock", null)); Assert.IsTrue(filter.IsBlocked(AmbientLogLevel.Trace, "testBlock", null)); }