internal static IClientBuilder AddLoggers(this IClientBuilder clientBuilder, PiraeusGatewayOptions options) { clientBuilder.ConfigureLogging(builder => { if (options.LoggerTypes.HasFlag(LoggerType.Console) && options.LoggingLevel != LogLevel.None) { builder.AddConsole(); } if (options.LoggerTypes.HasFlag(LoggerType.Debug) && options.LoggingLevel != LogLevel.None) { builder.AddDebug(); } if (options.LoggingLevel != LogLevel.None) { builder.SetMinimumLevel(options.LoggingLevel); } }); if (options.LoggingLevel.HasFlag(LoggerType.AppInsights) && options.LoggingLevel != LogLevel.None && !string.IsNullOrEmpty(options.AppInsightKey)) { clientBuilder.AddApplicationInsightsTelemetryConsumer(options.AppInsightKey); } return(clientBuilder); }
private static IClientBuilder AddOrleansClusterClient(this IClientBuilder builder, OrleansConfig config) { builder.ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IPiSystem).Assembly)); #if DEBUG builder.UseLocalhostClustering(); #else builder.Configure <ClusterOptions>(options => { options.ClusterId = config.ClusterId; options.ServiceId = config.ServiceId; }); if (config.DataConnectionString.Contains("6379") || config.DataConnectionString.Contains("6380")) { builder.UseRedisGatewayListProvider(options => options.ConnectionString = config.DataConnectionString); } else { builder.UseAzureStorageClustering(options => options.ConnectionString = config.DataConnectionString); } #endif LoggerType loggers = config.GetLoggerTypes(); if (loggers.HasFlag(LoggerType.AppInsights)) { builder.AddApplicationInsightsTelemetryConsumer(config.InstrumentationKey); } builder.ConfigureLogging(op => { if (loggers.HasFlag(LoggerType.AppInsights)) { op.AddApplicationInsights(config.InstrumentationKey); op.SetMinimumLevel(Enum.Parse <LogLevel>(config.LogLevel, true)); } if (loggers.HasFlag(LoggerType.Console)) { op.AddConsole(); op.SetMinimumLevel(Enum.Parse <LogLevel>(config.LogLevel, true)); } if (loggers.HasFlag(LoggerType.Debug)) { op.AddDebug(); op.SetMinimumLevel(Enum.Parse <LogLevel>(config.LogLevel, true)); } }); return(builder); }
private IClientBuilder AddAppInsighlts(IClientBuilder builder, LoggerType loggers, string instrumentationKey = null) { if (string.IsNullOrEmpty(instrumentationKey)) { return(builder); } if (loggers.HasFlag(Piraeus.Configuration.LoggerType.AppInsights)) { builder.AddApplicationInsightsTelemetryConsumer(instrumentationKey); } return(builder); }