You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by rg...@apache.org on 2006/11/13 05:43:38 UTC

svn commit: r474141 - in /ibatis/trunk/cs/mapper/IBatisNet.Common/Logging: ConfigurationSectionHandler.cs ILog.cs ILoggerFactoryAdapter.cs Impl/AbstractLogger.cs Impl/ConsoleOutLogger.cs Impl/NoOpLoggerFA.cs Impl/TraceLogger.cs LogManager.cs

Author: rgrabowski
Date: Sun Nov 12 20:43:37 2006
New Revision: 474141

URL: http://svn.apache.org/viewvc?view=rev&rev=474141
Log:
Added additional documentation information. Moved shared ILog code from ConsoleOutLogger and TraceLogger into AbstractLogger.

Added:
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/AbstractLogger.cs
Modified:
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ConfigurationSectionHandler.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILog.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILoggerFactoryAdapter.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLogger.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLoggerFA.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLogger.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/LogManager.cs

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ConfigurationSectionHandler.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ConfigurationSectionHandler.cs?view=diff&rev=474141&r1=474140&r2=474141
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ConfigurationSectionHandler.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ConfigurationSectionHandler.cs Sun Nov 12 20:43:37 2006
@@ -60,6 +60,14 @@
 	/// </configuration>
 	/// </code> 
 	/// </example>
+	/// <para>
+	/// The following aliases are recognized for the type attribute of logFactoryAdapter: 
+	/// </para>
+	/// <list type="table">
+	/// <item><term>CONSOLE</term><description>Alias for IBatisNet.Common.Logging.Impl.ConsoleOutLoggerFA, IBatisNet.Common</description></item>
+	/// <item><term>TRACE</term><description>Alias for IBatisNet.Common.Logging.Impl.TraceLoggerFA, IBatisNet.Common</description></item>
+	/// <item><term>NOOP</term><description>Alias IBatisNet.Common.Logging.Impl.NoOpLoggerFA, IBatisNet.Common</description></item>
+	/// </list>
 	/// </remarks>
 	public class ConfigurationSectionHandler: IConfigurationSectionHandler
 	{

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILog.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILog.cs?view=diff&rev=474141&r1=474140&r2=474141
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILog.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILog.cs Sun Nov 12 20:43:37 2006
@@ -64,7 +64,7 @@
 	}
 
 	/// <summary>
-	/// A simple logging interface abstracting logging APIs. 
+	/// A simple logging interface abstracting logging APIs. Inspired by log4net.
 	/// </summary>
 	public interface ILog
 	{

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILoggerFactoryAdapter.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILoggerFactoryAdapter.cs?view=diff&rev=474141&r1=474140&r2=474141
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILoggerFactoryAdapter.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILoggerFactoryAdapter.cs Sun Nov 12 20:43:37 2006
@@ -2,7 +2,7 @@
 #region Apache Notice
 /*****************************************************************************
  * $Header: $
- * $Revision: $
+ * $Revision$
  * $Date$
  * 
  * iBATIS.NET Data Mapper
@@ -25,25 +25,38 @@
 #endregion
 
 using System;
+using System.Collections.Specialized;
+using IBatisNet.Common.Logging.Impl;
 
 namespace IBatisNet.Common.Logging
 {
 	/// <summary>
-	/// LoggerFactoryAdapter interface is used internally by LogManager
-	/// Only developers wishing to write new SLF4J adapters need to
-	/// worry about this interface.
+	/// Defines the members that logging implementations must implement.
 	/// </summary>
+	/// <remarks>
+	/// Classes that implement this interface may optional implement a constructor that accepts 
+	/// a <see cref="NameValueCollection" /> which will contain zero or more user supplied configuration
+	/// properties.
+	/// <para>
+	/// The IBatisNet.Common assembly ships with the following built-in <see cref="ILoggerFactoryAdapter" /> implementations:
+	/// </para>
+	///	<list type="table">
+	///	<item><term><see cref="ConsoleOutLoggerFA" /></term><description>Writes output to Console.Out</description></item>
+	///	<item><term><see cref="TraceLoggerFA" /></term><description>Writes output to the System.Diagnostics.Trace sub-system</description></item>
+	///	<item><term><see cref="NoOpLoggerFA" /></term><description>Ignores all messages</description></item>
+	///	</list>
+	/// </remarks>
 	public interface ILoggerFactoryAdapter 
 	{
 		/// <summary>
-		/// Get a ILog instance by type 
+		/// Get a <see cref="ILog" /> instance by type.
 		/// </summary>
 		/// <param name="type"></param>
 		/// <returns></returns>
 		ILog GetLogger( Type type );
 
 		/// <summary>
-		/// Get a ILog instance by type name 
+		/// Get a <see cref="ILog" /> instance by name.
 		/// </summary>
 		/// <param name="name"></param>
 		/// <returns></returns>

Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/AbstractLogger.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/AbstractLogger.cs?view=auto&rev=474141
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/AbstractLogger.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/AbstractLogger.cs Sun Nov 12 20:43:37 2006
@@ -0,0 +1,207 @@
+using System;
+
+namespace IBatisNet.Common.Logging.Impl
+{
+	/// <summary>
+	/// Base class that implements the ILog interface.
+	/// </summary>
+	public abstract class AbstractLogger : ILog
+	{
+		/// <summary>
+		/// Concrete classes should override this method to perform the actual logging.
+		/// </summary>
+		/// <param name="logLevel"></param>
+		/// <param name="message"></param>
+		/// <param name="e"></param>
+		protected abstract void Write(LogLevel logLevel, object message, Exception e);
+
+		/// <summary>
+		/// Concrete classes should override this method to determine if a particular <see cref="LogLevel" />
+		/// is enabled.
+		/// </summary>
+		/// <param name="logLevel"></param>
+		/// <returns></returns>
+		protected abstract bool IsLevelEnabled(LogLevel logLevel);
+		
+		#region ILog Members
+
+		/// <summary>
+		/// Log a <see cref="LogLevel.Debug" /> message.
+		/// </summary>
+		/// <param name="message">The message to log.</param>
+		public void Debug(object message)
+		{
+			Debug( message, null );
+		}
+
+		/// <summary>
+		/// Log a <see cref="LogLevel.Debug" /> message with an optional <see cref="Exception" />.
+		/// </summary>
+		/// <param name="message">The message to log.</param>
+		/// <param name="e">
+		/// The	<see cref="Exception" /> associated with the message. If there isn't any
+		/// <see cref="Exception" /> associated with the message, pass <see langword="null" />.
+		/// </param>
+		public void Debug(object message, Exception e)
+		{
+			if ( IsLevelEnabled( LogLevel.Debug ) )
+			{
+				Write( LogLevel.Debug, message, e );	
+			}
+		}
+
+		/// <summary>
+		/// Log a <see cref="LogLevel.Error" /> message.
+		/// </summary>
+		/// <param name="message">The message to log.</param>
+		public void Error(object message)
+		{
+			Error( message, null );
+		}
+
+		/// <summary>
+		/// Log a <see cref="LogLevel.Error" /> message with an optional <see cref="Exception" />.
+		/// </summary>
+		/// <param name="message">The message to log.</param>
+		/// <param name="e">
+		/// The	<see cref="Exception" /> associated with the message. If there isn't any
+		/// <see cref="Exception" /> associated with the message, pass <see langword="null" />.
+		/// </param>
+		public void Error(object message, Exception e)
+		{
+			if ( IsLevelEnabled( LogLevel.Error ) )
+			{
+				Write( LogLevel.Error, message, e );	
+			}
+		}
+
+		/// <summary>
+		/// Log a <see cref="LogLevel.Fatal" /> message.
+		/// </summary>
+		/// <param name="message">The message to log.</param>
+		public void Fatal(object message)
+		{
+			Fatal( message, null );
+		}
+
+		/// <summary>
+		/// Log a <see cref="LogLevel.Fatal" /> message with an optional <see cref="Exception" />.
+		/// </summary>
+		/// <param name="message">The message to log.</param>
+		/// <param name="e">
+		/// The	<see cref="Exception" /> associated with the message. If there isn't any
+		/// <see cref="Exception" /> associated with the message, pass <see langword="null" />.
+		/// </param>
+		public void Fatal(object message, Exception e)
+		{
+			if ( IsLevelEnabled( LogLevel.Fatal ) )
+			{
+				Write( LogLevel.Fatal, message, e );
+			}
+		}
+
+		/// <summary>
+		/// Log a <see cref="LogLevel.Info" /> message.
+		/// </summary>
+		/// <param name="message">The message to log.</param>
+		public void Info(object message)
+		{
+			Info( message, null );
+		}
+
+		/// <summary>
+		/// Log a <see cref="LogLevel.Info" /> message with an optional <see cref="Exception" />.
+		/// </summary>
+		/// <param name="message">The message to log.</param>
+		/// <param name="e">
+		/// The	<see cref="Exception" /> associated with the message. If there isn't any
+		/// <see cref="Exception" /> associated with the message, pass <see langword="null" />.
+		/// </param>
+		public void Info(object message, Exception e)
+		{
+			if ( IsLevelEnabled( LogLevel.Info ) )
+			{
+				Write( LogLevel.Info, message, e );
+			}
+		}
+
+		/// <summary>
+		/// Log a <see cref="LogLevel.Warn" /> message.
+		/// </summary>
+		/// <param name="message">The message to log.</param>
+		public void Warn(object message)
+		{
+			Warn( message, null );
+		}
+
+		/// <summary>
+		/// Log a <see cref="LogLevel.Warn" /> message with an optional <see cref="Exception" />.
+		/// </summary>
+		/// <param name="message">The message to log.</param>
+		/// <param name="e">
+		/// The	<see cref="Exception" /> associated with the message. If there isn't any
+		/// <see cref="Exception" /> associated with the message, pass <see langword="null" />.
+		/// </param>
+		public void Warn(object message, Exception e)
+		{
+			if ( IsLevelEnabled( LogLevel.Warn ) )
+			{
+				Write( LogLevel.Warn, message, e );
+			}
+		}
+
+		/// <summary>
+		/// Returns <see langword="true" /> if the current <see cref="LogLevel" /> is greater than or
+		/// equal to <see cref="LogLevel.Debug" />. If it is, all messages will be sent to <see cref="Console.Out" />.
+		/// </summary>
+		public bool IsDebugEnabled
+		{
+			get { return IsLevelEnabled( LogLevel.Debug ); }
+		}
+
+		/// <summary>
+		/// Returns <see langword="true" /> if the current <see cref="LogLevel" /> is greater than or
+		/// equal to <see cref="LogLevel.Error" />. If it is, only messages with a <see cref="LogLevel" /> of
+		/// <see cref="LogLevel.Error" /> and <see cref="LogLevel.Fatal" /> will be sent to <see cref="Console.Out" />.
+		/// </summary>
+		public bool IsErrorEnabled
+		{
+			get { return IsLevelEnabled( LogLevel.Error ); }
+		}
+
+		/// <summary>
+		/// Returns <see langword="true" /> if the current <see cref="LogLevel" /> is greater than or
+		/// equal to <see cref="LogLevel.Fatal" />. If it is, only messages with a <see cref="LogLevel" /> of
+		/// <see cref="LogLevel.Fatal" /> will be sent to <see cref="Console.Out" />.
+		/// </summary>
+		public bool IsFatalEnabled
+		{
+			get { return IsLevelEnabled( LogLevel.Fatal ); }
+		}
+
+		/// <summary>
+		/// Returns <see langword="true" /> if the current <see cref="LogLevel" /> is greater than or
+		/// equal to <see cref="LogLevel.Info" />. If it is, only messages with a <see cref="LogLevel" /> of
+		/// <see cref="LogLevel.Info" />, <see cref="LogLevel.Warn" />, <see cref="LogLevel.Error" />, and 
+		/// <see cref="LogLevel.Fatal" /> will be sent to <see cref="Console.Out" />.
+		/// </summary>
+		public bool IsInfoEnabled
+		{
+			get { return IsLevelEnabled( LogLevel.Info ); }
+		}
+
+
+		/// <summary>
+		/// Returns <see langword="true" /> if the current <see cref="LogLevel" /> is greater than or
+		/// equal to <see cref="LogLevel.Warn" />. If it is, only messages with a <see cref="LogLevel" /> of
+		/// <see cref="LogLevel.Warn" />, <see cref="LogLevel.Error" />, and <see cref="LogLevel.Fatal" /> 
+		/// will be sent to <see cref="Console.Out" />.
+		/// </summary>
+		public bool IsWarnEnabled
+		{
+			get { return IsLevelEnabled( LogLevel.Warn ); }
+		}
+
+		#endregion
+	}
+}

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLogger.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLogger.cs?view=diff&rev=474141&r1=474140&r2=474141
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLogger.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLogger.cs Sun Nov 12 20:43:37 2006
@@ -33,7 +33,7 @@
 	/// <summary>
 	/// Sends log messages to <see cref="Console.Out" />.
 	/// </summary>
-	public class ConsoleOutLogger : ILog
+	public class ConsoleOutLogger : AbstractLogger
 	{
 		private bool _showDateTime = false;
 		private bool _showLogName = false;
@@ -72,7 +72,7 @@
 		/// <param name="level">The <see cref="LogLevel" /> of the message.</param>
 		/// <param name="message">The log message.</param>
 		/// <param name="e">An optional <see cref="Exception" /> associated with the message.</param>
-		private void Write( LogLevel level, object message, Exception e )
+		protected override void Write( LogLevel level, object message, Exception e )
 		{
 			// Use a StringBuilder for better performance
 			StringBuilder sb = new StringBuilder();
@@ -117,7 +117,7 @@
 		/// </summary>
 		/// <param name="level"></param>
 		/// <returns></returns>
-		private bool IsLevelEnabled( LogLevel level )
+		protected override bool IsLevelEnabled( LogLevel level )
 		{
 			int iLevel = (int)level;
 			int iCurrentLogLevel = (int)_currentLogLevel;
@@ -125,186 +125,5 @@
 			// return iLevel.CompareTo(iCurrentLogLevel); better ???
 			return ( iLevel >= iCurrentLogLevel );
 		}
-
-		#region ILog Members
-
-		/// <summary>
-		/// Log a <see cref="LogLevel.Debug" /> message.
-		/// </summary>
-		/// <param name="message">The message to log.</param>
-		public void Debug(object message)
-		{
-			Debug( message, null );
-		}
-
-		/// <summary>
-		/// Log a <see cref="LogLevel.Debug" /> message with an optional <see cref="Exception" />.
-		/// </summary>
-		/// <param name="message">The message to log.</param>
-		/// <param name="e">
-		/// The	<see cref="Exception" /> associated with the message. If there isn't any
-		/// <see cref="Exception" /> associated with the message, pass <see langword="null" />.
-		/// </param>
-		public void Debug(object message, Exception e)
-		{
-			if ( IsLevelEnabled( LogLevel.Debug ) )
-			{
-				Write( LogLevel.Debug, message, e );	
-			}
-		}
-
-		/// <summary>
-		/// Log a <see cref="LogLevel.Error" /> message.
-		/// </summary>
-		/// <param name="message">The message to log.</param>
-		public void Error(object message)
-		{
-			Error( message, null );
-		}
-
-		/// <summary>
-		/// Log a <see cref="LogLevel.Error" /> message with an optional <see cref="Exception" />.
-		/// </summary>
-		/// <param name="message">The message to log.</param>
-		/// <param name="e">
-		/// The	<see cref="Exception" /> associated with the message. If there isn't any
-		/// <see cref="Exception" /> associated with the message, pass <see langword="null" />.
-		/// </param>
-		public void Error(object message, Exception e)
-		{
-			if ( IsLevelEnabled( LogLevel.Error ) )
-			{
-				Write( LogLevel.Error, message, e );	
-			}
-		}
-
-		/// <summary>
-		/// Log a <see cref="LogLevel.Fatal" /> message.
-		/// </summary>
-		/// <param name="message">The message to log.</param>
-		public void Fatal(object message)
-		{
-			Fatal( message, null );
-		}
-
-		/// <summary>
-		/// Log a <see cref="LogLevel.Fatal" /> message with an optional <see cref="Exception" />.
-		/// </summary>
-		/// <param name="message">The message to log.</param>
-		/// <param name="e">
-		/// The	<see cref="Exception" /> associated with the message. If there isn't any
-		/// <see cref="Exception" /> associated with the message, pass <see langword="null" />.
-		/// </param>
-		public void Fatal(object message, Exception e)
-		{
-			if ( IsLevelEnabled( LogLevel.Fatal ) )
-			{
-				Write( LogLevel.Fatal, message, e );
-			}
-		}
-
-		/// <summary>
-		/// Log a <see cref="LogLevel.Info" /> message.
-		/// </summary>
-		/// <param name="message">The message to log.</param>
-		public void Info(object message)
-		{
-			Info( message, null );
-		}
-
-		/// <summary>
-		/// Log a <see cref="LogLevel.Info" /> message with an optional <see cref="Exception" />.
-		/// </summary>
-		/// <param name="message">The message to log.</param>
-		/// <param name="e">
-		/// The	<see cref="Exception" /> associated with the message. If there isn't any
-		/// <see cref="Exception" /> associated with the message, pass <see langword="null" />.
-		/// </param>
-		public void Info(object message, Exception e)
-		{
-			if ( IsLevelEnabled( LogLevel.Info ) )
-			{
-				Write( LogLevel.Info, message, e );
-			}
-		}
-
-		/// <summary>
-		/// Log a <see cref="LogLevel.Warn" /> message.
-		/// </summary>
-		/// <param name="message">The message to log.</param>
-		public void Warn(object message)
-		{
-			Warn( message, null );
-		}
-
-		/// <summary>
-		/// Log a <see cref="LogLevel.Warn" /> message with an optional <see cref="Exception" />.
-		/// </summary>
-		/// <param name="message">The message to log.</param>
-		/// <param name="e">
-		/// The	<see cref="Exception" /> associated with the message. If there isn't any
-		/// <see cref="Exception" /> associated with the message, pass <see langword="null" />.
-		/// </param>
-		public void Warn(object message, Exception e)
-		{
-			if ( IsLevelEnabled( LogLevel.Warn ) )
-			{
-				Write( LogLevel.Warn, message, e );
-			}
-		}
-
-		/// <summary>
-		/// Returns <see langword="true" /> if the current <see cref="LogLevel" /> is greater than or
-		/// equal to <see cref="LogLevel.Debug" />. If it is, all messages will be sent to <see cref="Console.Out" />.
-		/// </summary>
-		public bool IsDebugEnabled
-		{
-			get { return IsLevelEnabled( LogLevel.Debug ); }
-		}
-
-		/// <summary>
-		/// Returns <see langword="true" /> if the current <see cref="LogLevel" /> is greater than or
-		/// equal to <see cref="LogLevel.Error" />. If it is, only messages with a <see cref="LogLevel" /> of
-		/// <see cref="LogLevel.Error" /> and <see cref="LogLevel.Fatal" /> will be sent to <see cref="Console.Out" />.
-		/// </summary>
-		public bool IsErrorEnabled
-		{
-			get { return IsLevelEnabled( LogLevel.Error ); }
-		}
-
-		/// <summary>
-		/// Returns <see langword="true" /> if the current <see cref="LogLevel" /> is greater than or
-		/// equal to <see cref="LogLevel.Fatal" />. If it is, only messages with a <see cref="LogLevel" /> of
-		/// <see cref="LogLevel.Fatal" /> will be sent to <see cref="Console.Out" />.
-		/// </summary>
-		public bool IsFatalEnabled
-		{
-			get { return IsLevelEnabled( LogLevel.Fatal ); }
-		}
-
-		/// <summary>
-		/// Returns <see langword="true" /> if the current <see cref="LogLevel" /> is greater than or
-		/// equal to <see cref="LogLevel.Info" />. If it is, only messages with a <see cref="LogLevel" /> of
-		/// <see cref="LogLevel.Info" />, <see cref="LogLevel.Warn" />, <see cref="LogLevel.Error" />, and 
-		/// <see cref="LogLevel.Fatal" /> will be sent to <see cref="Console.Out" />.
-		/// </summary>
-		public bool IsInfoEnabled
-		{
-			get { return IsLevelEnabled( LogLevel.Info ); }
-		}
-
-
-		/// <summary>
-		/// Returns <see langword="true" /> if the current <see cref="LogLevel" /> is greater than or
-		/// equal to <see cref="LogLevel.Warn" />. If it is, only messages with a <see cref="LogLevel" /> of
-		/// <see cref="LogLevel.Warn" />, <see cref="LogLevel.Error" />, and <see cref="LogLevel.Fatal" /> 
-		/// will be sent to <see cref="Console.Out" />.
-		/// </summary>
-		public bool IsWarnEnabled
-		{
-			get { return IsLevelEnabled( LogLevel.Warn ); }
-		}
-
-		#endregion
 	}
 }

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLoggerFA.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLoggerFA.cs?view=diff&rev=474141&r1=474140&r2=474141
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLoggerFA.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLoggerFA.cs Sun Nov 12 20:43:37 2006
@@ -25,32 +25,36 @@
 #endregion
 
 using System;
-using System.Collections;
 using System.Collections.Specialized;
 
 namespace IBatisNet.Common.Logging.Impl
 {
 	/// <summary>
-	/// Summary description for NoOpLoggerFA.
+	/// Factory for creating "no operation" loggers that do nothing and whose Is*Enabled properties always 
+	/// return false.
 	/// </summary>
+	/// <remarks>
+	/// This factory creates a single instance of <see cref="NoOpLogger" /> and always returns that 
+	/// instance whenever an <see cref="ILog" /> instance is requested.
+	/// </remarks>
 	public sealed class NoOpLoggerFA : ILoggerFactoryAdapter
 	{
-		private ILog _nopLogger = null;
+		private ILog _nopLogger = new NoOpLogger();
 
-        /// <summary>
-        /// Constructor
-        /// </summary>
-        public NoOpLoggerFA()
-        {
-            _nopLogger = new NoOpLogger();
-        }
+		/// <summary>
+		/// Constructor
+		/// </summary>
+		public NoOpLoggerFA()
+		{
+			// empty
+		}
 
 		/// <summary>
 		/// Constructor
 		/// </summary>
-        public NoOpLoggerFA(NameValueCollection properties)
+		public NoOpLoggerFA(NameValueCollection properties)
 		{
-			_nopLogger = new NoOpLogger();
+			// empty
 		}
 
 		#region ILoggerFactoryAdapter Members
@@ -70,7 +74,7 @@
 		/// </summary>
 		/// <param name="name"></param>
 		/// <returns></returns>
-		ILog Logging.ILoggerFactoryAdapter.GetLogger(string name)
+		ILog ILoggerFactoryAdapter.GetLogger(string name)
 		{
 			return _nopLogger;
 

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLogger.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLogger.cs?view=diff&rev=474141&r1=474140&r2=474141
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLogger.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLogger.cs Sun Nov 12 20:43:37 2006
@@ -2,7 +2,7 @@
 #region Apache Notice
 /*****************************************************************************
  * $Header: $
- * $Revision: $
+ * $Revision$
  * $Date$
  * 
  * iBATIS.NET Data Mapper
@@ -25,15 +25,16 @@
 #endregion
 
 using System;
+using System.Diagnostics;
 using System.Globalization;
 using System.Text;
 
 namespace IBatisNet.Common.Logging.Impl
 {
 	/// <summary>
-	/// Logger sending everything to the trace output stream.
+	/// Logger that sends output to the <see cref="System.Diagnostics.Trace" /> sub-system.
 	/// </summary>
-	public class TraceLogger: ILog
+	public class TraceLogger: AbstractLogger
 	{
 		private bool _showDateTime = false;
 		private bool _showLogName = false;
@@ -43,15 +44,18 @@
 		private bool _hasDateTimeFormat = false;
 
 		/// <summary>
-		/// 
+		/// Creates a new instance of the TraceLogger.
 		/// </summary>
-		/// <param name="logName"></param>
-		/// <param name="logLevel"></param>
+		/// <param name="logName">The name for this instance (usually the fully qualified class name).</param>
+		/// <param name="logLevel">
+		///	The logging threshold. Log messages created with a <see cref="LogLevel" />
+		/// beneath this threshold will not be logged.
+		/// </param>
 		/// <param name="showDateTime">Include the current time in the log message </param>
 		/// <param name="showLogName">Include the instance name in the log message</param>
 		/// <param name="dateTimeFormat">The date and time format to use in the log message </param>
 		public TraceLogger( string logName, LogLevel logLevel
-			, bool showDateTime, bool showLogName, string dateTimeFormat)
+		                    , bool showDateTime, bool showLogName, string dateTimeFormat)
 		{
 			_logName = logName;
 			_currentLogLevel = logLevel;
@@ -66,19 +70,16 @@
 		}
 
 		/// <summary>
-		/// Do the actual logging.
-		/// This method assembles the message and write
-		/// the content of the message accumulated in the specified
-		/// StringBuffer to the appropriate output destination. The
-		/// default implementation writes to System.Console.Error.<p/>
+		/// Responsible for assembling and writing the log message to the tracing sub-system.
 		/// </summary>
 		/// <param name="level"></param>
 		/// <param name="message"></param>
 		/// <param name="e"></param>
-		private void Write( LogLevel level, object message, Exception e )
+		protected override void Write( LogLevel level, object message, Exception e )
 		{
 			// Use a StringBuilder for better performance
 			StringBuilder sb = new StringBuilder();
+
 			// Append date-time if so configured
 			if ( _showDateTime )
 			{
@@ -92,7 +93,8 @@
 				}
 				
 				sb.Append( " " );
-			}	
+			}
+	
 			// Append a readable representation of the log level
 			sb.Append( string.Format( "[{0}]", level.ToString().ToUpper() ).PadRight( 8 ) );
 
@@ -108,11 +110,11 @@
 			// Append stack trace if not null
 			if ( e != null )
 			{
-				sb.AppendFormat( "\n{0}", e.ToString() );
+				sb.Append(Environment.NewLine).Append(e.ToString());
 			}
 
 			// Print to the appropriate destination
-			System.Diagnostics.Trace.WriteLine( sb.ToString() );			
+			Trace.WriteLine( sb.ToString() );			
 		}
 
 		/// <summary>
@@ -120,168 +122,13 @@
 		/// </summary>
 		/// <param name="level"></param>
 		/// <returns></returns>
-		private bool IsLevelEnabled( LogLevel level )
+		protected override bool IsLevelEnabled( LogLevel level )
 		{
 			int iLevel = (int)level;
 			int iCurrentLogLevel = (int)_currentLogLevel;
 
 			return ( iLevel >= iCurrentLogLevel );
 		}
-
-		#region ILog Members
-
-		/// <summary>
-		/// Log a debug message.
-		/// </summary>
-		/// <param name="message"></param>
-		public void Debug(object message)
-		{
-			Debug( message, null );
-		}
-
-		/// <summary>
-		/// 
-		/// </summary>
-		/// <param name="message"></param>
-		/// <param name="e"></param>
-		public void Debug(object message, Exception e)
-		{
-			if ( IsLevelEnabled( LogLevel.Debug ) )
-			{
-				Write( LogLevel.Debug, message, e );	
-			}
-		}
-
-		/// <summary>
-		/// 
-		/// </summary>
-		/// <param name="message"></param>
-		public void Error(object message)
-		{
-			Error( message, null );
-		}
-
-		/// <summary>
-		/// 
-		/// </summary>
-		/// <param name="message"></param>
-		/// <param name="e"></param>
-		public void Error(object message, Exception e)
-		{
-			if ( IsLevelEnabled( LogLevel.Error ) )
-			{
-				Write( LogLevel.Error, message, e );	
-			}
-		}
-
-		/// <summary>
-		/// 
-		/// </summary>
-		/// <param name="message"></param>
-		public void Fatal(object message)
-		{
-			Fatal( message, null );
-		}
-
-		/// <summary>
-		/// 
-		/// </summary>
-		/// <param name="message"></param>
-		/// <param name="e"></param>
-		public void Fatal(object message, Exception e)
-		{
-			if ( IsLevelEnabled( LogLevel.Fatal ) )
-			{
-				Write( LogLevel.Fatal, message, e );
-			}
-		}
-
-		/// <summary>
-		/// 
-		/// </summary>
-		/// <param name="message"></param>
-		public void Info(object message)
-		{
-			Info( message, null );
-		}
-
-		/// <summary>
-		/// 
-		/// </summary>
-		/// <param name="message"></param>
-		/// <param name="e"></param>
-		public void Info(object message, Exception e)
-		{
-			if ( IsLevelEnabled( LogLevel.Info ) )
-			{
-				Write( LogLevel.Info, message, e );
-			}
-		}
-
-
-		/// <summary>
-		/// 
-		/// </summary>
-		/// <param name="message"></param>
-		public void Warn(object message)
-		{
-			Warn( message, null );
-		}
-
-		/// <summary>
-		/// 
-		/// </summary>
-		/// <param name="message"></param>
-		/// <param name="e"></param>
-		public void Warn(object message, Exception e)
-		{
-			if ( IsLevelEnabled( LogLevel.Warn ) )
-			{
-				Write( LogLevel.Warn, message, e );
-			}
-		}
-
-		/// <summary>
-		/// 
-		/// </summary>
-		public bool IsDebugEnabled
-		{
-			get { return IsLevelEnabled( LogLevel.Debug ); }
-		}
-
-		/// <summary>
-		/// 
-		/// </summary>
-		public bool IsErrorEnabled
-		{
-			get { return IsLevelEnabled( LogLevel.Error ); }
-		}
-
-		/// <summary>
-		/// 
-		/// </summary>
-		public bool IsFatalEnabled
-		{
-			get { return IsLevelEnabled( LogLevel.Fatal ); }
-		}
-
-		/// <summary>
-		/// 
-		/// </summary>
-		public bool IsInfoEnabled
-		{
-			get { return IsLevelEnabled( LogLevel.Info ); }
-		}
-
-		/// <summary>
-		/// 
-		/// </summary>
-		public bool IsWarnEnabled
-		{
-			get { return IsLevelEnabled( LogLevel.Warn ); }
-		}
-
-		#endregion
 	}
 }
 

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/LogManager.cs
URL: http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/LogManager.cs?view=diff&rev=474141&r1=474140&r2=474141
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/LogManager.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/LogManager.cs Sun Nov 12 20:43:37 2006
@@ -31,11 +31,8 @@
 namespace IBatisNet.Common.Logging
 {
 	/// <summary>
-	/// The LogManager can produce ILogFactory for various logging APIs,
-	/// most notably for log4net. 
-	/// Other implemenations such as
-	/// * SimpleLogger
-	/// * NoOpLogger are also supported.
+	/// Uses the specified <see cref="ILoggerFactoryAdapter" /> to create <see cref="ILog" /> instances
+	/// that are used to log messages. Inspired by log4net.
 	/// </summary>
 	public sealed class LogManager
 	{
@@ -53,11 +50,21 @@
 		{ }
 
 
-        /// <summary>
-        /// Gets or sets the adapter.
-        /// </summary>
-        /// <value>The adapter.</value>
-        public static ILoggerFactoryAdapter Adapter
+		/// <summary>
+		/// Gets or sets the adapter.
+		/// </summary>
+		/// <remarks>
+		/// <para>
+		/// The IBatisNet.Common assembly ships with the following built-in <see cref="ILoggerFactoryAdapter" /> implementations:
+		/// </para>
+		///	<list type="table">
+		///	<item><term><see cref="ConsoleOutLoggerFA" /></term><description>Writes output to Console.Out</description></item>
+		///	<item><term><see cref="TraceLoggerFA" /></term><description>Writes output to the System.Diagnostics.Trace sub-system</description></item>
+		///	<item><term><see cref="NoOpLoggerFA" /></term><description>Ignores all messages</description></item>
+		///	</list>
+		/// </remarks>
+		/// <value>The adapter.</value>
+		public static ILoggerFactoryAdapter Adapter
 		{
 			get
 			{
@@ -73,7 +80,7 @@
 				}
 				return _adapter;				
 			}
-		    set
+			set
 			{
 				lock (_loadLock)
 				{
@@ -84,32 +91,32 @@
 		}
 
 
-        /// <summary>
-        /// Gets the logger.
-        /// </summary>
-        /// <param name="type">The type.</param>
-        /// <returns></returns>
+		/// <summary>
+		/// Gets the logger.
+		/// </summary>
+		/// <param name="type">The type.</param>
+		/// <returns></returns>
 		public static ILog GetLogger( Type type )
 		{
 			return Adapter.GetLogger( type );
 		}
 
 
-        /// <summary>
-        /// Gets the logger.
-        /// </summary>
-        /// <param name="name">The name.</param>
-        /// <returns></returns>
+		/// <summary>
+		/// Gets the logger.
+		/// </summary>
+		/// <param name="name">The name.</param>
+		/// <returns></returns>
 		public static ILog GetLogger( string name )
 		{
 			return Adapter.GetLogger(name);
 		}
 
 
-        /// <summary>
-        /// Builds the logger factory adapter.
-        /// </summary>
-        /// <returns></returns>
+		/// <summary>
+		/// Builds the logger factory adapter.
+		/// </summary>
+		/// <returns></returns>
 		private static ILoggerFactoryAdapter BuildLoggerFactoryAdapter()
 		{
 			LogSetting setting = null;
@@ -118,7 +125,7 @@
 #if dotnet2
                 setting = (LogSetting)ConfigurationManager.GetSection(IBATIS_SECTION_LOGGING );
 #else
- 				setting = (LogSetting)ConfigurationSettings.GetConfig( IBATIS_SECTION_LOGGING );
+				setting = (LogSetting)ConfigurationSettings.GetConfig( IBATIS_SECTION_LOGGING );
 #endif
 			}
 			catch ( Exception ex )
@@ -133,7 +140,7 @@
 			{
 				ILoggerFactoryAdapter defaultFactory = BuildDefaultLoggerFactoryAdapter();
 				ILog log = defaultFactory.GetLogger( typeof(LogManager) );
-				log.Warn( "Type " + setting.FactoryAdapterType.FullName + " does not implement ILogFactory. Using default logger" );
+				log.Warn( "Type " + setting.FactoryAdapterType.FullName + " does not implement ILoggerFactoryAdapter. Using default logger" );
 				return defaultFactory;
 			}
 
@@ -176,7 +183,7 @@
 			{
 				ILoggerFactoryAdapter defaultFactory = BuildDefaultLoggerFactoryAdapter();
 				ILog log = defaultFactory.GetLogger( typeof(LogManager) );
-				log.Warn( "Unable to read configuration IBatisNet/logging. Using default logger (ConsoleLogger)." );
+				log.Warn( "Unable to read configuration IBatisNet/logging. Using default logger." );
 				return defaultFactory;
 			}
 
@@ -184,13 +191,13 @@
 		}
 
 
-        /// <summary>
-        /// Builds the default logger factory adapter.
-        /// </summary>
-        /// <returns></returns>
+		/// <summary>
+		/// Builds the default logger factory adapter.
+		/// </summary>
+		/// <returns></returns>
 		private static ILoggerFactoryAdapter BuildDefaultLoggerFactoryAdapter()
 		{
-            return new NoOpLoggerFA();
+			return new NoOpLoggerFA();
 		}
 	}
 }