Adding logging in a couple of components

--HG--
branch : dev
This commit is contained in:
Renaud Paquay 2010-12-04 14:09:15 -08:00
parent 74701225aa
commit a1059de8bb
3 changed files with 15 additions and 3 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -9,7 +9,7 @@ using Module = Autofac.Module;
namespace Orchard.Localization {
public class LocalizationModule : Module {
private readonly IDictionary<string, Localizer> _localizerCache;
public LocalizationModule() {
_localizerCache = new ConcurrentDictionary<string, Localizer>();
}
@ -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);