/// <summary> /// Adds Dolittle services /// </summary> /// <returns></returns> public static BootResult AddDolittle(this IServiceCollection services, ILoggerFactory loggerFactory = null) { ExecutionContextManager.SetInitialExecutionContext(); if (loggerFactory == null) { loggerFactory = new LoggerFactory(); } var logAppenders = Dolittle.Logging.Bootstrap.EntryPoint.Initialize(loggerFactory); var logger = new Logger(logAppenders); services.AddSingleton(typeof(Dolittle.Logging.ILogger), logger); var assemblies = Dolittle.Assemblies.Bootstrap.EntryPoint.Initialize(logger); var typeFinder = Dolittle.Types.Bootstrap.EntryPoint.Initialize(assemblies); Dolittle.Resources.Configuration.Bootstrap.EntryPoint.Initialize(typeFinder); var bindings = Dolittle.DependencyInversion.Bootstrap.Boot.Start(assemblies, typeFinder, logger, typeof(Container)); AddMvcOptions(services, typeFinder); return(new BootResult(assemblies, typeFinder, bindings)); }
/// <inheritdoc/> public void Perform(LoggingSettings settings, IBootStageBuilder builder) { var entryAssembly = builder.GetAssociation(WellKnownAssociations.EntryAssembly) as Assembly; var environment = builder.GetAssociation(WellKnownAssociations.Environment) as Environment; _initialExecutionContext = ExecutionContextManager.SetInitialExecutionContext(); #pragma warning disable CA2000 var loggerFactory = settings.LoggerFactory ?? new LoggerFactory(); #pragma warning restore CA2000 _isProduction = environment == Environment.Production; var logAppender = settings.LogAppender; if (logAppender == null) { logAppender = (_isProduction && !settings.UseDefaultInAllEnvironments) ? new JsonLogAppender(GetCurrentLoggingContext) : new DefaultLogAppender(GetCurrentLoggingContext, loggerFactory) as ILogAppender; } var logAppenders = Dolittle.Logging.Bootstrap.Boot.Start(logAppender, entryAssembly); Dolittle.Logging.ILogger logger = settings.Logger ?? new Logger(logAppenders); logger.Information($"<********* BOOTSTAGE : Logging *********>"); builder.Associate(WellKnownAssociations.Logger, logger); _executionContextManager = new ExecutionContextManager(logger); builder.Bindings.Bind <Dolittle.Logging.ILogger>().To(logger); builder.Bindings.Bind <ILoggerFactory>().To(loggerFactory); builder.Bindings.Bind <IExecutionContextManager>().To(_executionContextManager); }
/// <inheritdoc/> public void Perform(LoggingSettings settings, IBootStageBuilder builder) { var loggerManager = settings.DisableLogging ? NullLoggerManager.Instance : LoggerManager.Instance; if (settings.LogMessageWriterCreators != null) { loggerManager.AddLogMessageWriterCreators(settings.LogMessageWriterCreators.ToArray()); } builder.Associate(WellKnownAssociations.LoggerManager, loggerManager); builder.Bindings.Bind <ILoggerManager>().To(loggerManager); builder.Bindings.Bind(typeof(ILogger <>)).To(context => loggerManager.CreateLogger(context.Service.GetGenericArguments()[0])); builder.Bindings.Bind <ILogger>().To(() => loggerManager.CreateLogger <UnknownLogMessageSource>()); var logger = loggerManager.CreateLogger <Logging>(); logger.Debug("<********* BOOTSTAGE : Logging *********>"); var executionContextLogger = loggerManager.CreateLogger <ExecutionContextManager>(); ExecutionContextManager.SetInitialExecutionContext(executionContextLogger); builder.Bindings.Bind <IExecutionContextManager>().To(new ExecutionContextManager(executionContextLogger)); }
public Context(IProcessEngine engine, IDbSession dbSession) { this.executionContextManager = new ExecutionContextManager(this); this.engine = engine; this.DbSession = dbSession; }