public static IHealthChecksBuilder AddLoggerHealthCheck(this IHealthChecksBuilder builder, string?name = default, Action <LoggerHealthCheckOptions>?setup = default, IEnumerable <string>?tags = default, HealthStatus failureStatus = HealthStatus.Unhealthy) { var options = new LoggerHealthCheckOptions(); setup?.Invoke(options); return(builder.Add(new HealthCheckRegistration( name ?? LOGS_NAME, sp => new LoggerHealthCheck.LoggerHealthCheck(sp.GetRequiredService <HealthCheckLoggerProvider>(), sp.GetRequiredService <IHealthMessageFormatter>(), options), failureStatus, tags))); }
/// <summary> /// Creates a healthcheck that with the specified filter /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public static IHealthChecksBuilder AddLoggerHealthCheckForType <T>(IHealthChecksBuilder builder, string?name, Action <LoggerHealthCheckOptions>?setup, IEnumerable <string>?tags, HealthStatus failureStatus, Func <LogEntry, bool> typeFilter) { var options = new LoggerHealthCheckOptions(); setup?.Invoke(options); if (options.Filter != Filters.DefaultHealthCheck) { var customFilter = options.Filter; options.Filter = Filters.Combine(customFilter, typeFilter); } else { options.Filter = typeFilter; } return(builder.Add(new HealthCheckRegistration( name ?? typeof(T).Name, sp => new LoggerHealthCheck.LoggerHealthCheck(sp.GetRequiredService <HealthCheckLoggerProvider>(), sp.GetRequiredService <IHealthMessageFormatter>(), options), failureStatus, tags))); }