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)
This commit is contained in:
@@ -9,14 +9,14 @@ namespace Umbraco.Core.Logging
|
||||
///<summary>
|
||||
/// Used for logging
|
||||
///</summary>
|
||||
internal static class LogHelper
|
||||
public static class LogHelper
|
||||
{
|
||||
///<summary>
|
||||
/// Returns a logger for the type specified
|
||||
///</summary>
|
||||
///<typeparam name="T"></typeparam>
|
||||
///<returns></returns>
|
||||
public static ILog LoggerFor<T>()
|
||||
internal static ILog LoggerFor<T>()
|
||||
{
|
||||
return LogManager.GetLogger(typeof(T));
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace Umbraco.Core.Logging
|
||||
/// </summary>
|
||||
/// <param name="getTypeFromInstance"></param>
|
||||
/// <returns></returns>
|
||||
public static ILog LoggerFor(object getTypeFromInstance)
|
||||
internal static ILog LoggerFor(object getTypeFromInstance)
|
||||
{
|
||||
if (getTypeFromInstance == null) throw new ArgumentNullException("getTypeFromInstance");
|
||||
|
||||
|
||||
@@ -177,13 +177,19 @@ namespace umbraco.BusinessLogic
|
||||
{
|
||||
LogHelper.Error<Log>("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<Log>(
|
||||
"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<Log>(
|
||||
"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<LogItem> GetAuditLogItems(int NodeId)
|
||||
|
||||
@@ -153,6 +153,7 @@ namespace umbraco.BusinessLogic
|
||||
/// Use this log action for custom log messages that should be shown in the audit trail
|
||||
/// </summary>
|
||||
[AuditTrailLogItem]
|
||||
[Obsolete("Use LogHelper to write custom log messages")]
|
||||
Custom
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user