Adds some more detailed logging.

This commit is contained in:
Shannon
2015-07-08 16:27:06 +02:00
parent 8cfb56adf4
commit ca738979ce
3 changed files with 74 additions and 14 deletions

View File

@@ -97,7 +97,18 @@ namespace Umbraco.Core
//now we need to call the initialize methods
ApplicationEventsResolver.Current.ApplicationEventHandlers
.ForEach(x => x.OnApplicationInitialized(UmbracoApplication, ApplicationContext));
.ForEach(x =>
{
try
{
x.OnApplicationInitialized(UmbracoApplication, ApplicationContext);
}
catch (Exception ex)
{
LogHelper.Error<CoreBootManager>("An error occurred running OnApplicationInitialized for handler " + x.GetType(), ex);
throw;
}
});
_isInitialized = true;
@@ -203,7 +214,18 @@ namespace Umbraco.Core
//call OnApplicationStarting of each application events handler
ApplicationEventsResolver.Current.ApplicationEventHandlers
.ForEach(x => x.OnApplicationStarting(UmbracoApplication, ApplicationContext));
.ForEach(x =>
{
try
{
x.OnApplicationStarting(UmbracoApplication, ApplicationContext);
}
catch (Exception ex)
{
LogHelper.Error<CoreBootManager>("An error occurred running OnApplicationStarting for handler " + x.GetType(), ex);
throw;
}
});
if (afterStartup != null)
{
@@ -229,7 +251,18 @@ namespace Umbraco.Core
//call OnApplicationStarting of each application events handler
ApplicationEventsResolver.Current.ApplicationEventHandlers
.ForEach(x => x.OnApplicationStarted(UmbracoApplication, ApplicationContext));
.ForEach(x =>
{
try
{
x.OnApplicationStarted(UmbracoApplication, ApplicationContext);
}
catch (Exception ex)
{
LogHelper.Error<CoreBootManager>("An error occurred running OnApplicationStarted for handler " + x.GetType(), ex);
throw;
}
});
//Now, startup all of our legacy startup handler
ApplicationEventsResolver.Current.InstantiateLegacyStartupHandlers();

View File

@@ -606,14 +606,10 @@ namespace Umbraco.Core
/// <returns></returns>
internal IEnumerable<T> CreateInstances<T>(IEnumerable<Type> types, bool throwException = false)
{
//Have removed logging because it doesn't really need to be logged since the time taken is generally 0ms.
//we want to know if it fails ever, not how long it took if it is only 0.
var typesAsArray = types.ToArray();
//using (DisposableTimer.DebugDuration<PluginManager>(
// String.Format("Starting instantiation of {0} objects of type {1}", typesAsArray.Length, typeof(T).FullName),
// String.Format("Completed instantiation of {0} objects of type {1}", typesAsArray.Length, typeof(T).FullName)))
//{
LogHelper.Debug<PluginManager>(string.Format("Instantiating {0} objects of type {1}", typesAsArray.Length, typeof (T).FullName));
var instances = new List<T>();
foreach (var t in typesAsArray)
{
@@ -634,7 +630,7 @@ namespace Umbraco.Core
}
}
return instances;
//}
}
/// <summary>

View File

@@ -73,7 +73,18 @@ namespace Umbraco.Core
protected virtual void OnApplicationStarting(object sender, EventArgs e)
{
if (ApplicationStarting != null)
ApplicationStarting(sender, e);
{
try
{
ApplicationStarting(sender, e);
}
catch (Exception ex)
{
LogHelper.Error<UmbracoApplicationBase>("An error occurred in an ApplicationStarting event handler", ex);
throw;
}
}
}
/// <summary>
@@ -84,7 +95,17 @@ namespace Umbraco.Core
protected virtual void OnApplicationStarted(object sender, EventArgs e)
{
if (ApplicationStarted != null)
ApplicationStarted(sender, e);
{
try
{
ApplicationStarted(sender, e);
}
catch (Exception ex)
{
LogHelper.Error<UmbracoApplicationBase>("An error occurred in an ApplicationStarted event handler", ex);
throw;
}
}
}
/// <summary>
@@ -95,7 +116,17 @@ namespace Umbraco.Core
private void OnApplicationInit(object sender, EventArgs e)
{
if (ApplicationInit != null)
ApplicationInit(sender, e);
{
try
{
ApplicationInit(sender, e);
}
catch (Exception ex)
{
LogHelper.Error<UmbracoApplicationBase>("An error occurred in an ApplicationInit event handler", ex);
throw;
}
}
}
/// <summary>