setting up more of the core in CoreRuntime, this time the logger and Umbraco Core
This commit is contained in:
@@ -12,6 +12,7 @@ using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Logging.Serilog;
|
||||
using Umbraco.Core.Migrations.Upgrade;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
@@ -42,6 +43,15 @@ namespace Umbraco.Core.Runtime
|
||||
/// <inheritdoc/>
|
||||
public virtual void Boot(ServiceContainer container)
|
||||
{
|
||||
container.ConfigureUmbracoCore(); // also sets Current.Container
|
||||
|
||||
// register the essential stuff,
|
||||
// ie the global application logger
|
||||
// (profiler etc depend on boot manager)
|
||||
var logger = GetLogger();
|
||||
container.RegisterInstance(logger);
|
||||
// now it is ok to use Current.Logger
|
||||
|
||||
Compose(container);
|
||||
|
||||
// prepare essential stuff
|
||||
@@ -107,6 +117,14 @@ namespace Umbraco.Core.Runtime
|
||||
//sa.Scope?.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a logger.
|
||||
/// </summary>
|
||||
protected virtual ILogger GetLogger()
|
||||
{
|
||||
return SerilogLogger.CreateWithDefaultConfiguration();
|
||||
}
|
||||
|
||||
private void AquireMainDom(IServiceFactory container)
|
||||
{
|
||||
using (var timer = ProfilingLogger.DebugDuration<CoreRuntime>("Acquiring MainDom.", "Aquired."))
|
||||
|
||||
@@ -64,14 +64,6 @@ namespace Umbraco.Tests.Runtimes
|
||||
return new TestRuntime(this);
|
||||
}
|
||||
|
||||
// the application's logger is created by the application
|
||||
// through GetLogger, that custom application can override
|
||||
protected override ILogger GetLogger()
|
||||
{
|
||||
//return Mock.Of<ILogger>();
|
||||
return new DebugDiagnosticsLogger();
|
||||
}
|
||||
|
||||
// don't register anything against AppDomain
|
||||
protected override void ConfigureUnhandledException(ILogger logger)
|
||||
{ }
|
||||
@@ -86,6 +78,14 @@ namespace Umbraco.Tests.Runtimes
|
||||
_umbracoApplication = umbracoApplication;
|
||||
}
|
||||
|
||||
// the application's logger is created by the application
|
||||
// through GetLogger, that custom application can override
|
||||
protected override ILogger GetLogger()
|
||||
{
|
||||
//return Mock.Of<ILogger>();
|
||||
return new DebugDiagnosticsLogger();
|
||||
}
|
||||
|
||||
public override void Compose(ServiceContainer container)
|
||||
{
|
||||
base.Compose(container);
|
||||
|
||||
@@ -23,14 +23,6 @@ namespace Umbraco.Web
|
||||
/// </summary>
|
||||
protected abstract IRuntime GetRuntime();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a logger.
|
||||
/// </summary>
|
||||
protected virtual ILogger GetLogger()
|
||||
{
|
||||
return SerilogLogger.CreateWithDefaultConfiguration();
|
||||
}
|
||||
|
||||
// events - in the order they trigger
|
||||
|
||||
// were part of the BootManager architecture, would trigger only for the initial
|
||||
@@ -62,21 +54,15 @@ namespace Umbraco.Web
|
||||
// create the container for the application, and configure.
|
||||
// the boot manager is responsible for registrations
|
||||
var container = new ServiceContainer();
|
||||
container.ConfigureUmbracoCore(); // also sets Current.Container
|
||||
|
||||
// register the essential stuff,
|
||||
// ie the global application logger
|
||||
// (profiler etc depend on boot manager)
|
||||
var logger = GetLogger();
|
||||
container.RegisterInstance(logger);
|
||||
// now it is ok to use Current.Logger
|
||||
|
||||
ConfigureUnhandledException(logger);
|
||||
ConfigureAssemblyResolve(logger);
|
||||
|
||||
// get runtime & boot
|
||||
_runtime = GetRuntime();
|
||||
_runtime.Boot(container);
|
||||
|
||||
var logger = container.GetInstance<ILogger>();
|
||||
|
||||
ConfigureUnhandledException(logger);
|
||||
ConfigureAssemblyResolve(logger);
|
||||
}
|
||||
|
||||
protected virtual void ConfigureUnhandledException(ILogger logger)
|
||||
|
||||
Reference in New Issue
Block a user