Esempio n. 1
0
 public Logger(string name, SlackLoggerOptions options, Func <string, LogLevel, bool> scopeFilter)
 {
     _name             = name;
     _environmentName  = options.EnvironmentName ?? "";
     _options          = options;
     _enabledLogLevels = GetEnabledLogLevels(_options.LogLevel);
     _scopeFilter      = scopeFilter ?? ((category, logLevel) => true);
 }
        public LoggerProvider(IOptions <LoggerFilterOptions> filterOptions, IOptions <SlackLoggerOptions> options, IConfiguration configuration, IHostingEnvironment env)
        {
            _options = options.Value;
            _options.Merge(configuration.GetSection("Logging:Slack"));

            _options.EnvironmentName = env?.EnvironmentName;
            _options.ApplicationName = !string.IsNullOrEmpty(_options.ApplicationName)
                ? _options.ApplicationName
                : env?.ApplicationName;

            _options.ValidateWebookUrl();

            var filterSettings = filterOptions.Value;

            if (!filterSettings.Rules.Any())
            {
                filterSettings.Rules.Add(new LoggerFilterRule(null, null, LogLevel.Information, null));
            }
            _scopeSettings = new ScopeSettings(filterSettings);
        }
Esempio n. 3
0
 public static string Sanitize(this string input, SlackLoggerOptions options)
 =>
 options.SanitizeOutputFunction != null?
 options.SanitizeOutputFunction(input) :
     input;
Esempio n. 4
0
 public SlackService(SlackLoggerOptions options)
 {
     _options = options;
 }