/// <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); }
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()); }); }
private static void RegisterEnricherComponents(AutofacNancyLogServiceCollection serviceImpl) { serviceImpl.ActiveLogEventEnrichers(); }
private static void RegisterCoreComponents(AutofacNancyLogServiceCollection serviceImpl) { serviceImpl.BuildConfiguration(); serviceImpl.ActiveSinkSettings(); serviceImpl.ActiveOriginConfiguration(); }