#region Apache Notice
/*****************************************************************************
* $Header: $
* $Revision: 474141 $
* $Date: 2006-11-12 23:43:37 -0500 (Sun, 12 Nov 2006) $
*
* 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;
namespace IBatisNet.Common.Logging.Impl
{
///
/// Base class that implements the ILog interface.
///
public abstract class AbstractLogger : ILog
{
///
/// Concrete classes should override this method to perform the actual logging.
///
///
///
///
protected abstract void Write(LogLevel logLevel, object message, Exception e);
///
/// Concrete classes should override this method to determine if a particular
/// is enabled.
///
///
///
protected abstract bool IsLevelEnabled(LogLevel logLevel);
#region ILog Members
///
/// Log a message.
///
/// The message to log.
public void Debug(object message)
{
Debug( message, null );
}
///
/// Log a message with an optional .
///
/// The message to log.
///
/// The associated with the message. If there isn't any
/// associated with the message, pass .
///
public void Debug(object message, Exception e)
{
if ( IsLevelEnabled( LogLevel.Debug ) )
{
Write( LogLevel.Debug, message, e );
}
}
///
/// Log a message.
///
/// The message to log.
public void Error(object message)
{
Error( message, null );
}
///
/// Log a message with an optional .
///
/// The message to log.
///
/// The associated with the message. If there isn't any
/// associated with the message, pass .
///
public void Error(object message, Exception e)
{
if ( IsLevelEnabled( LogLevel.Error ) )
{
Write( LogLevel.Error, message, e );
}
}
///
/// Log a message.
///
/// The message to log.
public void Fatal(object message)
{
Fatal( message, null );
}
///
/// Log a message with an optional .
///
/// The message to log.
///
/// The associated with the message. If there isn't any
/// associated with the message, pass .
///
public void Fatal(object message, Exception e)
{
if ( IsLevelEnabled( LogLevel.Fatal ) )
{
Write( LogLevel.Fatal, message, e );
}
}
///
/// Log a message.
///
/// The message to log.
public void Info(object message)
{
Info( message, null );
}
///
/// Log a message with an optional .
///
/// The message to log.
///
/// The associated with the message. If there isn't any
/// associated with the message, pass .
///
public void Info(object message, Exception e)
{
if ( IsLevelEnabled( LogLevel.Info ) )
{
Write( LogLevel.Info, message, e );
}
}
///
/// Log a message.
///
/// The message to log.
public void Warn(object message)
{
Warn( message, null );
}
///
/// Log a message with an optional .
///
/// The message to log.
///
/// The associated with the message. If there isn't any
/// associated with the message, pass .
///
public void Warn(object message, Exception e)
{
if ( IsLevelEnabled( LogLevel.Warn ) )
{
Write( LogLevel.Warn, message, e );
}
}
///
/// Returns if the current is greater than or
/// equal to . If it is, all messages will be sent to .
///
public bool IsDebugEnabled
{
get { return IsLevelEnabled( LogLevel.Debug ); }
}
///
/// Returns if the current is greater than or
/// equal to . If it is, only messages with a of
/// and will be sent to .
///
public bool IsErrorEnabled
{
get { return IsLevelEnabled( LogLevel.Error ); }
}
///
/// Returns if the current is greater than or
/// equal to . If it is, only messages with a of
/// will be sent to .
///
public bool IsFatalEnabled
{
get { return IsLevelEnabled( LogLevel.Fatal ); }
}
///
/// Returns if the current is greater than or
/// equal to . If it is, only messages with a of
/// , , , and
/// will be sent to .
///
public bool IsInfoEnabled
{
get { return IsLevelEnabled( LogLevel.Info ); }
}
///
/// Returns if the current is greater than or
/// equal to . If it is, only messages with a of
/// , , and
/// will be sent to .
///
public bool IsWarnEnabled
{
get { return IsLevelEnabled( LogLevel.Warn ); }
}
#endregion
}
}