diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs
index 2291aae917..0aceac24bf 100644
--- a/src/Umbraco.Core/ApplicationContext.cs
+++ b/src/Umbraco.Core/ApplicationContext.cs
@@ -8,6 +8,7 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Logging;
using Umbraco.Core.ObjectResolution;
+using Umbraco.Core.Profiling;
using Umbraco.Core.Services;
@@ -28,7 +29,7 @@ namespace Umbraco.Core
///
///
///
- public ApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext, CacheHelper cache, ILogger logger)
+ public ApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext, CacheHelper cache, ProfilingLogger logger)
{
if (dbContext == null) throw new ArgumentNullException("dbContext");
if (serviceContext == null) throw new ArgumentNullException("serviceContext");
@@ -36,7 +37,7 @@ namespace Umbraco.Core
_databaseContext = dbContext;
_services = serviceContext;
ApplicationCache = cache;
- Logger = logger;
+ ProfilingLogger = logger;
}
///
@@ -47,7 +48,8 @@ namespace Umbraco.Core
///
[Obsolete("Use the other constructor specifying an ILogger instead")]
public ApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext, CacheHelper cache)
- : this(dbContext, serviceContext, cache, LoggerResolver.Current.Logger)
+ : this(dbContext, serviceContext, cache,
+ new ProfilingLogger(LoggerResolver.Current.Logger, ProfilerResolver.Current.Profiler))
{
}
@@ -96,7 +98,7 @@ namespace Umbraco.Core
///
/// This is NOT thread safe
///
- [Obsolete("Use the other method specifying an ILogger instead")]
+ [Obsolete("Use the other method specifying an ProfilingLogger instead")]
public static ApplicationContext EnsureContext(DatabaseContext dbContext, ServiceContext serviceContext, CacheHelper cache, bool replaceContext)
{
if (ApplicationContext.Current != null)
@@ -124,7 +126,7 @@ namespace Umbraco.Core
///
/// This is NOT thread safe
///
- public static ApplicationContext EnsureContext(DatabaseContext dbContext, ServiceContext serviceContext, CacheHelper cache, ILogger logger, bool replaceContext)
+ public static ApplicationContext EnsureContext(DatabaseContext dbContext, ServiceContext serviceContext, CacheHelper cache, ProfilingLogger logger, bool replaceContext)
{
if (ApplicationContext.Current != null)
{
@@ -150,10 +152,10 @@ namespace Umbraco.Core
public CacheHelper ApplicationCache { get; private set; }
///
- /// Exposes the global ILogger - this should generally not be accessed via the UmbracoContext and should normally just be exposed
+ /// Exposes the global ProfilingLogger - this should generally not be accessed via the UmbracoContext and should normally just be exposed
/// on most base classes or injected with IoC
///
- public ILogger Logger { get; private set; }
+ public ProfilingLogger ProfilingLogger { get; private set; }
// IsReady is set to true by the boot manager once it has successfully booted
// note - the original umbraco module checks on content.Instance in umbraco.dll
@@ -227,7 +229,7 @@ namespace Umbraco.Core
if (currentVersion != configStatus)
{
- Logger.Info("CurrentVersion different from configStatus: '" + currentVersion + "','" + configStatus + "'");
+ ProfilingLogger.Logger.Info("CurrentVersion different from configStatus: '" + currentVersion + "','" + configStatus + "'");
}
diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs
index f7e2551687..70f3d3e5eb 100644
--- a/src/Umbraco.Core/CoreBootManager.cs
+++ b/src/Umbraco.Core/CoreBootManager.cs
@@ -36,7 +36,7 @@ namespace Umbraco.Core
///
public class CoreBootManager : IBootManager
{
-
+ private ProfilingLogger _profilingLogger;
private DisposableTimer _timer;
private bool _isInitialized = false;
private bool _isStarted = false;
@@ -64,7 +64,9 @@ namespace Umbraco.Core
InitializeLoggerResolver();
InitializeProfilerResolver();
- _timer = DisposableTimer.DebugDuration("Umbraco application starting", "Umbraco application startup complete");
+ _profilingLogger = new ProfilingLogger(LoggerResolver.Current.Logger, ProfilerResolver.Current.Profiler);
+
+ _timer = _profilingLogger.DebugDuration("Umbraco application starting", "Umbraco application startup complete");
CreateApplicationCache();
@@ -119,7 +121,7 @@ namespace Umbraco.Core
protected virtual void CreateApplicationContext(DatabaseContext dbContext, ServiceContext serviceContext)
{
//create the ApplicationContext
- ApplicationContext = ApplicationContext.Current = new ApplicationContext(dbContext, serviceContext, ApplicationCache, LoggerResolver.Current.Logger);
+ ApplicationContext = ApplicationContext.Current = new ApplicationContext(dbContext, serviceContext, ApplicationCache, _profilingLogger);
}
///
diff --git a/src/Umbraco.Core/DisposableTimer.cs b/src/Umbraco.Core/DisposableTimer.cs
index fc7d531f22..816256360a 100644
--- a/src/Umbraco.Core/DisposableTimer.cs
+++ b/src/Umbraco.Core/DisposableTimer.cs
@@ -62,7 +62,7 @@ namespace Umbraco.Core
}
}
- protected DisposableTimer(Action callback)
+ protected internal DisposableTimer(Action callback)
{
if (callback == null) throw new ArgumentNullException("callback");
_callback = callback;
diff --git a/src/Umbraco.Core/PluginManager.cs b/src/Umbraco.Core/PluginManager.cs
index d03edc0fc6..12484889d5 100644
--- a/src/Umbraco.Core/PluginManager.cs
+++ b/src/Umbraco.Core/PluginManager.cs
@@ -196,7 +196,7 @@ namespace Umbraco.Core
//add the trees.config - use the contents to create the has since this gets resaved on every app startup!
new Tuple(new FileInfo(IOHelper.MapPath(SystemDirectories.Config + "/trees.config")), true)
- }
+ }, _appContext.ProfilingLogger
);
return _currentAssembliesHash;
}
@@ -219,9 +219,9 @@ namespace Umbraco.Core
/// (true will make a hash based on it's contents)
///
///
- internal static long GetFileHash(IEnumerable> filesAndFolders)
+ internal static long GetFileHash(IEnumerable> filesAndFolders, ProfilingLogger logger)
{
- using (DisposableTimer.TraceDuration("Determining hash of code files on disk", "Hash determined"))
+ using (logger.TraceDuration("Determining hash of code files on disk", "Hash determined"))
{
var hashCombiner = new HashCodeCombiner();
@@ -250,9 +250,9 @@ namespace Umbraco.Core
}
}
- internal static long GetFileHash(IEnumerable filesAndFolders)
+ internal static long GetFileHash(IEnumerable filesAndFolders, ProfilingLogger logger)
{
- using (DisposableTimer.TraceDuration("Determining hash of code files on disk", "Hash determined"))
+ using (logger.TraceDuration("Determining hash of code files on disk", "Hash determined"))
{
var hashCombiner = new HashCodeCombiner();
@@ -610,7 +610,7 @@ namespace Umbraco.Core
//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(
+ //using (_appContext.ProfilingLogger.DebugDuration(
// 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)))
//{
@@ -625,7 +625,7 @@ namespace Umbraco.Core
catch (Exception ex)
{
- LogHelper.Error(String.Format("Error creating type {0}", t.FullName), ex);
+ _appContext.ProfilingLogger.Logger.Error(String.Format("Error creating type {0}", t.FullName), ex);
if (throwException)
{
@@ -659,9 +659,9 @@ namespace Umbraco.Core
{
var typesFound = new List();
- using (DisposableTimer.TraceDuration(
- () => String.Format("Starting resolution types of {0}", typeof(T).FullName),
- () => String.Format("Completed resolution of types of {0}, found {1}", typeof(T).FullName, typesFound.Count)))
+ using (_appContext.ProfilingLogger.TraceDuration(
+ String.Format("Starting resolution types of {0}", typeof(T).FullName),
+ String.Format("Completed resolution of types of {0}, found {1}", typeof(T).FullName, typesFound.Count)))
{
//check if the TypeList already exists, if so return it, if not we'll create it
var typeList = _types.SingleOrDefault(x => x.IsTypeList(resolutionType));
@@ -669,7 +669,7 @@ namespace Umbraco.Core
//need to put some logging here to try to figure out why this is happening: http://issues.umbraco.org/issue/U4-3505
if (cacheResult && typeList != null)
{
- LogHelper.Debug("Existing typeList found for {0} with resolution type {1}", () => typeof(T), () => resolutionType);
+ _appContext.ProfilingLogger.Logger.Debug("Existing typeList found for {0} with resolution type {1}", () => typeof(T), () => resolutionType);
}
//if we're not caching the result then proceed, or if the type list doesn't exist then proceed
@@ -691,7 +691,7 @@ namespace Umbraco.Core
//so in this instance there will never be a result.
if (fileCacheResult.Exception != null && fileCacheResult.Exception is CachedPluginNotFoundInFileException)
{
- LogHelper.Debug("Tried to find typelist for type {0} and resolution {1} in file cache but the type was not found so loading types by assembly scan ", () => typeof(T), () => resolutionType);
+ _appContext.ProfilingLogger.Logger.Debug("Tried to find typelist for type {0} and resolution {1} in file cache but the type was not found so loading types by assembly scan ", () => typeof(T), () => resolutionType);
//we don't have a cache for this so proceed to look them up by scanning
LoadViaScanningAndUpdateCacheFile(typeList, resolutionType, finder);
@@ -716,7 +716,7 @@ namespace Umbraco.Core
//if there are any exceptions loading types, we have to exist, this should never happen so
//we will need to revert to scanning for types.
successfullyLoadedFromCache = false;
- LogHelper.Error("Could not load a cached plugin type: " + t + " now reverting to re-scanning assemblies for the base type: " + typeof(T).FullName, ex);
+ _appContext.ProfilingLogger.Logger.Error("Could not load a cached plugin type: " + t + " now reverting to re-scanning assemblies for the base type: " + typeof(T).FullName, ex);
break;
}
}
@@ -727,14 +727,14 @@ namespace Umbraco.Core
}
else
{
- LogHelper.Debug("Loaded plugin types {0} with resolution {1} from persisted cache", () => typeof(T), () => resolutionType);
+ _appContext.ProfilingLogger.Logger.Debug("Loaded plugin types {0} with resolution {1} from persisted cache", () => typeof(T), () => resolutionType);
}
}
}
}
else
{
- LogHelper.Debug("Assembly changes detected, loading types {0} for resolution {1} by assembly scan", () => typeof(T), () => resolutionType);
+ _appContext.ProfilingLogger.Logger.Debug("Assembly changes detected, loading types {0} for resolution {1} by assembly scan", () => typeof(T), () => resolutionType);
//we don't have a cache for this so proceed to look them up by scanning
LoadViaScanningAndUpdateCacheFile(typeList, resolutionType, finder);
@@ -746,7 +746,7 @@ namespace Umbraco.Core
//add the type list to the collection
var added = _types.Add(typeList);
- LogHelper.Debug("Caching of typelist for type {0} and resolution {1} was successful = {2}", () => typeof(T), () => resolutionType, () => added);
+ _appContext.ProfilingLogger.Logger.Debug("Caching of typelist for type {0} and resolution {1} was successful = {2}", () => typeof(T), () => resolutionType, () => added);
}
}
diff --git a/src/Umbraco.Core/Profiling/LogProfiler.cs b/src/Umbraco.Core/Profiling/LogProfiler.cs
index 5936e4cbd1..117d177650 100644
--- a/src/Umbraco.Core/Profiling/LogProfiler.cs
+++ b/src/Umbraco.Core/Profiling/LogProfiler.cs
@@ -7,7 +7,7 @@ using Umbraco.Core.Logging;
namespace Umbraco.Core.Profiling
{
///
- /// A profiler that outputs its results to the LogHelper
+ /// A profiler that outputs its results to an ILogger
///
internal class LogProfiler : IProfiler
{
@@ -26,7 +26,7 @@ namespace Umbraco.Core.Profiling
public IDisposable Step(string name)
{
_logger.Debug(typeof(LogProfiler), "Starting - " + name);
- return DisposableTimer.Start(l => _logger.Info(typeof(LogProfiler), () => name + " (took " + l + "ms)"));
+ return new DisposableTimer(l => _logger.Info(typeof(LogProfiler), () => name + " (took " + l + "ms)"));
}
public void Start()
diff --git a/src/Umbraco.Tests/MockTests.cs b/src/Umbraco.Tests/MockTests.cs
index 4214bbcdb4..f6e99c9e38 100644
--- a/src/Umbraco.Tests/MockTests.cs
+++ b/src/Umbraco.Tests/MockTests.cs
@@ -10,6 +10,7 @@ using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Persistence.UnitOfWork;
+using Umbraco.Core.Profiling;
using Umbraco.Core.Services;
using Moq;
using Umbraco.Web;
@@ -112,7 +113,7 @@ namespace Umbraco.Tests
new Mock().Object,
Mock.Of()),
CacheHelper.CreateDisabledCacheHelper(),
- Mock.Of());
+ new ProfilingLogger(Mock.Of(), Mock.Of()));
Assert.Pass();
}
diff --git a/src/Umbraco.Tests/Persistence/BaseTableByTableTest.cs b/src/Umbraco.Tests/Persistence/BaseTableByTableTest.cs
index f239ccb80e..8fd0c8230a 100644
--- a/src/Umbraco.Tests/Persistence/BaseTableByTableTest.cs
+++ b/src/Umbraco.Tests/Persistence/BaseTableByTableTest.cs
@@ -12,6 +12,7 @@ using Umbraco.Core.ObjectResolution;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Persistence.UnitOfWork;
+using Umbraco.Core.Profiling;
using Umbraco.Core.Publishing;
using Umbraco.Core.Services;
using Umbraco.Tests.TestHelpers;
@@ -60,7 +61,7 @@ namespace Umbraco.Tests.Persistence
//assign the service context
new ServiceContext(repositoryFactory, new PetaPocoUnitOfWorkProvider(_logger), new FileUnitOfWorkProvider(), new PublishingStrategy(), cacheHelper, _logger),
cacheHelper,
- new Logger(new FileInfo(TestHelper.MapPathForTest("~/unit-test-log4net.config"))))
+ new ProfilingLogger(new Logger(new FileInfo(TestHelper.MapPathForTest("~/unit-test-log4net.config"))), Mock.Of()))
{
IsReady = true
};
diff --git a/src/Umbraco.Tests/Plugins/PluginManagerTests.cs b/src/Umbraco.Tests/Plugins/PluginManagerTests.cs
index 505ddbec06..342e337a57 100644
--- a/src/Umbraco.Tests/Plugins/PluginManagerTests.cs
+++ b/src/Umbraco.Tests/Plugins/PluginManagerTests.cs
@@ -4,6 +4,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
+using Moq;
using NUnit.Framework;
using SqlCE4Umbraco;
using umbraco;
@@ -11,6 +12,8 @@ using umbraco.businesslogic;
using umbraco.cms.businesslogic;
using Umbraco.Core;
using Umbraco.Core.IO;
+using Umbraco.Core.Logging;
+using Umbraco.Core.Profiling;
using Umbraco.Core.PropertyEditors;
using umbraco.DataLayer;
using umbraco.editorControls;
@@ -236,18 +239,18 @@ namespace Umbraco.Tests.Plugins
var list1 = new[] { f1, f2, f3, f4, f5, f6 };
var list2 = new[] { f1, f3, f5 };
var list3 = new[] { f1, f3, f5, f7 };
-
+
//Act
- var hash1 = PluginManager.GetFileHash(list1);
- var hash2 = PluginManager.GetFileHash(list2);
- var hash3 = PluginManager.GetFileHash(list3);
+ var hash1 = PluginManager.GetFileHash(list1, new ProfilingLogger(Mock.Of(), Mock.Of()));
+ var hash2 = PluginManager.GetFileHash(list2, new ProfilingLogger(Mock.Of(), Mock.Of()));
+ var hash3 = PluginManager.GetFileHash(list3, new ProfilingLogger(Mock.Of(), Mock.Of()));
//Assert
Assert.AreNotEqual(hash1, hash2);
Assert.AreNotEqual(hash1, hash3);
Assert.AreNotEqual(hash2, hash3);
- Assert.AreEqual(hash1, PluginManager.GetFileHash(list1));
+ Assert.AreEqual(hash1, PluginManager.GetFileHash(list1, new ProfilingLogger(Mock.Of(), Mock.Of())));
}
[Test]
diff --git a/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs b/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs
index 548b412d5b..283fbcfdce 100644
--- a/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs
+++ b/src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs
@@ -81,7 +81,7 @@ namespace Umbraco.Tests.TestHelpers
//assign the service context
new ServiceContext(repositoryFactory, new PetaPocoUnitOfWorkProvider(dbFactory), new FileUnitOfWorkProvider(), new PublishingStrategy(), cacheHelper, Logger),
cacheHelper,
- Logger)
+ ProfilingLogger)
{
IsReady = true
};
diff --git a/src/Umbraco.Tests/TestHelpers/BaseDatabaseTest.cs b/src/Umbraco.Tests/TestHelpers/BaseDatabaseTest.cs
index ba64d8e8a0..eedd100a0d 100644
--- a/src/Umbraco.Tests/TestHelpers/BaseDatabaseTest.cs
+++ b/src/Umbraco.Tests/TestHelpers/BaseDatabaseTest.cs
@@ -13,6 +13,7 @@ using Umbraco.Core.ObjectResolution;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Persistence.UnitOfWork;
+using Umbraco.Core.Profiling;
using Umbraco.Core.Publishing;
using Umbraco.Core.Services;
using GlobalSettings = Umbraco.Core.Configuration.GlobalSettings;
@@ -73,7 +74,7 @@ namespace Umbraco.Tests.TestHelpers
//assign the service context
new ServiceContext(repositoryFactory, new PetaPocoUnitOfWorkProvider(dbFactory), new FileUnitOfWorkProvider(), new PublishingStrategy(), cacheHelper, logger),
cacheHelper,
- logger)
+ new ProfilingLogger(logger, Mock.Of()))
{
IsReady = true
};
diff --git a/src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs b/src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs
index fda4f37542..b1bb7b6a77 100644
--- a/src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs
+++ b/src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs
@@ -11,6 +11,7 @@ using Umbraco.Core.ObjectResolution;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Persistence.UnitOfWork;
+using Umbraco.Core.Profiling;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Publishing;
using Umbraco.Core.Services;
@@ -32,7 +33,8 @@ namespace Umbraco.Tests.TestHelpers
[TestFixtureSetUp]
public void InitializeFixture()
{
- Logger = new Logger(new FileInfo(TestHelper.MapPathForTest("~/unit-test-log4net.config")));
+ var logger = new Logger(new FileInfo(TestHelper.MapPathForTest("~/unit-test-log4net.config")));
+ ProfilingLogger = new ProfilingLogger(logger, new LogProfiler(logger));
}
[SetUp]
@@ -158,7 +160,7 @@ namespace Umbraco.Tests.TestHelpers
//assign the service context
new ServiceContext(repoFactory, new PetaPocoUnitOfWorkProvider(Logger), new FileUnitOfWorkProvider(), new PublishingStrategy(), cacheHelper, Logger),
cacheHelper,
- Logger)
+ ProfilingLogger)
{
IsReady = true
};
@@ -201,6 +203,10 @@ namespace Umbraco.Tests.TestHelpers
get { return ApplicationContext.Current; }
}
- protected ILogger Logger { get; private set; }
+ protected ILogger Logger
+ {
+ get { return ProfilingLogger.Logger; }
+ }
+ protected ProfilingLogger ProfilingLogger { get; private set; }
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Web/Editors/PackageInstallController.cs b/src/Umbraco.Web/Editors/PackageInstallController.cs
index dbd775ed12..0b1c1a56dd 100644
--- a/src/Umbraco.Web/Editors/PackageInstallController.cs
+++ b/src/Umbraco.Web/Editors/PackageInstallController.cs
@@ -87,7 +87,7 @@ namespace Umbraco.Web.Editors
ins.LoadConfig(IOHelper.MapPath(model.TemporaryDirectoryPath));
ins.InstallCleanUp(model.Id, IOHelper.MapPath(model.TemporaryDirectoryPath));
- var clientDependencyConfig = new Umbraco.Core.Configuration.ClientDependencyConfiguration(ApplicationContext.Logger);
+ var clientDependencyConfig = new Umbraco.Core.Configuration.ClientDependencyConfiguration(ApplicationContext.ProfilingLogger.Logger);
var clientDependencyUpdated = clientDependencyConfig.IncreaseVersionNumber();
//clear the tree cache - we'll do this here even though the browser will reload, but just in case it doesn't can't hurt.
diff --git a/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs b/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs
index 9acd66c2da..e4f18fdcab 100644
--- a/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs
+++ b/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs
@@ -37,7 +37,7 @@ namespace Umbraco.Web.Install.InstallSteps
GlobalSettings.ConfigurationStatus = UmbracoVersion.Current.ToString(3);
// Update ClientDependency version
- var clientDependencyConfig = new ClientDependencyConfiguration(_applicationContext.Logger);
+ var clientDependencyConfig = new ClientDependencyConfiguration(_applicationContext.ProfilingLogger.Logger);
var clientDependencyUpdated = clientDependencyConfig.IncreaseVersionNumber();
var security = new WebSecurity(_httpContext, _applicationContext);