Exemplo n.º 1
0
        public static void LogConfiguration(IServiceProvider serviceProvider, AppOptions appOptions, ILoggerFactory loggerFactory)
        {
            var logger = loggerFactory.CreateLogger <Bootstrapper>();

            if (!logger.IsEnabled(LogLevel.Warning))
            {
                return;
            }

            var cacheOptions = serviceProvider.GetRequiredService <IOptions <CacheOptions> >();

            if (String.IsNullOrEmpty(cacheOptions.Value.Provider))
            {
                logger.LogWarning("Distributed cache is NOT enabled on {MachineName}.", Environment.MachineName);
            }

            var messageBusOptions = serviceProvider.GetRequiredService <IOptions <MessageBusOptions> >();

            if (String.IsNullOrEmpty(messageBusOptions.Value.Provider))
            {
                logger.LogWarning("Distributed message bus is NOT enabled on {MachineName}.", Environment.MachineName);
            }

            var metricsOptions = serviceProvider.GetRequiredService <IOptions <MetricOptions> >();

            if (String.IsNullOrEmpty(metricsOptions.Value.Provider))
            {
                logger.LogWarning("Metrics reporting is NOT enabled on {MachineName}.", Environment.MachineName);
            }

            var queueOptions = serviceProvider.GetRequiredService <IOptions <QueueOptions> >();

            if (String.IsNullOrEmpty(queueOptions.Value.Provider))
            {
                logger.LogWarning("Distributed queue is NOT enabled on {MachineName}.", Environment.MachineName);
            }

            var storageOptions = serviceProvider.GetRequiredService <IOptions <StorageOptions> >();

            if (String.IsNullOrEmpty(storageOptions.Value.Provider))
            {
                logger.LogWarning("Distributed storage is NOT enabled on {MachineName}.", Environment.MachineName);
            }

            if (!appOptions.EnableWebSockets)
            {
                logger.LogWarning("Web Sockets is NOT enabled on {MachineName}", Environment.MachineName);
            }

            if (appOptions.AppMode == AppMode.Development)
            {
                logger.LogWarning("Emails will NOT be sent in Development mode on {MachineName}", Environment.MachineName);
            }

            var fileStorage = serviceProvider.GetRequiredService <IFileStorage>();

            if (fileStorage is InMemoryFileStorage)
            {
                logger.LogWarning("Using in memory file storage on {MachineName}", Environment.MachineName);
            }

            if (!appOptions.EnableBootstrapStartupActions)
            {
                logger.LogWarning("Startup Actions is NOT enabled on {MachineName}", Environment.MachineName);
            }

            var elasticsearchOptions = serviceProvider.GetRequiredService <IOptions <ElasticsearchOptions> >();

            if (elasticsearchOptions.Value.DisableIndexConfiguration)
            {
                logger.LogWarning("Index Configuration is NOT enabled on {MachineName}", Environment.MachineName);
            }

            if (appOptions.EventSubmissionDisabled)
            {
                logger.LogWarning("Event Submission is NOT enabled on {MachineName}", Environment.MachineName);
            }

            var authOptions = serviceProvider.GetRequiredService <IOptions <AuthOptions> >();

            if (!authOptions.Value.EnableAccountCreation)
            {
                logger.LogWarning("Account Creation is NOT enabled on {MachineName}", Environment.MachineName);
            }
        }
Exemplo n.º 2
0
        public static void LogConfiguration(IServiceProvider serviceProvider, AppOptions appOptions, ILogger logger)
        {
            if (!logger.IsEnabled(LogLevel.Warning))
            {
                return;
            }

            if (String.IsNullOrEmpty(appOptions.CacheOptions.Provider))
            {
                logger.LogWarning("Distributed cache is NOT enabled on {MachineName}.", Environment.MachineName);
            }

            if (String.IsNullOrEmpty(appOptions.MessageBusOptions.Provider))
            {
                logger.LogWarning("Distributed message bus is NOT enabled on {MachineName}.", Environment.MachineName);
            }

            if (String.IsNullOrEmpty(appOptions.MetricOptions.Provider))
            {
                logger.LogWarning("Metrics reporting is NOT enabled on {MachineName}.", Environment.MachineName);
            }

            if (String.IsNullOrEmpty(appOptions.QueueOptions.Provider))
            {
                logger.LogWarning("Distributed queue is NOT enabled on {MachineName}.", Environment.MachineName);
            }

            if (String.IsNullOrEmpty(appOptions.StorageOptions.Provider))
            {
                logger.LogWarning("Distributed storage is NOT enabled on {MachineName}.", Environment.MachineName);
            }

            if (!appOptions.EnableWebSockets)
            {
                logger.LogWarning("Web Sockets is NOT enabled on {MachineName}", Environment.MachineName);
            }

            if (appOptions.AppMode == AppMode.Development)
            {
                logger.LogWarning("Emails will NOT be sent in Development mode on {MachineName}", Environment.MachineName);
            }
            else if (String.IsNullOrEmpty(appOptions.EmailOptions.SmtpHost))
            {
                logger.LogWarning("Emails will NOT be sent until the SmtpHost is configured on {MachineName}", Environment.MachineName);
            }

            var fileStorage = serviceProvider.GetService <IFileStorage>();

            if (fileStorage is InMemoryFileStorage)
            {
                logger.LogWarning("Using in memory file storage on {MachineName}", Environment.MachineName);
            }

            if (appOptions.ElasticsearchOptions.DisableIndexConfiguration)
            {
                logger.LogWarning("Index Configuration is NOT enabled on {MachineName}", Environment.MachineName);
            }

            if (appOptions.EventSubmissionDisabled)
            {
                logger.LogWarning("Event Submission is NOT enabled on {MachineName}", Environment.MachineName);
            }

            if (!appOptions.AuthOptions.EnableAccountCreation)
            {
                logger.LogWarning("Account Creation is NOT enabled on {MachineName}", Environment.MachineName);
            }
        }