logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1211480 - /logging/log4net/trunk/src/Util/OnlyOnceErrorHandler.cs
Date Wed, 07 Dec 2011 15:48:02 GMT
Author: bodewig
Date: Wed Dec  7 15:48:02 2011
New Revision: 1211480

URL: http://svn.apache.org/viewvc?rev=1211480&view=rev
Log:
Make OnlyOnceErrorHandler subclass friendly.  LOG4NET-283

Modified:
    logging/log4net/trunk/src/Util/OnlyOnceErrorHandler.cs

Modified: logging/log4net/trunk/src/Util/OnlyOnceErrorHandler.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/Util/OnlyOnceErrorHandler.cs?rev=1211480&r1=1211479&r2=1211480&view=diff
==============================================================================
--- logging/log4net/trunk/src/Util/OnlyOnceErrorHandler.cs (original)
+++ logging/log4net/trunk/src/Util/OnlyOnceErrorHandler.cs Wed Dec  7 15:48:02 2011
@@ -30,7 +30,7 @@ namespace log4net.Util
 	/// </summary>
 	/// <remarks>
 	/// <para>
-	/// The error message is processed using the LogLog sub-system.
+	/// The error message is processed using the LogLog sub-system by default.
 	/// </para>
 	/// <para>
 	/// This policy aims at protecting an otherwise working application
@@ -98,37 +98,50 @@ namespace log4net.Util
 		/// <param name="errorCode">The internal error code.</param>
 		/// <remarks>
 		/// <para>
-		/// Sends the error information to <see cref="LogLog"/>'s Error method.
+		/// Invokes <see cref="FirstError"/> if and only if this is the first error or the
first error after <see cref="Reset"/> has been called.
 		/// </para>
 		/// </remarks>
 		public void Error(string message, Exception e, ErrorCode errorCode) 
 		{
 			if (m_firstTime)
 			{
-				m_enabledDate = DateTime.Now;
-				m_errorCode = errorCode;
-				m_exception = e;
-				m_message = message;
-				m_firstTime = false;
-
-				if (LogLog.InternalDebugging && !LogLog.QuietMode)
-				{
-					LogLog.Error(declaringType, "[" + m_prefix + "] ErrorCode: " + errorCode.ToString()
+ ". " + message, e);
-				}
+                FirstError(message, e, errorCode);
 			}
 		}
 
-		/// <summary>
+        /// <summary>
+        /// Log the very first error
+        /// </summary>
+        /// <param name="message">The error message.</param>
+        /// <param name="e">The exception.</param>
+        /// <param name="errorCode">The internal error code.</param>
+        /// <remarks>
+        /// <para>
+        /// Sends the error information to <see cref="LogLog"/>'s Error method.
+        /// </para>
+        /// </remarks>
+        public virtual void FirstError(string message, Exception e, ErrorCode errorCode)
{
+            m_enabledDate = DateTime.Now;
+            m_errorCode = errorCode;
+            m_exception = e;
+            m_message = message;
+            m_firstTime = false;
+
+            if (LogLog.InternalDebugging && !LogLog.QuietMode) {
+                LogLog.Error(declaringType, "[" + m_prefix + "] ErrorCode: " + errorCode.ToString()
+ ". " + message, e);
+            }
+        }
+
+        /// <summary>
 		/// Log an Error
 		/// </summary>
 		/// <param name="message">The error message.</param>
 		/// <param name="e">The exception.</param>
 		/// <remarks>
-		/// <para>
-		/// Prints the message and the stack trace of the exception on the standard
-		/// error output stream.
-		/// </para>
-		/// </remarks>
+        /// <para>
+        /// Invokes <see cref="FirstError"/> if and only if this is the first error
or the first error after <see cref="Reset"/> has been called.
+        /// </para>
+        /// </remarks>
 		public void Error(string message, Exception e) 
 		{
 			Error(message, e, ErrorCode.GenericFailure);
@@ -139,11 +152,10 @@ namespace log4net.Util
 		/// </summary>
 		/// <param name="message">The error message.</param>
 		/// <remarks>
-		/// <para>
-		/// Print a the error message passed as parameter on the standard
-		/// error output stream.
-		/// </para>
-		/// </remarks>
+        /// <para>
+        /// Invokes <see cref="FirstError"/> if and only if this is the first error
or the first error after <see cref="Reset"/> has been called.
+        /// </para>
+        /// </remarks>
 		public void Error(string message) 
 		{
 			Error(message, null, ErrorCode.GenericFailure);



Mime
View raw message