示例#1
0
        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);

            return(logCustomization.Customize(new HerculesLog(settings)));
        }
示例#2
0
 private bool IsEnabledFor(HerculesLogSettings settings, LogLevel level)
 => Array.IndexOf(settings.EnabledLogLevels, level) >= 0;
示例#3
0
 /// <summary>
 /// Create a new <see cref="HerculesLog"/> with given static settings.
 /// </summary>
 public HerculesLog(HerculesLogSettings settings)
     : this(() => settings)
 {
 }