From 9a78afd41ba8dd2677423b6e9589da87912d0f05 Mon Sep 17 00:00:00 2001 From: Frode Nilsen Date: Thu, 16 Aug 2018 14:34:25 +0200 Subject: [PATCH] Unified implementation to same approach --- .../Core/Logging/LevelFilteredLogger.cs | 210 ++++++------------ .../NLogLogger.cs | 177 +++++++++++---- 2 files changed, 201 insertions(+), 186 deletions(-) diff --git a/src/Castle.Core/Core/Logging/LevelFilteredLogger.cs b/src/Castle.Core/Core/Logging/LevelFilteredLogger.cs index 13d272f5af..25fb839011 100644 --- a/src/Castle.Core/Core/Logging/LevelFilteredLogger.cs +++ b/src/Castle.Core/Core/Logging/LevelFilteredLogger.cs @@ -204,22 +204,18 @@ public void TraceFormat(Exception exception, IFormatProvider formatProvider, str /// The message to log public void Debug(string message) { - if (!IsDebugEnabled) + if (IsDebugEnabled) { - return; + Log(LoggerLevel.Debug, message, null); } - - Log(LoggerLevel.Debug, message, null); } public void Debug(Func messageFactory) { - if (!IsDebugEnabled) + if (IsDebugEnabled) { - return; + Log(LoggerLevel.Debug, messageFactory.Invoke(), null); } - - Log(LoggerLevel.Debug, messageFactory.Invoke(), null); } /// @@ -229,12 +225,10 @@ public void Debug(Func messageFactory) /// The message to log public void Debug(string message, Exception exception) { - if (!IsDebugEnabled) + if (IsDebugEnabled) { - return; + Log(LoggerLevel.Debug, message, exception); } - - Log(LoggerLevel.Debug, message, exception); } /// @@ -244,12 +238,10 @@ public void Debug(string message, Exception exception) /// Format arguments for the message to log public void DebugFormat(string format, params object[] args) { - if (!IsDebugEnabled) + if (IsDebugEnabled) { - return; + Log(LoggerLevel.Debug, String.Format(CultureInfo.CurrentCulture, format, args), null); } - - Log(LoggerLevel.Debug, String.Format(CultureInfo.CurrentCulture, format, args), null); } /// @@ -260,12 +252,10 @@ public void DebugFormat(string format, params object[] args) /// Format arguments for the message to log public void DebugFormat(Exception exception, string format, params object[] args) { - if (!IsDebugEnabled) + if (IsDebugEnabled) { - return; + Log(LoggerLevel.Debug, String.Format(CultureInfo.CurrentCulture, format, args), exception); } - - Log(LoggerLevel.Debug, String.Format(CultureInfo.CurrentCulture, format, args), exception); } /// @@ -276,12 +266,10 @@ public void DebugFormat(Exception exception, string format, params object[] args /// Format arguments for the message to log public void DebugFormat(IFormatProvider formatProvider, string format, params object[] args) { - if (!IsDebugEnabled) + if (IsDebugEnabled) { - return; + Log(LoggerLevel.Debug, String.Format(formatProvider, format, args), null); } - - Log(LoggerLevel.Debug, String.Format(formatProvider, format, args), null); } /// @@ -293,12 +281,10 @@ public void DebugFormat(IFormatProvider formatProvider, string format, params ob /// Format arguments for the message to log public void DebugFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args) { - if (!IsDebugEnabled) + if (IsDebugEnabled) { - return; + Log(LoggerLevel.Debug, String.Format(formatProvider, format, args), exception); } - - Log(LoggerLevel.Debug, String.Format(formatProvider, format, args), exception); } #endregion @@ -311,22 +297,18 @@ public void DebugFormat(Exception exception, IFormatProvider formatProvider, str /// The message to log public void Info(string message) { - if (!IsInfoEnabled) + if (IsInfoEnabled) { - return; + Log(LoggerLevel.Info, message, null); } - - Log(LoggerLevel.Info, message, null); } public void Info(Func messageFactory) { - if (!IsInfoEnabled) + if (IsInfoEnabled) { - return; + Log(LoggerLevel.Info, messageFactory.Invoke(), null); } - - Log(LoggerLevel.Info, messageFactory.Invoke(), null); } /// @@ -336,12 +318,10 @@ public void Info(Func messageFactory) /// The message to log public void Info(string message, Exception exception) { - if (!IsInfoEnabled) + if (IsInfoEnabled) { - return; + Log(LoggerLevel.Info, message, exception); } - - Log(LoggerLevel.Info, message, exception); } /// @@ -351,12 +331,10 @@ public void Info(string message, Exception exception) /// Format arguments for the message to log public void InfoFormat(string format, params object[] args) { - if (!IsInfoEnabled) + if (IsInfoEnabled) { - return; + Log(LoggerLevel.Info, String.Format(CultureInfo.CurrentCulture, format, args), null); } - - Log(LoggerLevel.Info, String.Format(CultureInfo.CurrentCulture, format, args), null); } /// @@ -367,12 +345,10 @@ public void InfoFormat(string format, params object[] args) /// Format arguments for the message to log public void InfoFormat(Exception exception, string format, params object[] args) { - if (!IsInfoEnabled) + if (IsInfoEnabled) { - return; + Log(LoggerLevel.Info, String.Format(CultureInfo.CurrentCulture, format, args), exception); } - - Log(LoggerLevel.Info, String.Format(CultureInfo.CurrentCulture, format, args), exception); } /// @@ -383,12 +359,10 @@ public void InfoFormat(Exception exception, string format, params object[] args) /// Format arguments for the message to log public void InfoFormat(IFormatProvider formatProvider, string format, params object[] args) { - if (!IsInfoEnabled) + if (IsInfoEnabled) { - return; + Log(LoggerLevel.Info, String.Format(formatProvider, format, args), null); } - - Log(LoggerLevel.Info, String.Format(formatProvider, format, args), null); } /// @@ -400,12 +374,10 @@ public void InfoFormat(IFormatProvider formatProvider, string format, params obj /// Format arguments for the message to log public void InfoFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args) { - if (!IsInfoEnabled) + if (IsInfoEnabled) { - return; + Log(LoggerLevel.Info, String.Format(formatProvider, format, args), exception); } - - Log(LoggerLevel.Info, String.Format(formatProvider, format, args), exception); } #endregion @@ -418,22 +390,18 @@ public void InfoFormat(Exception exception, IFormatProvider formatProvider, stri /// The message to log public void Warn(string message) { - if (!IsWarnEnabled) + if (IsWarnEnabled) { - return; + Log(LoggerLevel.Warn, message, null); } - - Log(LoggerLevel.Warn, message, null); } public void Warn(Func messageFactory) { - if (!IsWarnEnabled) + if (IsWarnEnabled) { - return; + Log(LoggerLevel.Warn, messageFactory.Invoke(), null); } - - Log(LoggerLevel.Warn, messageFactory.Invoke(), null); } /// @@ -443,12 +411,10 @@ public void Warn(Func messageFactory) /// The message to log public void Warn(string message, Exception exception) { - if (!IsWarnEnabled) + if (IsWarnEnabled) { - return; + Log(LoggerLevel.Warn, message, exception); } - - Log(LoggerLevel.Warn, message, exception); } /// @@ -458,12 +424,10 @@ public void Warn(string message, Exception exception) /// Format arguments for the message to log public void WarnFormat(string format, params object[] args) { - if (!IsWarnEnabled) + if (IsWarnEnabled) { - return; + Log(LoggerLevel.Warn, String.Format(CultureInfo.CurrentCulture, format, args), null); } - - Log(LoggerLevel.Warn, String.Format(CultureInfo.CurrentCulture, format, args), null); } /// @@ -474,12 +438,10 @@ public void WarnFormat(string format, params object[] args) /// Format arguments for the message to log public void WarnFormat(Exception exception, string format, params object[] args) { - if (!IsWarnEnabled) + if (IsWarnEnabled) { - return; + Log(LoggerLevel.Warn, String.Format(CultureInfo.CurrentCulture, format, args), exception); } - - Log(LoggerLevel.Warn, String.Format(CultureInfo.CurrentCulture, format, args), exception); } /// @@ -490,12 +452,10 @@ public void WarnFormat(Exception exception, string format, params object[] args) /// Format arguments for the message to log public void WarnFormat(IFormatProvider formatProvider, string format, params object[] args) { - if (!IsWarnEnabled) + if (IsWarnEnabled) { - return; + Log(LoggerLevel.Warn, String.Format(formatProvider, format, args), null); } - - Log(LoggerLevel.Warn, String.Format(formatProvider, format, args), null); } /// @@ -507,12 +467,10 @@ public void WarnFormat(IFormatProvider formatProvider, string format, params obj /// Format arguments for the message to log public void WarnFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args) { - if (!IsWarnEnabled) + if (IsWarnEnabled) { - return; + Log(LoggerLevel.Warn, String.Format(formatProvider, format, args), exception); } - - Log(LoggerLevel.Warn, String.Format(formatProvider, format, args), exception); } #endregion @@ -525,22 +483,18 @@ public void WarnFormat(Exception exception, IFormatProvider formatProvider, stri /// The message to log public void Error(string message) { - if (!IsErrorEnabled) + if (IsErrorEnabled) { - return; + Log(LoggerLevel.Error, message, null); } - - Log(LoggerLevel.Error, message, null); } public void Error(Func messageFactory) { - if (!IsErrorEnabled) + if (IsErrorEnabled) { - return; + Log(LoggerLevel.Error, messageFactory.Invoke(), null); } - - Log(LoggerLevel.Error, messageFactory.Invoke(), null); } /// @@ -550,12 +504,10 @@ public void Error(Func messageFactory) /// The message to log public void Error(string message, Exception exception) { - if (!IsErrorEnabled) + if (IsErrorEnabled) { - return; + Log(LoggerLevel.Error, message, exception); } - - Log(LoggerLevel.Error, message, exception); } /// @@ -565,12 +517,10 @@ public void Error(string message, Exception exception) /// Format arguments for the message to log public void ErrorFormat(string format, params object[] args) { - if (!IsErrorEnabled) + if (IsErrorEnabled) { - return; + Log(LoggerLevel.Error, String.Format(CultureInfo.CurrentCulture, format, args), null); } - - Log(LoggerLevel.Error, String.Format(CultureInfo.CurrentCulture, format, args), null); } /// @@ -581,12 +531,10 @@ public void ErrorFormat(string format, params object[] args) /// Format arguments for the message to log public void ErrorFormat(Exception exception, string format, params object[] args) { - if (!IsErrorEnabled) + if (IsErrorEnabled) { - return; + Log(LoggerLevel.Error, String.Format(CultureInfo.CurrentCulture, format, args), exception); } - - Log(LoggerLevel.Error, String.Format(CultureInfo.CurrentCulture, format, args), exception); } /// @@ -597,12 +545,10 @@ public void ErrorFormat(Exception exception, string format, params object[] args /// Format arguments for the message to log public void ErrorFormat(IFormatProvider formatProvider, string format, params object[] args) { - if (!IsErrorEnabled) + if (IsErrorEnabled) { - return; + Log(LoggerLevel.Error, String.Format(formatProvider, format, args), null); } - - Log(LoggerLevel.Error, String.Format(formatProvider, format, args), null); } /// @@ -614,12 +560,10 @@ public void ErrorFormat(IFormatProvider formatProvider, string format, params ob /// Format arguments for the message to log public void ErrorFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args) { - if (!IsErrorEnabled) + if (IsErrorEnabled) { - return; + Log(LoggerLevel.Error, String.Format(formatProvider, format, args), exception); } - - Log(LoggerLevel.Error, String.Format(formatProvider, format, args), exception); } #endregion @@ -632,22 +576,18 @@ public void ErrorFormat(Exception exception, IFormatProvider formatProvider, str /// The message to log public void Fatal(string message) { - if (!IsFatalEnabled) + if (IsFatalEnabled) { - return; + Log(LoggerLevel.Fatal, message, null); } - - Log(LoggerLevel.Fatal, message, null); } public void Fatal(Func messageFactory) { - if (!IsFatalEnabled) + if (IsFatalEnabled) { - return; + Log(LoggerLevel.Fatal, messageFactory.Invoke(), null); } - - Log(LoggerLevel.Fatal, messageFactory.Invoke(), null); } /// @@ -657,12 +597,10 @@ public void Fatal(Func messageFactory) /// The message to log public void Fatal(string message, Exception exception) { - if (!IsFatalEnabled) + if (IsFatalEnabled) { - return; + Log(LoggerLevel.Fatal, message, exception); } - - Log(LoggerLevel.Fatal, message, exception); } /// @@ -672,12 +610,10 @@ public void Fatal(string message, Exception exception) /// Format arguments for the message to log public void FatalFormat(string format, params object[] args) { - if (!IsFatalEnabled) + if (IsFatalEnabled) { - return; + Log(LoggerLevel.Fatal, String.Format(CultureInfo.CurrentCulture, format, args), null); } - - Log(LoggerLevel.Fatal, String.Format(CultureInfo.CurrentCulture, format, args), null); } /// @@ -688,12 +624,10 @@ public void FatalFormat(string format, params object[] args) /// Format arguments for the message to log public void FatalFormat(Exception exception, string format, params object[] args) { - if (!IsFatalEnabled) + if (IsFatalEnabled) { - return; + Log(LoggerLevel.Fatal, String.Format(CultureInfo.CurrentCulture, format, args), exception); } - - Log(LoggerLevel.Fatal, String.Format(CultureInfo.CurrentCulture, format, args), exception); } /// @@ -704,12 +638,10 @@ public void FatalFormat(Exception exception, string format, params object[] args /// Format arguments for the message to log public void FatalFormat(IFormatProvider formatProvider, string format, params object[] args) { - if (!IsFatalEnabled) + if (IsFatalEnabled) { - return; + Log(LoggerLevel.Fatal, String.Format(formatProvider, format, args), null); } - - Log(LoggerLevel.Fatal, String.Format(formatProvider, format, args), null); } /// @@ -721,12 +653,10 @@ public void FatalFormat(IFormatProvider formatProvider, string format, params ob /// Format arguments for the message to log public void FatalFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args) { - if (!IsFatalEnabled) + if (IsFatalEnabled) { - return; + Log(LoggerLevel.Fatal, String.Format(formatProvider, format, args), exception); } - - Log(LoggerLevel.Fatal, String.Format(formatProvider, format, args), exception); } #endregion diff --git a/src/Castle.Services.Logging.NLogIntegration/NLogLogger.cs b/src/Castle.Services.Logging.NLogIntegration/NLogLogger.cs index 14d06992b7..77027fa8b5 100644 --- a/src/Castle.Services.Logging.NLogIntegration/NLogLogger.cs +++ b/src/Castle.Services.Logging.NLogIntegration/NLogLogger.cs @@ -218,7 +218,10 @@ public void TraceFormat(Exception exception, IFormatProvider formatProvider, str /// The message to log public void Debug(string message) { - Log(LogLevel.Debug, message); + if (IsDebugEnabled) + { + Log(LogLevel.Debug, message); + } } /// @@ -229,9 +232,8 @@ public void Debug(Func messageFactory) { if (IsDebugEnabled == false) { - return; + Log(LogLevel.Debug, messageFactory()); } - Log(LogLevel.Debug, messageFactory()); } /// @@ -241,7 +243,10 @@ public void Debug(Func messageFactory) /// The message to log public void Debug(string message, Exception exception) { - Log(LogLevel.Debug, message, exception); + if (IsDebugEnabled) + { + Log(LogLevel.Debug, message, exception); + } } /// @@ -251,7 +256,10 @@ public void Debug(string message, Exception exception) /// Format arguments for the message to log public void DebugFormat(string format, params object[] args) { - Log(LogLevel.Debug, format, args); + if (IsDebugEnabled) + { + Log(LogLevel.Debug, format, args); + } } /// @@ -262,7 +270,10 @@ public void DebugFormat(string format, params object[] args) /// Format arguments for the message to log public void DebugFormat(Exception exception, string format, params object[] args) { - Log(LogLevel.Debug, exception, format, args); + if (IsDebugEnabled) + { + Log(LogLevel.Debug, exception, format, args); + } } /// @@ -273,7 +284,10 @@ public void DebugFormat(Exception exception, string format, params object[] args /// Format arguments for the message to log public void DebugFormat(IFormatProvider formatProvider, string format, params object[] args) { - Log(LogLevel.Debug, formatProvider, format, args); + if (IsDebugEnabled) + { + Log(LogLevel.Debug, formatProvider, format, args); + } } /// @@ -285,7 +299,10 @@ public void DebugFormat(IFormatProvider formatProvider, string format, params ob /// Format arguments for the message to log public void DebugFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args) { - Log(LogLevel.Debug, exception, formatProvider, format, args); + if (IsDebugEnabled) + { + Log(LogLevel.Debug, exception, formatProvider, format, args); + } } /// @@ -294,7 +311,10 @@ public void DebugFormat(Exception exception, IFormatProvider formatProvider, str /// The message to log public void Error(string message) { - Log(LogLevel.Error, message); + if (IsErrorEnabled) + { + Log(LogLevel.Error, message); + } } /// @@ -303,11 +323,10 @@ public void Error(string message) /// Factory constructing lazily the message to log if the level is enabled public void Error(Func messageFactory) { - if (IsErrorEnabled == false) + if (IsErrorEnabled) { - return; + Log(LogLevel.Error, messageFactory()); } - Log(LogLevel.Error, messageFactory()); } /// @@ -317,7 +336,10 @@ public void Error(Func messageFactory) /// The message to log public void Error(string message, Exception exception) { - Log(LogLevel.Error, message, exception); + if (IsErrorEnabled) + { + Log(LogLevel.Error, message, exception); + } } /// @@ -327,7 +349,10 @@ public void Error(string message, Exception exception) /// Format arguments for the message to log public void ErrorFormat(string format, params object[] args) { - Log(LogLevel.Error, format, args); + if (IsErrorEnabled) + { + Log(LogLevel.Error, format, args); + } } /// @@ -338,7 +363,10 @@ public void ErrorFormat(string format, params object[] args) /// Format arguments for the message to log public void ErrorFormat(Exception exception, string format, params object[] args) { - Log(LogLevel.Error, exception, format, args); + if (IsErrorEnabled) + { + Log(LogLevel.Error, exception, format, args); + } } /// @@ -349,7 +377,10 @@ public void ErrorFormat(Exception exception, string format, params object[] args /// Format arguments for the message to log public void ErrorFormat(IFormatProvider formatProvider, string format, params object[] args) { - Log(LogLevel.Error, formatProvider, format, args); + if (IsErrorEnabled) + { + Log(LogLevel.Error, formatProvider, format, args); + } } /// @@ -361,7 +392,10 @@ public void ErrorFormat(IFormatProvider formatProvider, string format, params ob /// Format arguments for the message to log public void ErrorFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args) { - Log(LogLevel.Error, exception, formatProvider, format, args); + if (IsErrorEnabled) + { + Log(LogLevel.Error, exception, formatProvider, format, args); + } } /// @@ -370,7 +404,10 @@ public void ErrorFormat(Exception exception, IFormatProvider formatProvider, str /// The message to log public void Fatal(string message) { - Log(LogLevel.Fatal, message); + if (IsFatalEnabled) + { + Log(LogLevel.Fatal, message); + } } /// @@ -379,11 +416,10 @@ public void Fatal(string message) /// Factory constructing lazily the message to log if the level is enabled public void Fatal(Func messageFactory) { - if (IsFatalEnabled == false) + if (IsFatalEnabled) { - return; + Log(LogLevel.Fatal, messageFactory()); } - Log(LogLevel.Fatal, messageFactory()); } /// @@ -393,7 +429,10 @@ public void Fatal(Func messageFactory) /// The message to log public void Fatal(string message, Exception exception) { - Log(LogLevel.Fatal, message, exception); + if (IsFatalEnabled) + { + Log(LogLevel.Fatal, message, exception); + } } /// @@ -403,7 +442,10 @@ public void Fatal(string message, Exception exception) /// Format arguments for the message to log public void FatalFormat(string format, params object[] args) { - Log(LogLevel.Fatal, format, args); + if (IsFatalEnabled) + { + Log(LogLevel.Fatal, format, args); + } } /// @@ -414,7 +456,10 @@ public void FatalFormat(string format, params object[] args) /// Format arguments for the message to log public void FatalFormat(Exception exception, string format, params object[] args) { - Log(LogLevel.Fatal, exception, format, args); + if (IsFatalEnabled) + { + Log(LogLevel.Fatal, exception, format, args); + } } /// @@ -425,7 +470,10 @@ public void FatalFormat(Exception exception, string format, params object[] args /// Format arguments for the message to log public void FatalFormat(IFormatProvider formatProvider, string format, params object[] args) { - Log(LogLevel.Fatal, formatProvider, format, args); + if (IsFatalEnabled) + { + Log(LogLevel.Fatal, formatProvider, format, args); + } } /// @@ -437,7 +485,10 @@ public void FatalFormat(IFormatProvider formatProvider, string format, params ob /// Format arguments for the message to log public void FatalFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args) { - Log(LogLevel.Fatal, exception, formatProvider, format, args); + if (IsFatalEnabled) + { + Log(LogLevel.Fatal, exception, formatProvider, format, args); + } } /// @@ -446,7 +497,10 @@ public void FatalFormat(Exception exception, IFormatProvider formatProvider, str /// The message to log public void Info(string message) { - Log(LogLevel.Info, message); + if (IsInfoEnabled) + { + Log(LogLevel.Info, message); + } } /// @@ -455,11 +509,10 @@ public void Info(string message) /// Factory constructing lazily the message to log if the level is enabled public void Info(Func messageFactory) { - if (IsInfoEnabled == false) + if (IsInfoEnabled) { - return; + Log(LogLevel.Info, messageFactory()); } - Log(LogLevel.Info, messageFactory()); } /// @@ -469,7 +522,10 @@ public void Info(Func messageFactory) /// The message to log public void Info(string message, Exception exception) { - Log(LogLevel.Info, message, exception); + if (IsInfoEnabled) + { + Log(LogLevel.Info, message, exception); + } } /// @@ -479,7 +535,10 @@ public void Info(string message, Exception exception) /// Format arguments for the message to log public void InfoFormat(string format, params object[] args) { - Log(LogLevel.Info, format, args); + if (IsInfoEnabled) + { + Log(LogLevel.Info, format, args); + } } /// @@ -490,7 +549,10 @@ public void InfoFormat(string format, params object[] args) /// Format arguments for the message to log public void InfoFormat(Exception exception, string format, params object[] args) { - Log(LogLevel.Info, exception, format, args); + if (IsInfoEnabled) + { + Log(LogLevel.Info, exception, format, args); + } } /// @@ -501,7 +563,10 @@ public void InfoFormat(Exception exception, string format, params object[] args) /// Format arguments for the message to log public void InfoFormat(IFormatProvider formatProvider, string format, params object[] args) { - Log(LogLevel.Info, formatProvider, format, args); + if (IsInfoEnabled) + { + Log(LogLevel.Info, formatProvider, format, args); + } } /// @@ -513,7 +578,10 @@ public void InfoFormat(IFormatProvider formatProvider, string format, params obj /// Format arguments for the message to log public void InfoFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args) { - Log(LogLevel.Info, exception, formatProvider, format, args); + if (IsInfoEnabled) + { + Log(LogLevel.Info, exception, formatProvider, format, args); + } } /// @@ -522,7 +590,10 @@ public void InfoFormat(Exception exception, IFormatProvider formatProvider, stri /// The message to log public void Warn(string message) { - Log(LogLevel.Warn, message); + if (IsWarnEnabled) + { + Log(LogLevel.Warn, message); + } } /// @@ -531,11 +602,10 @@ public void Warn(string message) /// Factory constructing lazily the message to log if the level is enabled public void Warn(Func messageFactory) { - if (IsWarnEnabled == false) + if (IsWarnEnabled) { - return; + Log(LogLevel.Warn, messageFactory()); } - Log(LogLevel.Warn, messageFactory()); } /// @@ -545,7 +615,10 @@ public void Warn(Func messageFactory) /// The message to log public void Warn(string message, Exception exception) { - Log(LogLevel.Warn, message, exception); + if (IsWarnEnabled) + { + Log(LogLevel.Warn, message, exception); + } } /// @@ -555,7 +628,10 @@ public void Warn(string message, Exception exception) /// Format arguments for the message to log public void WarnFormat(string format, params object[] args) { - Log(LogLevel.Warn, format, args); + if (IsWarnEnabled) + { + Log(LogLevel.Warn, format, args); + } } /// @@ -566,7 +642,10 @@ public void WarnFormat(string format, params object[] args) /// Format arguments for the message to log public void WarnFormat(Exception exception, string format, params object[] args) { - Log(LogLevel.Warn, exception, format, args); + if (IsWarnEnabled) + { + Log(LogLevel.Warn, exception, format, args); + } } /// @@ -577,7 +656,10 @@ public void WarnFormat(Exception exception, string format, params object[] args) /// Format arguments for the message to log public void WarnFormat(IFormatProvider formatProvider, string format, params object[] args) { - Log(LogLevel.Warn, formatProvider, format, args); + if (IsWarnEnabled) + { + Log(LogLevel.Warn, formatProvider, format, args); + } } /// @@ -589,7 +671,10 @@ public void WarnFormat(IFormatProvider formatProvider, string format, params obj /// Format arguments for the message to log public void WarnFormat(Exception exception, IFormatProvider formatProvider, string format, params object[] args) { - Log(LogLevel.Warn, exception, formatProvider, format, args); + if (IsWarnEnabled) + { + Log(LogLevel.Warn, exception, formatProvider, format, args); + } } private void Log(LogLevel logLevel, string message) @@ -631,11 +716,11 @@ private void Log(LogLevel logLevel, IFormatProvider formatProvider, string forma }); } - private void Log(LogLevel logLevel, Exception exceptoin, IFormatProvider formatProvider, string format, object[] args) + private void Log(LogLevel logLevel, Exception exception, IFormatProvider formatProvider, string format, object[] args) { Logger.Log(typeof(NLogLogger), new LogEventInfo(logLevel, Logger.Name, format) { - Exception = exceptoin, + Exception = exception, FormatProvider = formatProvider, Parameters = args });