Exposes an ILogger property called Logger on all relevant base classes

This commit is contained in:
Shannon
2015-01-07 17:38:25 +11:00
parent 519b06fe30
commit 77e672aec1
9 changed files with 103 additions and 10 deletions

View File

@@ -4,6 +4,7 @@ using System.Web.Mvc;
using System.Web.Routing;
using System.Web.UI;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
using umbraco.BusinessLogic;
using umbraco.DataLayer;
@@ -15,13 +16,22 @@ namespace Umbraco.Web.UI.Controls
/// </summary>
public abstract class UmbracoControl : Control
{
/// <summary>
protected UmbracoControl(UmbracoContext umbracoContext)
: this(LoggerResolver.Current.Logger, umbracoContext)
{
}
/// <summary>
/// Default constructor
/// </summary>
/// <param name="logger"></param>
/// <param name="umbracoContext"></param>
protected UmbracoControl(UmbracoContext umbracoContext)
protected UmbracoControl(ILogger logger, UmbracoContext umbracoContext)
{
if (logger == null) throw new ArgumentNullException("logger");
if (umbracoContext == null) throw new ArgumentNullException("umbracoContext");
Logger = logger;
UmbracoContext = umbracoContext;
Umbraco = new UmbracoHelper(umbracoContext);
}
@@ -39,6 +49,7 @@ namespace Umbraco.Web.UI.Controls
/// </summary>
public UmbracoHelper Umbraco { get; private set; }
public ILogger Logger { get; private set; }
public UmbracoContext UmbracoContext { get; private set; }
protected ApplicationContext ApplicationContext

View File

@@ -4,6 +4,7 @@ using System.Web.Mvc;
using System.Web.Routing;
using System.Web.UI;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
using Umbraco.Web.Security;
using umbraco.DataLayer;
@@ -15,13 +16,21 @@ namespace Umbraco.Web.UI.Controls
/// </summary>
public abstract class UmbracoUserControl : UserControl
{
protected UmbracoUserControl(UmbracoContext umbracoContext)
: this(LoggerResolver.Current.Logger, umbracoContext)
{
}
/// <summary>
/// Default constructor
/// </summary>
/// <param name="logger"></param>
/// <param name="umbracoContext"></param>
protected UmbracoUserControl(UmbracoContext umbracoContext)
protected UmbracoUserControl(ILogger logger, UmbracoContext umbracoContext)
{
if (logger == null) throw new ArgumentNullException("logger");
if (umbracoContext == null) throw new ArgumentNullException("umbracoContext");
Logger = logger;
UmbracoContext = umbracoContext;
InstanceId = Guid.NewGuid();
Umbraco = new UmbracoHelper(umbracoContext);
@@ -64,6 +73,8 @@ namespace Umbraco.Web.UI.Controls
get { return UmbracoContext.Security; }
}
public ILogger Logger { get; private set; }
/// <summary>
/// Returns the current UmbracoContext
/// </summary>

View File

@@ -42,6 +42,12 @@ namespace Umbraco.Web.UI.Pages
// get { return global::umbraco.BusinessLogic.Application.SqlHelper; }
//}
private ILogger _logger;
public ILogger Logger
{
get { return _logger ?? (_logger = LoggerResolver.Current.Logger); }
}
private UrlHelper _url;
/// <summary>
/// Returns a UrlHelper