From: <fab...@us...> - 2011-05-02 14:27:05
|
Revision: 5794 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5794&view=rev Author: fabiomaulo Date: 2011-05-02 14:26:59 +0000 (Mon, 02 May 2011) Log Message: ----------- Fix NH-2685 and any other possible not safe call to the logger Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Logging.cs trunk/nhibernate/src/NHibernate.Test/Logging/Log4NetLoggerTest.cs Modified: trunk/nhibernate/src/NHibernate/Logging.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Logging.cs 2011-05-02 14:08:59 UTC (rev 5793) +++ trunk/nhibernate/src/NHibernate/Logging.cs 2011-05-02 14:26:59 UTC (rev 5794) @@ -374,72 +374,86 @@ public void Error(object message) { - ErrorDelegate(logger, message); + if (IsErrorEnabled) + ErrorDelegate(logger, message); } public void Error(object message, Exception exception) { - ErrorExceptionDelegate(logger,message,exception); + if (IsErrorEnabled) + ErrorExceptionDelegate(logger, message, exception); } public void ErrorFormat(string format, params object[] args) { - ErrorFormatDelegate(logger, format, args); + if (IsErrorEnabled) + ErrorFormatDelegate(logger, format, args); } public void Fatal(object message) { - FatalDelegate(logger, message); + if (IsFatalEnabled) + FatalDelegate(logger, message); } public void Fatal(object message, Exception exception) { - FatalExceptionDelegate(logger,message,exception); + if (IsFatalEnabled) + FatalExceptionDelegate(logger, message, exception); } public void Debug(object message) { - DebugDelegate(logger, message); + if (IsDebugEnabled) + DebugDelegate(logger, message); } public void Debug(object message, Exception exception) { - DebugExceptionDelegate(logger, message, exception); + if (IsDebugEnabled) + DebugExceptionDelegate(logger, message, exception); } public void DebugFormat(string format, params object[] args) { - DebugFormatDelegate(logger, format, args); + if (IsDebugEnabled) + DebugFormatDelegate(logger, format, args); } public void Info(object message) { - InfoDelegate(logger, message); + if (IsInfoEnabled) + InfoDelegate(logger, message); } public void Info(object message, Exception exception) { - InfoExceptionDelegate(logger, message, exception); + if (IsInfoEnabled) + InfoExceptionDelegate(logger, message, exception); } public void InfoFormat(string format, params object[] args) { - InfoFormatDelegate(logger, format, args); + if (IsInfoEnabled) + InfoFormatDelegate(logger, format, args); } public void Warn(object message) { - WarnDelegate(logger, message); + if (IsWarnEnabled) + WarnDelegate(logger, message); } public void Warn(object message, Exception exception) { - WarnExceptionDelegate(logger, message, exception); + if (IsWarnEnabled) + WarnExceptionDelegate(logger, message, exception); } public void WarnFormat(string format, params object[] args) { - WarnFormatDelegate(logger, format, args); + if (IsWarnEnabled) + WarnFormatDelegate(logger, format, args); } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/Logging/Log4NetLoggerTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Logging/Log4NetLoggerTest.cs 2011-05-02 14:08:59 UTC (rev 5793) +++ trunk/nhibernate/src/NHibernate.Test/Logging/Log4NetLoggerTest.cs 2011-05-02 14:26:59 UTC (rev 5794) @@ -214,7 +214,7 @@ get { isDebugEnabled++; - return false; + return true; } } @@ -223,7 +223,7 @@ get { isInfoEnabled++; - return false; + return true; } } @@ -232,7 +232,7 @@ get { isWarnEnabled++; - return false; + return true; } } @@ -241,7 +241,7 @@ get { isErrorEnabled++; - return false; + return true; } } @@ -250,7 +250,7 @@ get { isFatalEnabled++; - return false; + return true; } } } @@ -299,11 +299,11 @@ logMock.errorFormat.Should().Be(1); logMock.fatal.Should().Be(1); logMock.fatalException.Should().Be(1); - logMock.isDebugEnabled.Should().Be(1); - logMock.isInfoEnabled.Should().Be(1); - logMock.isWarnEnabled.Should().Be(1); - logMock.isErrorEnabled.Should().Be(1); - logMock.isFatalEnabled.Should().Be(1); + logMock.isDebugEnabled.Should().Be.GreaterThan(1); + logMock.isInfoEnabled.Should().Be.GreaterThan(1); + logMock.isWarnEnabled.Should().Be.GreaterThan(1); + logMock.isErrorEnabled.Should().Be.GreaterThan(1); + logMock.isFatalEnabled.Should().Be.GreaterThan(1); } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |