コード例 #1
0
ファイル: LoggerExtensions.cs プロジェクト: lulzzz/piraeus-1
        public static ISiloHostBuilder AddLoggers(this ISiloHostBuilder siloBuilder, OrleansConfig config)
        {
            LoggerType loggerType = config.GetLoggerTypes();

            siloBuilder.ConfigureLogging(builder =>
            {
                if (loggerType.HasFlag(LoggerType.Console))
                {
                    builder.AddConsole();
                }

                if (loggerType.HasFlag(LoggerType.Debug))
                {
                    builder.AddDebug();
                }

                builder.SetMinimumLevel(Enum.Parse <LogLevel>(config.LogLevel));
            });

            if (loggerType.HasFlag(LoggerType.AppInsights))
            {
                siloBuilder.AddApplicationInsightsTelemetryConsumer(config.AppInsightsKey);
            }

            return(siloBuilder);
        }
コード例 #2
0
        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

            //if (!config.Dockerized)
            //{
            //    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);
            //    }
            //}

            Piraeus.Configuration.LoggerType loggers = config.GetLoggerTypes();

            if (loggers.HasFlag(Piraeus.Configuration.LoggerType.AppInsights))
            {
                builder.AddApplicationInsightsTelemetryConsumer(config.AppInsightsKey);
            }

            builder.ConfigureLogging(op =>
            {
                if (loggers.HasFlag(Piraeus.Configuration.LoggerType.AppInsights))
                {
                    op.AddApplicationInsights(config.AppInsightsKey);
                    op.SetMinimumLevel(Enum.Parse <LogLevel>(config.LogLevel, true));
                }

                if (loggers.HasFlag(Piraeus.Configuration.LoggerType.Console))
                {
                    op.AddConsole();
                    op.SetMinimumLevel(Enum.Parse <LogLevel>(config.LogLevel, true));
                }

                if (loggers.HasFlag(Piraeus.Configuration.LoggerType.Debug))
                {
                    op.AddDebug();
                    op.SetMinimumLevel(Enum.Parse <LogLevel>(config.LogLevel, true));
                }
            });

            return(builder);
        }