Exemple #1
0
        /// <summary>
        /// 应用AspNetCore的服务业务
        /// </summary>
        /// <param name="app">Asp应用程序构建器</param>
        public override void UsePack(IApplicationBuilder app)
        {
            IServiceProvider serviceProvider = app.ApplicationServices;
            IConfiguration   configuration   = serviceProvider.GetService <IConfiguration>();
            bool             enabled         = configuration["OSharp:Hangfire:Enabled"].CastTo(false);

            if (!enabled)
            {
                return;
            }

            IGlobalConfiguration globalConfiguration = serviceProvider.GetService <IGlobalConfiguration>();

            globalConfiguration.UseLogProvider(new AspNetCoreLogProvider(serviceProvider.GetService <ILoggerFactory>()));

            BackgroundJobServerOptions serverOptions = GetBackgroundJobServerOptions(configuration);

            app.UseHangfireServer(serverOptions);

            string           url = configuration["OSharp:Hangfire:DashboardUrl"].CastTo("/hangfire");
            DashboardOptions dashboardOptions = GetDashboardOptions(configuration);

            app.UseHangfireDashboard(url, dashboardOptions);

            IHangfireJobRunner jobRunner = serviceProvider.GetService <IHangfireJobRunner>();

            jobRunner?.Start();

            IsEnabled = true;
        }
Exemple #2
0
        public static IGlobalConfiguration <LoupeLogProvider> UseLoupeLogProvider(
            [NotNull] this IGlobalConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            return(configuration.UseLogProvider(new LoupeLogProvider()));
        }
Exemple #3
0
        public static IGlobalConfiguration <SerilogLogProvider> UseSerilogLogProvider(
            [NotNull] this IGlobalConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            return(configuration.UseLogProvider(new SerilogLogProvider()));
        }
Exemple #4
0
        public static IGlobalConfiguration <Log4NetLogProvider> UseLog4NetLogProvider(
            this IGlobalConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            return(configuration.UseLogProvider(new Log4NetLogProvider()));
        }
Exemple #5
0
        public static IGlobalConfiguration <ElmahLogProvider> UseElmahLogProvider(
            [NotNull] this IGlobalConfiguration configuration,
            LogLevel minLevel)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            return(configuration.UseLogProvider(new ElmahLogProvider(minLevel)));
        }
Exemple #6
0
        public static IGlobalConfiguration <ColouredConsoleLogProvider> UseColouredConsoleLogProvider(
            [NotNull] this IGlobalConfiguration configuration,
            LogLevel minLevel)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            return(configuration.UseLogProvider(new ColouredConsoleLogProvider(minLevel)));
        }
Exemple #7
0
        public static IGlobalConfiguration <LykkeLogProvider> UseLykkeLogProvider(
            [NotNull] this IGlobalConfiguration configuration,
            [NotNull] IContainer container)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var logFactory  = container.Resolve <ILogFactory>();
            var logProvider = new LykkeLogProvider(logFactory);

            return(configuration.UseLogProvider(logProvider));
        }
Exemple #8
0
        /// <summary>
        /// Tries to set up Splunk logging configuration.
        /// </summary>
        /// <param name="configuration">Instance of <see cref="IGlobalConfiguration"/>.</param>
        public static IGlobalConfiguration UseSplunkLogProvider(this IGlobalConfiguration configuration)
        {
            var splunkConfig = TryGetSplungLogProviderSection();

            if (splunkConfig == null)
            {
                return(configuration);
            }

            if (!Uri.IsWellFormedUriString(splunkConfig.BaseUrl, UriKind.Absolute))
            {
                return(configuration);
            }

            return
                (string.IsNullOrWhiteSpace(splunkConfig.Token)
                    ? configuration
                    : configuration.UseLogProvider(new SplunkLogProvider(splunkConfig)));
        }