private void Initialize(StdOutputHealthReporterConfiguration configuration) { Requires.NotNull(configuration, nameof(configuration)); // Prepare the configuration, set default values, handle invalid values. this.Configuration = configuration; this.formatTokens = new FormatTokenizer().Tokenize(Configuration.MessageFormat ?? DefaultMessageFormat); HealthReportLevel logLevel; string logLevelString = this.Configuration.MinReportLevel; if (string.IsNullOrWhiteSpace(logLevelString)) { this.minReportLevel = HealthReportLevel.Problem; } else if (Enum.TryParse(logLevelString, out logLevel)) { this.minReportLevel = logLevel; } else { this.minReportLevel = HealthReportLevel.Problem; // The severity has to be at least the same as the default level of problem. ReportProblem($"Failed to parse log level. Please check the value of: {logLevelString}. Falling back to default value: {this.minReportLevel.ToString()}", TraceTag); } this.Configuration.MinReportLevel = this.minReportLevel.ToString(); }
/// <summary> /// Create a StdOutputHealthReporter with configuration. /// </summary> /// <param name="configuration">StdOutputHealthReporter configuration.</param> public StdOutputHealthReporter(StdOutputHealthReporterConfiguration configuration) { Initialize(configuration); }