From a1059de8bb1917e86b9153bdfcafed57e354b9e4 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 4 Dec 2010 14:09:15 -0800 Subject: [PATCH] Adding logging in a couple of components --HG-- branch : dev --- src/Orchard/Data/Migration/DataMigrationManager.cs | 3 ++- .../Environment/State/ShellStateCoordinator.cs | 11 +++++++++++ src/Orchard/Localization/LocalizationModule.cs | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Orchard/Data/Migration/DataMigrationManager.cs b/src/Orchard/Data/Migration/DataMigrationManager.cs index b416e1bf3..8b9bbc410 100644 --- a/src/Orchard/Data/Migration/DataMigrationManager.cs +++ b/src/Orchard/Data/Migration/DataMigrationManager.cs @@ -59,7 +59,6 @@ namespace Orchard.Data.Migration { } public void Update(string feature){ - Logger.Information("Updating feature: {0}", feature); // proceed with dependent features first, whatever the module it's in @@ -125,6 +124,8 @@ namespace Orchard.Data.Migration { } public void Uninstall(string feature) { + Logger.Information("Uninstalling feature: {0}", feature); + var migrations = GetDataMigrations(feature); // apply update methods to each migration class for the module diff --git a/src/Orchard/Environment/State/ShellStateCoordinator.cs b/src/Orchard/Environment/State/ShellStateCoordinator.cs index adc4a2f31..5f9d36972 100644 --- a/src/Orchard/Environment/State/ShellStateCoordinator.cs +++ b/src/Orchard/Environment/State/ShellStateCoordinator.cs @@ -7,6 +7,7 @@ using Orchard.Environment.Extensions.Models; using Orchard.Environment.State.Models; using Orchard.Environment.Descriptor; using Orchard.Environment.Descriptor.Models; +using Orchard.Logging; namespace Orchard.Environment.State { public class ShellStateCoordinator : IShellStateManagerEventHandler, IShellDescriptorManagerEventHandler { @@ -27,8 +28,11 @@ namespace Orchard.Environment.State { _extensionManager = extensionManager; _processingEngine = processingEngine; _featureEvents = featureEvents; + Logger = NullLogger.Instance; } + public ILogger Logger { get; set; } + void IShellDescriptorManagerEventHandler.Changed(ShellDescriptor descriptor) { // deduce and apply state changes involved var shellState = _stateManager.GetShellState(); @@ -73,6 +77,7 @@ namespace Orchard.Environment.State { .ToArray() }; + Logger.Information("Adding pending task 'ApplyChanges' for shell '{0}'", _settings.Name); _processingEngine.AddTask( _settings, descriptor, @@ -98,6 +103,8 @@ namespace Orchard.Environment.State { } void IShellStateManagerEventHandler.ApplyChanges() { + Logger.Information("Applying changes for for shell '{0}'", _settings.Name); + var shellState = _stateManager.GetShellState(); // start with description of all declared features in order - order preserved with all merging @@ -149,12 +156,14 @@ namespace Orchard.Environment.State { // lower enabled states in reverse order foreach (var entry in allEntries.Reverse().Where(entry => entry.FeatureState.EnableState == ShellFeatureState.State.Falling)) { + Logger.Information("Disabling feature '{0}'", entry.Feature.Descriptor.Id); _featureEvents.Disable(entry.Feature); _stateManager.UpdateEnabledState(entry.FeatureState, ShellFeatureState.State.Down); } // lower installed states in reverse order foreach (var entry in allEntries.Reverse().Where(entry => entry.FeatureState.InstallState == ShellFeatureState.State.Falling)) { + Logger.Information("Uninstalling feature '{0}'", entry.Feature.Descriptor.Id); _featureEvents.Uninstall(entry.Feature); _stateManager.UpdateInstalledState(entry.FeatureState, ShellFeatureState.State.Down); } @@ -162,10 +171,12 @@ namespace Orchard.Environment.State { // raise install and enabled states in order foreach (var entry in allEntries.Where(entry => IsRising(entry.FeatureState))) { if (entry.FeatureState.InstallState == ShellFeatureState.State.Rising) { + Logger.Information("Installing feature '{0}'", entry.Feature.Descriptor.Id); _featureEvents.Install(entry.Feature); _stateManager.UpdateInstalledState(entry.FeatureState, ShellFeatureState.State.Up); } if (entry.FeatureState.EnableState == ShellFeatureState.State.Rising) { + Logger.Information("Enabling feature '{0}'", entry.Feature.Descriptor.Id); _featureEvents.Enable(entry.Feature); _stateManager.UpdateEnabledState(entry.FeatureState, ShellFeatureState.State.Up); } diff --git a/src/Orchard/Localization/LocalizationModule.cs b/src/Orchard/Localization/LocalizationModule.cs index 9d538c874..506e7b893 100644 --- a/src/Orchard/Localization/LocalizationModule.cs +++ b/src/Orchard/Localization/LocalizationModule.cs @@ -9,7 +9,7 @@ using Module = Autofac.Module; namespace Orchard.Localization { public class LocalizationModule : Module { private readonly IDictionary _localizerCache; - + public LocalizationModule() { _localizerCache = new ConcurrentDictionary(); } @@ -29,7 +29,7 @@ namespace Orchard.Localization { if (_localizerCache.ContainsKey(scope)) { userProperty.SetValue(e.Instance, _localizerCache[scope], null); } - else { + else { var localizer = LocalizationUtilities.Resolve(e.Context, scope); _localizerCache.Add(scope, localizer); userProperty.SetValue(e.Instance, localizer, null);