コード例 #1
0
ファイル: HerculesLogBuilder.cs プロジェクト: vostok/hosting
        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));
        }