From e0550a9a572a2bbb02ec1abe0456f5b865e885e3 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Thu, 3 Jan 2013 02:08:29 +0300 Subject: [PATCH] Fixes: #U4-1381 - LogHelper is public. Obsoletes 'Custm' log type and ensures that they are written to the log4net log too (though they will continue to write to the audit trail until it is removed) --- src/Umbraco.Core/Logging/LogHelper.cs | 6 +++--- src/umbraco.businesslogic/Log.cs | 18 ++++++++++++------ src/umbraco.businesslogic/LogTypes.cs | 1 + 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Core/Logging/LogHelper.cs b/src/Umbraco.Core/Logging/LogHelper.cs index 31de04c839..9291ffec1d 100644 --- a/src/Umbraco.Core/Logging/LogHelper.cs +++ b/src/Umbraco.Core/Logging/LogHelper.cs @@ -9,14 +9,14 @@ namespace Umbraco.Core.Logging /// /// Used for logging /// - internal static class LogHelper + public static class LogHelper { /// /// Returns a logger for the type specified /// /// /// - public static ILog LoggerFor() + internal static ILog LoggerFor() { return LogManager.GetLogger(typeof(T)); } @@ -26,7 +26,7 @@ namespace Umbraco.Core.Logging /// /// /// - public static ILog LoggerFor(object getTypeFromInstance) + internal static ILog LoggerFor(object getTypeFromInstance) { if (getTypeFromInstance == null) throw new ArgumentNullException("getTypeFromInstance"); diff --git a/src/umbraco.businesslogic/Log.cs b/src/umbraco.businesslogic/Log.cs index ec06ac0174..92da7b093f 100644 --- a/src/umbraco.businesslogic/Log.cs +++ b/src/umbraco.businesslogic/Log.cs @@ -177,13 +177,19 @@ namespace umbraco.BusinessLogic { LogHelper.Error("An error occurred adding an audit trail log to the umbracoLog table", e); } + + //Because 'Custom' log types are also Audit trail (for some wacky reason) but we also want these logged normally so we have to check for this: + if (type != LogTypes.Custom) + { + return; + } + } - else - { - LogHelper.Info( - "Redirected log call (please use Umbraco.Core.Logging.LogHelper instead of umbraco.BusinessLogic.Log) | Type: {0} | User: {1} | NodeId: {2} | Comment: {3}", - () => type.ToString(), () => userId, () => nodeId.ToString(CultureInfo.InvariantCulture), () => comment); - } + + //if we've made it this far it means that the log type is not an audit trail log or is a custom log. + LogHelper.Info( + "Redirected log call (please use Umbraco.Core.Logging.LogHelper instead of umbraco.BusinessLogic.Log) | Type: {0} | User: {1} | NodeId: {2} | Comment: {3}", + () => type.ToString(), () => userId, () => nodeId.ToString(CultureInfo.InvariantCulture), () => comment); } public List GetAuditLogItems(int NodeId) diff --git a/src/umbraco.businesslogic/LogTypes.cs b/src/umbraco.businesslogic/LogTypes.cs index 21b168d001..f8232c0df0 100644 --- a/src/umbraco.businesslogic/LogTypes.cs +++ b/src/umbraco.businesslogic/LogTypes.cs @@ -153,6 +153,7 @@ namespace umbraco.BusinessLogic /// Use this log action for custom log messages that should be shown in the audit trail /// [AuditTrailLogItem] + [Obsolete("Use LogHelper to write custom log messages")] Custom } } \ No newline at end of file