diff --git a/src/Umbraco.Web/Mvc/PluginController.cs b/src/Umbraco.Web/Mvc/PluginController.cs index 1814da09b2..d4aae1e08c 100644 --- a/src/Umbraco.Web/Mvc/PluginController.cs +++ b/src/Umbraco.Web/Mvc/PluginController.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Concurrent; using System.Web.Mvc; using Umbraco.Core; +using Umbraco.Core.Logging; using Umbraco.Core.Services; using Umbraco.Web.WebApi; @@ -18,16 +19,23 @@ namespace Umbraco.Web.Mvc private static readonly ConcurrentDictionary MetadataStorage = new ConcurrentDictionary(); + protected PluginController(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); + } + /// /// Default constructor /// /// protected PluginController(UmbracoContext umbracoContext) + : this(LoggerResolver.Current.Logger, umbracoContext) { - if (umbracoContext == null) throw new ArgumentNullException("umbracoContext"); - UmbracoContext = umbracoContext; - InstanceId = Guid.NewGuid(); - Umbraco = new UmbracoHelper(umbracoContext); } /// @@ -40,7 +48,12 @@ namespace Umbraco.Web.Mvc /// public UmbracoHelper Umbraco { get; private set; } - /// + /// + /// Returns an ILogger + /// + public ILogger Logger { get; private set; } + + /// /// Returns the current UmbracoContext /// public UmbracoContext UmbracoContext { get; private set; } diff --git a/src/Umbraco.Web/Mvc/RenderMvcController.cs b/src/Umbraco.Web/Mvc/RenderMvcController.cs index 86bccbe224..1debe0c4a5 100644 --- a/src/Umbraco.Web/Mvc/RenderMvcController.cs +++ b/src/Umbraco.Web/Mvc/RenderMvcController.cs @@ -24,6 +24,12 @@ namespace Umbraco.Web.Mvc ActionInvoker = new RenderActionInvoker(); } + public RenderMvcController(ILogger logger, UmbracoContext umbracoContext) + : base(logger, umbracoContext) + { + + } + public RenderMvcController(UmbracoContext umbracoContext) : base(umbracoContext) { diff --git a/src/Umbraco.Web/Mvc/UmbracoController.cs b/src/Umbraco.Web/Mvc/UmbracoController.cs index d514b56aa6..c1dabe4477 100644 --- a/src/Umbraco.Web/Mvc/UmbracoController.cs +++ b/src/Umbraco.Web/Mvc/UmbracoController.cs @@ -1,6 +1,7 @@ using System; using System.Web.Mvc; using Umbraco.Core; +using Umbraco.Core.Logging; using Umbraco.Core.Services; using Umbraco.Web.Security; @@ -11,12 +12,19 @@ namespace Umbraco.Web.Mvc /// public abstract class UmbracoController : Controller { - protected UmbracoController(UmbracoContext umbracoContext) + protected UmbracoController(ILogger logger, UmbracoContext umbracoContext) { + if (logger == null) throw new ArgumentNullException("logger"); if (umbracoContext == null) throw new ArgumentNullException("umbracoContext"); + Logger = logger; UmbracoContext = umbracoContext; } + protected UmbracoController(UmbracoContext umbracoContext) + : this(LoggerResolver.Current.Logger, umbracoContext) + { + } + protected UmbracoController() : this(UmbracoContext.Current) { @@ -24,6 +32,7 @@ namespace Umbraco.Web.Mvc } private UmbracoHelper _umbraco; + /// /// Returns an UmbracoHelper object /// @@ -32,6 +41,11 @@ namespace Umbraco.Web.Mvc get { return _umbraco ?? (_umbraco = new UmbracoHelper(UmbracoContext)); } } + /// + /// Returns an ILogger + /// + public ILogger Logger { get; private set; } + /// /// Returns the current UmbracoContext /// diff --git a/src/Umbraco.Web/UI/Controls/UmbracoControl.cs b/src/Umbraco.Web/UI/Controls/UmbracoControl.cs index 66f896312e..eb1546525a 100644 --- a/src/Umbraco.Web/UI/Controls/UmbracoControl.cs +++ b/src/Umbraco.Web/UI/Controls/UmbracoControl.cs @@ -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 /// public abstract class UmbracoControl : Control { - /// + + protected UmbracoControl(UmbracoContext umbracoContext) + : this(LoggerResolver.Current.Logger, umbracoContext) + { + } + + /// /// Default constructor /// + /// /// - 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 /// public UmbracoHelper Umbraco { get; private set; } + public ILogger Logger { get; private set; } public UmbracoContext UmbracoContext { get; private set; } protected ApplicationContext ApplicationContext diff --git a/src/Umbraco.Web/UI/Controls/UmbracoUserControl.cs b/src/Umbraco.Web/UI/Controls/UmbracoUserControl.cs index 4910dcb2d4..d6cb44338b 100644 --- a/src/Umbraco.Web/UI/Controls/UmbracoUserControl.cs +++ b/src/Umbraco.Web/UI/Controls/UmbracoUserControl.cs @@ -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 /// public abstract class UmbracoUserControl : UserControl { + protected UmbracoUserControl(UmbracoContext umbracoContext) + : this(LoggerResolver.Current.Logger, umbracoContext) + { + } + /// /// Default constructor /// + /// /// - 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; } + /// /// Returns the current UmbracoContext /// diff --git a/src/Umbraco.Web/UI/Pages/BasePage.cs b/src/Umbraco.Web/UI/Pages/BasePage.cs index 4fa198f8b6..0119cd7fdb 100644 --- a/src/Umbraco.Web/UI/Pages/BasePage.cs +++ b/src/Umbraco.Web/UI/Pages/BasePage.cs @@ -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; /// /// Returns a UrlHelper diff --git a/src/Umbraco.Web/WebApi/UmbracoApiController.cs b/src/Umbraco.Web/WebApi/UmbracoApiController.cs index 572e9e5af3..05e390816d 100644 --- a/src/Umbraco.Web/WebApi/UmbracoApiController.cs +++ b/src/Umbraco.Web/WebApi/UmbracoApiController.cs @@ -5,6 +5,7 @@ using System.Web; using System.Web.Http; using System.Web.Http.ModelBinding; using Umbraco.Core; +using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Validation; using Umbraco.Core.Services; @@ -21,15 +22,23 @@ namespace Umbraco.Web.WebApi } - protected UmbracoApiController(UmbracoContext umbracoContext) + protected UmbracoApiController(ILogger logger, UmbracoContext umbracoContext) { + if (logger == null) throw new ArgumentNullException("logger"); if (umbracoContext == null) throw new ArgumentNullException("umbracoContext"); UmbracoContext = umbracoContext; InstanceId = Guid.NewGuid(); Umbraco = new UmbracoHelper(umbracoContext); + Logger = logger; _membershipHelper = new MembershipHelper(UmbracoContext); } + protected UmbracoApiController(UmbracoContext umbracoContext) + : this(LoggerResolver.Current.Logger, umbracoContext) + { + + } + private readonly MembershipHelper _membershipHelper; /// @@ -41,6 +50,8 @@ namespace Umbraco.Web.WebApi return Request.TryGetHttpContext(); } + public ILogger Logger { get; private set; } + /// /// Returns the current ApplicationContext /// diff --git a/src/Umbraco.Web/WebServices/UmbracoHttpHandler.cs b/src/Umbraco.Web/WebServices/UmbracoHttpHandler.cs index b7c8344788..964606dbd9 100644 --- a/src/Umbraco.Web/WebServices/UmbracoHttpHandler.cs +++ b/src/Umbraco.Web/WebServices/UmbracoHttpHandler.cs @@ -3,6 +3,7 @@ using System.Web; using System.Web.Mvc; using System.Web.Routing; using Umbraco.Core; +using Umbraco.Core.Logging; using Umbraco.Core.Services; using Umbraco.Web.Security; @@ -20,8 +21,16 @@ namespace Umbraco.Web.WebServices } protected UmbracoHttpHandler(UmbracoContext umbracoContext) + : this(LoggerResolver.Current.Logger, umbracoContext) { + } + + + protected UmbracoHttpHandler(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); } @@ -34,6 +43,8 @@ namespace Umbraco.Web.WebServices get { return UmbracoContext.Application; } } + public ILogger Logger { get; private set; } + /// /// Returns the current UmbracoContext /// diff --git a/src/Umbraco.Web/WebServices/UmbracoWebService.cs b/src/Umbraco.Web/WebServices/UmbracoWebService.cs index 5f7dc7da5d..42743f6911 100644 --- a/src/Umbraco.Web/WebServices/UmbracoWebService.cs +++ b/src/Umbraco.Web/WebServices/UmbracoWebService.cs @@ -4,6 +4,7 @@ using System.Web.Mvc; using System.Web.Routing; using System.Web.Services; using Umbraco.Core; +using Umbraco.Core.Logging; using Umbraco.Core.Services; using Umbraco.Web.Security; @@ -21,8 +22,15 @@ namespace Umbraco.Web.WebServices } protected UmbracoWebService(UmbracoContext umbracoContext) + : this(LoggerResolver.Current.Logger, umbracoContext) { + } + + protected UmbracoWebService(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); } @@ -35,6 +43,8 @@ namespace Umbraco.Web.WebServices get { return UmbracoContext.Application; } } + public ILogger Logger { get; private set; } + /// /// Returns the current UmbracoContext ///