Exemple #1
0
        public static ILoggerFactory AddSlack(this ILoggerFactory factory, Func <string, LogLevel, Exception, bool> filter, SlackConfiguration configuration,
                                              string applicationName, string environmentName, HttpClient client = null)
        {
            //dee for legacy support
            if (null != filter)
            {
                configuration.filter = (s, l, e) => filter(s, l, e);
            }

            if (string.IsNullOrEmpty(applicationName))
            {
                throw new ArgumentNullException(nameof(applicationName));
            }

            if (string.IsNullOrEmpty(environmentName))
            {
                throw new ArgumentNullException(nameof(environmentName));
            }

            ILoggerProvider provider = new SlackLoggerProvider(configuration, client, applicationName, environmentName);

            factory.AddProvider(provider);

            return(factory);
        }
        public static ILoggingBuilder AddSlack(this ILoggingBuilder builder, Func <string, LogLevel, Exception, bool> filter, SlackConfiguration configuration, IHostingEnvironment hostingEnvironment, HttpClient client = null)
        {
            ILoggerProvider provider = new SlackLoggerProvider(filter, configuration, client, hostingEnvironment.ApplicationName, hostingEnvironment.EnvironmentName);

            builder.AddProvider(provider);

            return(builder);
        }
        public static ILoggingBuilder AddSlack(this ILoggingBuilder builder, SlackConfiguration configuration, IHostingEnvironment hostingEnvironment, HttpClient client = null)
        {
            ILoggerProvider provider = new SlackLoggerProvider((n, l, e) => l >= configuration.MinLevel, configuration, client, hostingEnvironment.ApplicationName, hostingEnvironment.EnvironmentName);

            builder.AddProvider(provider);

            return(builder);
        }
        public static ILoggingBuilder AddSlack(this ILoggingBuilder builder, SlackConfiguration configuration, string applicationName, string environmentName, HttpClient client = null)
        {
            if (string.IsNullOrEmpty(applicationName))
            {
                throw new ArgumentNullException(nameof(applicationName));
            }

            if (string.IsNullOrEmpty(environmentName))
            {
                throw new ArgumentNullException(nameof(environmentName));
            }

            ILoggerProvider provider = new SlackLoggerProvider((n, l, e) => l >= configuration.MinLevel, configuration, client, applicationName, environmentName);

            builder.AddProvider(provider);

            return(builder);
        }