Exemple #1
0
        /// <summary>
        /// Register Cosmos Logging in NancyFX pipeline
        /// </summary>
        /// <param name="pipelines"></param>
        /// <param name="container"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static IPipelines RegisterCosmosLogging(this IPipelines pipelines, ILifetimeScope container, Action <ILogServiceCollection> config)
        {
            if (pipelines == null)
            {
                throw new ArgumentNullException(nameof(pipelines));
            }
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            var serviceImpl = new AutofacNancyLogServiceCollection();

            config?.Invoke(serviceImpl);

            RegisterCoreComponents(serviceImpl);

            UpdateAutofacContainer(container, serviceImpl);

            UpdateStaticProvider(container);

            NancyPipelinesHook.RegisterLoggingHandlers(pipelines);

            RegisterEnricherComponents(serviceImpl);

            return(pipelines);
        }
Exemple #2
0
 private static void UpdateAutofacContainer(ILifetimeScope container, AutofacNancyLogServiceCollection serviceImpl)
 {
     container.Update(builder => {
         builder.Populate(serviceImpl.ExposeServices());
         builder.RegisterType <NancyLoggingServiceProvider>().As <ILoggingServiceProvider>().SingleInstance();
         builder.RegisterInstance(Options.Create((LoggingOptions)serviceImpl.ExposeLogSettings()));
         builder.RegisterInstance(serviceImpl.ExposeLoggingConfiguration());
     });
 }
Exemple #3
0
 private static void RegisterEnricherComponents(AutofacNancyLogServiceCollection serviceImpl)
 {
     serviceImpl.ActiveLogEventEnrichers();
 }
Exemple #4
0
 private static void RegisterCoreComponents(AutofacNancyLogServiceCollection serviceImpl)
 {
     serviceImpl.BuildConfiguration();
     serviceImpl.ActiveSinkSettings();
     serviceImpl.ActiveOriginConfiguration();
 }