public void Setup() { stream = "test_stream_for_logs"; sink = Substitute.For <IHerculesSink>(); log = new HerculesLog(new HerculesLogSettings(sink, stream)); }
public void IsEnabledFor_should_respect_enabled_log_levels() { sink = Substitute.For <IHerculesSink>(); log = new HerculesLog(new HerculesLogSettings(sink, "stream") { EnabledLogLevels = new[] { LogLevel.Debug, LogLevel.Warn, LogLevel.Fatal } }); log.IsEnabledFor(LogLevel.Debug).Should().BeTrue(); log.IsEnabledFor(LogLevel.Info).Should().BeFalse(); log.IsEnabledFor(LogLevel.Warn).Should().BeTrue(); log.IsEnabledFor(LogLevel.Error).Should().BeFalse(); log.IsEnabledFor(LogLevel.Fatal).Should().BeTrue(); }
public ILog Build(BuildContext context) { if (!enabled) { context.LogDisabled("HerculesLog"); return(null); } var herculesSink = context.HerculesSink; if (herculesSink == null) { context.LogDisabled("HerculesLog", "disabled HerculesSink"); return(null); } if (stream == null) { context.LogDisabled("HerculesLog", "unconfigured stream"); return(null); } if (apiKeyProvider != null) { herculesSink.ConfigureStream(stream, new StreamSettings { ApiKeyProvider = apiKeyProvider }); } var settings = new HerculesLogSettings(herculesSink, stream); settingsCustomization.Customize(settings); ILog log = new HerculesLog(settings); if (minLevelProvider != null) { log = log.WithMinimumLevel(minLevelProvider); } return(logCustomization.Customize(log)); }
public void Log_should_respect_enabled_log_levels() { sink = Substitute.For <IHerculesSink>(); log = new HerculesLog(new HerculesLogSettings(sink, "stream") { EnabledLogLevels = new[] { LogLevel.Debug, LogLevel.Warn, LogLevel.Fatal } }); log.Debug(""); sink.ReceivedCalls().Should().HaveCount(1); log.Info(""); sink.ReceivedCalls().Should().HaveCount(1); log.Warn(""); sink.ReceivedCalls().Should().HaveCount(2); log.Error(""); sink.ReceivedCalls().Should().HaveCount(2); log.Fatal(""); sink.ReceivedCalls().Should().HaveCount(3); }