Author: gbayon
Date: Fri Jul  1 11:34:01 2005
New Revision: 208781

URL: http://svn.apache.org/viewcvs?rev=208781&view=rev
Log:
- Renamed SimpleLogger to ConsoleOutLogger
- Added TraceLogger

Added:
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLogger.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLoggerFA.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLogger.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLoggerFA.cs
Removed:
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/SimpleLogger.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/SimpleLoggerFA.cs
Modified:
    
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Logging/LogTest.cs
    
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Transaction/BaseTest.cs
    
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/bin/Debug/IBatisNet.Common.Test.dll.config
    ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILog.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLogger.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLoggerFA.cs
    ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/LogManager.cs

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Logging/LogTest.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Logging/LogTest.cs?rev=208781&r1=208780&r2=208781&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Logging/LogTest.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Logging/LogTest.cs
 Fri Jul  1 11:34:01 2005
@@ -52,12 +52,6 @@
                }
 
                [Test]
-               public void LogTrace()
-               {
-                       _log.Trace("test LogTrace");
-               }
-
-               [Test]
                public void LogWarn()
                {
                        _log.Warn("test LogWarn");

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Transaction/BaseTest.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Transaction/BaseTest.cs?rev=208781&r1=208780&r2=208781&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Transaction/BaseTest.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Transaction/BaseTest.cs
 Fri Jul  1 11:34:01 2005
@@ -4,7 +4,7 @@
 using System.IO;
 using System.Reflection;
 using System.Configuration;
-
+using IBatisNet.DataMapper.Configuration;
 using log4net;
 
 using NUnit.Framework;
@@ -63,7 +63,8 @@
                        //DateTime start = DateTime.Now;
 
                        ConfigureHandler handler = new ConfigureHandler( 
Configure );
-                       sqlMap = SqlMapper.ConfigureAndWatch( "sqlmap"+ "_" +  
ConfigurationSettings.AppSettings["database"] + "_"
+                       DomSqlMapBuilder builder = new DomSqlMapBuilder();
+                       sqlMap = builder.ConfigureAndWatch( "sqlmap"+ "_" +  
ConfigurationSettings.AppSettings["database"] + "_"
                                + 
ConfigurationSettings.AppSettings["providerType"] +".config", handler );
 
 //                     string loadTime = 
DateTime.Now.Subtract(start).ToString();

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/bin/Debug/IBatisNet.Common.Test.dll.config
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/bin/Debug/IBatisNet.Common.Test.dll.config?rev=208781&r1=208780&r2=208781&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/bin/Debug/IBatisNet.Common.Test.dll.config
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/bin/Debug/IBatisNet.Common.Test.dll.config
 Fri Jul  1 11:34:01 2005
@@ -25,16 +25,16 @@
        
        <iBATIS>
                <logging>
-                       <!--<logFactoryAdapter 
type="IBatisNet.Common.Logging.Impl.SimpleLoggerFA, IBatisNet.Common">
-                               <arg property="showLogName" value="true" />
-                               <arg property="showDataTime" value="true" />
-                               <arg property="level" value="ALL" />
-                               <arg property="dateTimeFormat" 
value="yyyy/MM/dd HH:mm:ss:SSS" />
-                       </logFactoryAdapter>            -->     
+                       <logFactoryAdapter 
type="IBatisNet.Common.Logging.Impl.ConsoleOutLoggerFA, IBatisNet.Common">
+                               <arg key="showLogName" value="true" />
+                               <arg key="showDataTime" value="true" />
+                               <arg key="level" value="ALL" />
+                               <arg key="dateTimeFormat" value="yyyy/MM/dd 
HH:mm:ss:SSS" />
+                       </logFactoryAdapter>            
                        
-                       <logFactoryAdapter 
type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common">
+                       <!--<logFactoryAdapter 
type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common">
                                <arg key="configType" value="inline" />
-                       </logFactoryAdapter>
+                       </logFactoryAdapter>--> 
                </logging>
        </iBATIS>
        

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj?rev=208781&r1=208780&r2=208781&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/IBatisNet.Common.csproj Fri Jul  1 
11:34:01 2005
@@ -194,6 +194,16 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "Logging\Impl\ConsoleOutLogger.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "Logging\Impl\ConsoleOutLoggerFA.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "Logging\Impl\Log4NetLogger.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
@@ -214,12 +224,12 @@
                     BuildAction = "Compile"
                 />
                 <File
-                    RelPath = "Logging\Impl\SimpleLogger.cs"
+                    RelPath = "Logging\Impl\TraceLogger.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
                 <File
-                    RelPath = "Logging\Impl\SimpleLoggerFA.cs"
+                    RelPath = "Logging\Impl\TraceLoggerFA.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILog.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILog.cs?rev=208781&r1=208780&r2=208781&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILog.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/ILog.cs Fri Jul  1 11:34:01 
2005
@@ -40,31 +40,27 @@
                /// <summary>
                /// 
                /// </summary>
-               Trace = 1,
+               Debug = 1,
                /// <summary>
                /// 
                /// </summary>
-               Debug = 2,
+               Info  = 2,
                /// <summary>
                /// 
                /// </summary>
-               Info  = 3,
+               Warn  = 3,
                /// <summary>
                /// 
                /// </summary>
-               Warn  = 4,
+               Error = 4,
                /// <summary>
                /// 
                /// </summary>
-               Error = 5,
+               Fatal = 5,
                /// <summary>
                /// 
                /// </summary>
-               Fatal = 6,
-               /// <summary>
-               /// 
-               /// </summary>
-               Off  = 7,
+               Off  = 6,
        }
 
        /// <summary>
@@ -73,79 +69,157 @@
        public interface ILog
        {
                /// <summary>
-               /// 
+               /// Log a message object with the <see cref="LogLevel.Debug"/> 
level.
                /// </summary>
-               /// <param name="message"></param>
+               /// <param name="message">The message object to log.</param>
                void Debug( object message );
+
                /// <summary>
-               /// 
-               /// </summary>
-               /// <param name="message"></param>
-               /// <param name="e"></param>
-               void Debug( object message, Exception e );
+               /// Log a message object with the <see cref="LogLevel.Debug"/> 
level including
+               /// the stack trace of the <see cref="Exception"/> passed
+               /// as a parameter.
+               /// </summary>
+               /// <param name="message">The message object to log.</param>
+               /// <param name="exception">The exception to log, including its 
stack trace.</param>
+               void Debug( object message, Exception exception );
+
+//             /// <summary>
+//             /// Logs a formatted message string with the <see 
cref="LogLevel.Debug"/> level.
+//             /// </summary>
+//             /// <param name="format">A String containing zero or more 
format items</param>
+//             /// <param name="args">An Object array containing zero or more 
objects to format</param>
+//             void DebugFormat(string format, params object[] args); 
+//
+//             /// <summary>
+//             /// Logs a formatted message string with the <see 
cref="LogLevel.Debug"/> level.
+//             /// </summary>
+//             /// <param name="provider">An <see cref="IFormatProvider"/> 
that supplies culture-specific formatting information</param>
+//             /// <param name="format">A String containing zero or more 
format items</param>
+//             /// <param name="args">An Object array containing zero or more 
objects to format</param>
+//             void DebugFormat(IFormatProvider provider, string format, 
params object[] args);
 
                /// <summary>
-               /// 
+               /// Log a message object with the <see cref="LogLevel.Error"/> 
level.
                /// </summary>
-               /// <param name="message"></param>
+               /// <param name="message">The message object to log.</param>
                void Error( object message );
+
                /// <summary>
-               /// 
-               /// </summary>
-               /// <param name="message"></param>
-               /// <param name="e"></param>
-               void Error( object message, Exception e );
+               /// Log a message object with the <see cref="LogLevel.Error"/> 
level including
+               /// the stack trace of the <see cref="Exception"/> passed
+               /// as a parameter.
+               /// </summary>
+               /// <param name="message">The message object to log.</param>
+               /// <param name="exception">The exception to log, including its 
stack trace.</param>
+               void Error( object message, Exception exception );
+
+//             /// <summary>
+//             /// Logs a formatted message string with the <see 
cref="LogLevel.Error"/> level.
+//             /// </summary>
+//             /// <param name="format">A String containing zero or more 
format items</param>
+//             /// <param name="args">An Object array containing zero or more 
objects to format</param>
+//             void ErrorFormat(string format, params object[] args); 
+//
+//             /// <summary>
+//             /// Logs a formatted message string with the <see 
cref="LogLevel.Error"/> level.
+//             /// </summary>
+//             /// <param name="provider">An <see cref="IFormatProvider"/> 
that supplies culture-specific formatting information</param>
+//             /// <param name="format">A String containing zero or more 
format items</param>
+//             /// <param name="args">An Object array containing zero or more 
objects to format</param>
+//             void ErrorFormat(IFormatProvider provider, string format, 
params object[] args);
 
                /// <summary>
-               /// 
+               /// Log a message object with the <see cref="LogLevel.Fatal"/> 
level.
                /// </summary>
-               /// <param name="message"></param>
+               /// <param name="message">The message object to log.</param>
                void Fatal( object message );
+
                /// <summary>
-               /// 
-               /// </summary>
-               /// <param name="message"></param>
-               /// <param name="e"></param>
-               void Fatal( object message, Exception e );
+               /// Log a message object with the <see cref="LogLevel.Fatal"/> 
level including
+               /// the stack trace of the <see cref="Exception"/> passed
+               /// as a parameter.
+               /// </summary>
+               /// <param name="message">The message object to log.</param>
+               /// <param name="exception">The exception to log, including its 
stack trace.</param>
+               void Fatal( object message, Exception exception );
+
+//             /// <summary>
+//             /// Logs a formatted message string with the <see 
cref="LogLevel.Fatal"/> level.
+//             /// </summary>
+//             /// <param name="format">A String containing zero or more 
format items</param>
+//             /// <param name="args">An Object array containing zero or more 
objects to format</param>
+//             void FatalFormat(string format, params object[] args); 
+//
+//             /// <summary>
+//             /// Logs a formatted message string with the <see 
cref="LogLevel.Fatal"/> level.
+//             /// </summary>
+//             /// <param name="provider">An <see cref="IFormatProvider"/> 
that supplies culture-specific formatting information</param>
+//             /// <param name="format">A String containing zero or more 
format items</param>
+//             /// <param name="args">An Object array containing zero or more 
objects to format</param>
+//             void FatalFormat(IFormatProvider provider, string format, 
params object[] args);
 
                /// <summary>
-               /// 
+               /// Log a message object with the <see cref="LogLevel.Info"/> 
level.
                /// </summary>
-               /// <param name="message"></param>
+               /// <param name="message">The message object to log.</param>
                void Info( object message );
-               /// <summary>
-               /// 
-               /// </summary>
-               /// <param name="message"></param>
-               /// <param name="e"></param>
-               void Info( object message, Exception e );
 
                /// <summary>
-               /// 
-               /// </summary>
-               /// <param name="message"></param>
-               void Trace( object message );
-               /// <summary>
-               /// 
-               /// </summary>
-               /// <param name="message"></param>
-               /// <param name="e"></param>
-               void Trace( object message, Exception e );
+               /// Log a message object with the <see cref="LogLevel.Info"/> 
level including
+               /// the stack trace of the <see cref="Exception"/> passed
+               /// as a parameter.
+               /// </summary>
+               /// <param name="message">The message object to log.</param>
+               /// <param name="exception">The exception to log, including its 
stack trace.</param>
+               void Info( object message, Exception exception );
+
+//             /// <summary>
+//             /// Logs a formatted message string with the <see 
cref="LogLevel.Info"/> level.
+//             /// </summary>
+//             /// <param name="format">A String containing zero or more 
format items</param>
+//             /// <param name="args">An Object array containing zero or more 
objects to format</param>
+//             void InfoFormat(string format, params object[] args); 
+//
+//             /// <summary>
+//             /// Logs a formatted message string with the <see 
cref="LogLevel.Info"/> level.
+//             /// </summary>
+//             /// <param name="provider">An <see cref="IFormatProvider"/> 
that supplies culture-specific formatting information</param>
+//             /// <param name="format">A String containing zero or more 
format items</param>
+//             /// <param name="args">An Object array containing zero or more 
objects to format</param>
+//             void InfoFormat(IFormatProvider provider, string format, params 
object[] args);
 
                /// <summary>
-               /// 
+               /// Log a message object with the <see cref="LogLevel.Warn"/> 
level.
                /// </summary>
-               /// <param name="message"></param>
+               /// <param name="message">The message object to log.</param>
                void Warn( object message );
+
                /// <summary>
-               /// 
-               /// </summary>
-               /// <param name="message"></param>
-               /// <param name="e"></param>
-               void Warn( object message, Exception e );
+               /// Log a message object with the <see cref="LogLevel.Warn"/> 
level including
+               /// the stack trace of the <see cref="Exception"/> passed
+               /// as a parameter.
+               /// </summary>
+               /// <param name="message">The message object to log.</param>
+               /// <param name="exception">The exception to log, including its 
stack trace.</param>
+               void Warn( object message, Exception exception );
+
+//             /// <summary>
+//             /// Logs a formatted message string with the <see 
cref="LogLevel.Warn"/> level.
+//             /// </summary>
+//             /// <param name="format">A String containing zero or more 
format items</param>
+//             /// <param name="args">An Object array containing zero or more 
objects to format</param>
+//             void WarnFormat(string format, params object[] args); 
+//
+//             /// <summary>
+//             /// Logs a formatted message string with the <see 
cref="LogLevel.Warn"/> level.
+//             /// </summary>
+//             /// <param name="provider">An <see cref="IFormatProvider"/> 
that supplies culture-specific formatting information</param>
+//             /// <param name="format">A String containing zero or more 
format items</param>
+//             /// <param name="args">An Object array containing zero or more 
objects to format</param>
+//             void WarnFormat(IFormatProvider provider, string format, params 
object[] args);
 
                /// <summary>
-               /// 
+               /// Checks if this logger is enabled for the <see 
cref="LogLevel.Debug"/> level.
                /// </summary>
                bool IsDebugEnabled
                {
@@ -153,7 +227,7 @@
                }
 
                /// <summary>
-               /// 
+               /// Checks if this logger is enabled for the <see 
cref="LogLevel.Error"/> level.
                /// </summary>
                bool IsErrorEnabled
                {
@@ -161,7 +235,7 @@
                }
 
                /// <summary>
-               /// 
+               /// Checks if this logger is enabled for the <see 
cref="LogLevel.Fatal"/> level.
                /// </summary>
                bool IsFatalEnabled
                {
@@ -169,7 +243,7 @@
                }
 
                /// <summary>
-               /// 
+               /// Checks if this logger is enabled for the <see 
cref="LogLevel.Info"/> level.
                /// </summary>
                bool IsInfoEnabled
                {
@@ -177,15 +251,7 @@
                }
 
                /// <summary>
-               /// 
-               /// </summary>
-               bool IsTraceEnabled
-               {
-                       get;
-               }
-
-               /// <summary>
-               /// 
+               /// Checks if this logger is enabled for the <see 
cref="LogLevel.Warn"/> level.
                /// </summary>
                bool IsWarnEnabled
                {

Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLogger.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLogger.cs?rev=208781&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLogger.cs 
(added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLogger.cs 
Fri Jul  1 11:34:01 2005
@@ -0,0 +1,271 @@
+
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: $
+ * $Date: $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004 - Gilles Bayon
+ *  
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ 
********************************************************************************/
+#endregion
+
+using System;
+using System.Text;
+
+namespace IBatisNet.Common.Logging.Impl
+{
+       /// <summary>
+       /// Logger sending everything to the standard output error stream.
+       /// </summary>
+       public class ConsoleOutLogger: ILog
+       {
+               private bool _showDateTime = false;
+               private bool _showLogName = false;
+               private string _logName = string.Empty;
+               private LogLevel _currentLogLevel = LogLevel.All;
+               private string _dateTimeFormat = string.Empty;
+
+               /// <summary>
+               /// 
+               /// </summary>
+               /// <param name="logName"></param>
+               /// <param name="logLevel"></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 ConsoleOutLogger( string logName, LogLevel logLevel
+                       , bool showDateTime, bool showLogName, string 
dateTimeFormat)
+               {
+                       _logName = logName;
+                       _currentLogLevel = logLevel;
+                       _showDateTime = showDateTime;
+                       _showLogName = showLogName;
+                       _dateTimeFormat = dateTimeFormat;
+               }
+
+               /// <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/>
+               /// </summary>
+               /// <param name="level"></param>
+               /// <param name="message"></param>
+               /// <param name="e"></param>
+               private 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 )
+                       {
+                               sb.Append( DateTime.Now );
+                               sb.Append( " " );
+                       }       
+                       // Append a readable representation of the log level
+                       sb.Append( string.Format( "[{0}]", 
level.ToString().ToUpper() ).PadRight( 8 ) );
+
+                       // Append the name of the log instance if so configured
+                       if ( _showLogName )
+                       {
+                               sb.Append( _logName ).Append( " - " );
+                       }
+
+                       // Append the message
+                       sb.Append( message.ToString() );
+
+                       // Append stack trace if not null
+                       if ( e != null )
+                       {
+                               sb.AppendFormat( "\n{0}", e.ToString() );
+                       }
+
+                       // Print to the appropriate destination
+                       System.Console.Out.WriteLine( sb.ToString() );          
        
+               }
+
+               /// <summary>
+               /// Is the given log level currently enabled ?
+               /// </summary>
+               /// <param name="level"></param>
+               /// <returns></returns>
+               private 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
+       }
+}

Added: 
ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLoggerFA.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLoggerFA.cs?rev=208781&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLoggerFA.cs 
(added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/ConsoleOutLoggerFA.cs 
Fri Jul  1 11:34:01 2005
@@ -0,0 +1,107 @@
+
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: $
+ * $Date: $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004 - Gilles Bayon
+ *  
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ 
********************************************************************************/
+#endregion
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+
+namespace IBatisNet.Common.Logging.Impl
+{
+       /// <summary>
+       /// Description résumée de ConsoleOutLoggerFA.
+       /// </summary>
+       public class ConsoleOutLoggerFA: ILoggerFactoryAdapter 
+       {
+               private Hashtable _logs = Hashtable.Synchronized( new 
Hashtable() );
+               private LogLevel _Level = LogLevel.All;
+               private bool _showDateTime = true;
+               private bool _showLogName = true;
+               private string _dateTimeFormat = string.Empty;
+
+               /// <summary>
+               /// Constructor
+               /// </summary>
+               /// <param name="properties"></param>
+               public ConsoleOutLoggerFA(NameValueCollection properties)
+               {
+                       try
+                       {
+                               _Level = (LogLevel)Enum.Parse( 
typeof(LogLevel), properties["level"], true );
+                       }
+                       catch ( Exception )
+                       {
+                               _Level = LogLevel.All;
+                       }
+                       try
+                       {
+                               _showDateTime = bool.Parse( 
properties["showDateTime"] );
+                       }
+                       catch ( Exception )
+                       {
+                               _showDateTime = true;
+                       }
+                       try 
+                       {
+                               _showLogName = bool.Parse( 
properties["showLogName"] );
+                       }
+                       catch ( Exception )
+                       {
+                               _showLogName = true;
+                       }
+                       _dateTimeFormat =  properties["dateTimeFormat"];
+               }
+
+               #region ILoggerFactoryAdapter Members
+
+               /// <summary>
+               /// Get a ILog instance by type 
+               /// </summary>
+               /// <param name="type"></param>
+               /// <returns></returns>
+               public ILog GetLogger(Type type)
+               {
+                       return GetLogger( type.FullName );
+               }
+
+               /// <summary>
+               /// Get a ILog instance by type name 
+               /// </summary>
+               /// <param name="name"></param>
+               /// <returns></returns>
+               public ILog GetLogger(string name)
+               {
+                       ILog log = _logs[name] as ILog;
+                       if ( log == null )
+                       {
+                               log = new ConsoleOutLogger( name, _Level, 
_showDateTime, _showLogName, _dateTimeFormat );
+                               _logs.Add( name, log );
+                       }
+                       return log;
+               }
+
+               #endregion
+       }
+}

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLogger.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLogger.cs?rev=208781&r1=208780&r2=208781&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLogger.cs 
(original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLogger.cs Fri Jul  
1 11:34:01 2005
@@ -31,7 +31,7 @@
        /// <summary>
        /// Summary description for NoOpLogger.
        /// </summary>
-       public class NoOpLogger: ILog
+       public sealed class NoOpLogger: ILog
        {
                /// <summary>
                /// A NOP implementation.

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLoggerFA.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLoggerFA.cs?rev=208781&r1=208780&r2=208781&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLoggerFA.cs 
(original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/NoOpLoggerFA.cs Fri 
Jul  1 11:34:01 2005
@@ -31,10 +31,13 @@
        /// <summary>
        /// Summary description for NoOpLoggerFA.
        /// </summary>
-       public class NoOpLoggerFA : ILoggerFactoryAdapter
+       public sealed class NoOpLoggerFA : ILoggerFactoryAdapter
        {
                private ILog _nopLogger = null;
 
+               /// <summary>
+               /// Constructor
+               /// </summary>
                public NoOpLoggerFA()
                {
                        _nopLogger = new NoOpLogger();
@@ -42,11 +45,21 @@
 
                #region ILoggerFactoryAdapter Members
 
+               /// <summary>
+               /// Get a ILog instance by type 
+               /// </summary>
+               /// <param name="type"></param>
+               /// <returns></returns>
                public ILog GetLogger(Type type)
                {
                        return _nopLogger;
                }
 
+               /// <summary>
+               /// Get a ILog instance by type name 
+               /// </summary>
+               /// <param name="name"></param>
+               /// <returns></returns>
                ILog Logging.ILoggerFactoryAdapter.GetLogger(string name)
                {
                        return _nopLogger;

Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLogger.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLogger.cs?rev=208781&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLogger.cs (added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLogger.cs Fri Jul 
 1 11:34:01 2005
@@ -0,0 +1,272 @@
+
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: $
+ * $Date: $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004 - Gilles Bayon
+ *  
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ 
********************************************************************************/
+#endregion
+
+using System;
+using System.Text;
+
+namespace IBatisNet.Common.Logging.Impl
+{
+       /// <summary>
+       /// Logger sending everything to the trace output stream.
+       /// </summary>
+       public class TraceLogger: ILog
+       {
+               private bool _showDateTime = false;
+               private bool _showLogName = false;
+               private string _logName = string.Empty;
+               private LogLevel _currentLogLevel = LogLevel.All;
+               private string _dateTimeFormat = string.Empty;
+
+               /// <summary>
+               /// 
+               /// </summary>
+               /// <param name="logName"></param>
+               /// <param name="logLevel"></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)
+               {
+                       _logName = logName;
+                       _currentLogLevel = logLevel;
+                       _showDateTime = showDateTime;
+                       _showLogName = showLogName;
+                       _dateTimeFormat = dateTimeFormat;
+               }
+
+               /// <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/>
+               /// </summary>
+               /// <param name="level"></param>
+               /// <param name="message"></param>
+               /// <param name="e"></param>
+               private 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 )
+                       {
+                               sb.Append( DateTime.Now );
+                               sb.Append( " " );
+                       }       
+                       // Append a readable representation of the log level
+                       sb.Append( string.Format( "[{0}]", 
level.ToString().ToUpper() ).PadRight( 8 ) );
+
+                       // Append the name of the log instance if so configured
+                       if ( _showLogName )
+                       {
+                               sb.Append( _logName ).Append( " - " );
+                       }
+
+                       // Append the message
+                       sb.Append( message.ToString() );
+
+                       // Append stack trace if not null
+                       if ( e != null )
+                       {
+                               sb.AppendFormat( "\n{0}", e.ToString() );
+                       }
+
+                       // Print to the appropriate destination
+                       System.Diagnostics.Trace.WriteLine( sb.ToString() );    
                
+               }
+
+               /// <summary>
+               /// Is the given log level currently enabled ?
+               /// </summary>
+               /// <param name="level"></param>
+               /// <returns></returns>
+               private 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
+       }
+}
+

Added: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLoggerFA.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLoggerFA.cs?rev=208781&view=auto
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLoggerFA.cs 
(added)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/Impl/TraceLoggerFA.cs Fri 
Jul  1 11:34:01 2005
@@ -0,0 +1,107 @@
+
+#region Apache Notice
+/*****************************************************************************
+ * $Header: $
+ * $Revision: $
+ * $Date: $
+ * 
+ * iBATIS.NET Data Mapper
+ * Copyright (C) 2004 - Gilles Bayon
+ *  
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ 
********************************************************************************/
+#endregion
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+
+namespace IBatisNet.Common.Logging.Impl
+{
+       /// <summary>
+       /// Summary description for  TraceLoggerFA.
+       /// </summary>
+       public class TraceLoggerFA: ILoggerFactoryAdapter 
+       {
+               private Hashtable _logs = Hashtable.Synchronized( new 
Hashtable() );
+               private LogLevel _Level = LogLevel.All;
+               private bool _showDateTime = true;
+               private bool _showLogName = true;
+               private string _dateTimeFormat = string.Empty;
+
+               /// <summary>
+               /// Constructor
+               /// </summary>
+               /// <param name="properties"></param>
+               public TraceLoggerFA(NameValueCollection properties)
+               {
+                       try
+                       {
+                               _Level = (LogLevel)Enum.Parse( 
typeof(LogLevel), properties["level"], true );
+                       }
+                       catch ( Exception )
+                       {
+                               _Level = LogLevel.All;
+                       }
+                       try
+                       {
+                               _showDateTime = bool.Parse( 
properties["showDateTime"] );
+                       }
+                       catch ( Exception )
+                       {
+                               _showDateTime = true;
+                       }
+                       try 
+                       {
+                               _showLogName = bool.Parse( 
properties["showLogName"] );
+                       }
+                       catch ( Exception )
+                       {
+                               _showLogName = true;
+                       }
+                       _dateTimeFormat =  properties["dateTimeFormat"];
+               }
+
+               #region ILoggerFactoryAdapter Members
+
+               /// <summary>
+               /// Get a ILog instance by type 
+               /// </summary>
+               /// <param name="type"></param>
+               /// <returns></returns>
+               public ILog GetLogger(Type type)
+               {
+                       return GetLogger( type.FullName );
+               }
+
+               /// <summary>
+               /// Get a ILog instance by type name 
+               /// </summary>
+               /// <param name="name"></param>
+               /// <returns></returns>
+               public ILog GetLogger(string name)
+               {
+                       ILog log = _logs[name] as ILog;
+                       if ( log == null )
+                       {
+                               log = new TraceLogger( name, _Level, 
_showDateTime, _showLogName, _dateTimeFormat );
+                               _logs.Add( name, log );
+                       }
+                       return log;
+               }
+
+               #endregion
+       }
+}

Modified: ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/LogManager.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/LogManager.cs?rev=208781&r1=208780&r2=208781&view=diff
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/LogManager.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common/Logging/LogManager.cs Fri Jul  1 
11:34:01 2005
@@ -174,7 +174,7 @@
                /// <returns></returns>
                private static ILoggerFactoryAdapter 
BuildDefaultLoggerFactoryAdapter()
                {
-                       ILoggerFactoryAdapter simpleLogFactory = new 
SimpleLoggerFA(new NameValueCollection( null, new CaseInsensitiveComparer() ));
+                       ILoggerFactoryAdapter simpleLogFactory = new 
ConsoleOutLoggerFA(new NameValueCollection( null, new CaseInsensitiveComparer() 
));
                        return simpleLogFactory;
                }
        }


Reply via email to