net.sf.click.service
Class ConsoleLogService

java.lang.Object
  extended bynet.sf.click.service.ConsoleLogService
All Implemented Interfaces:
LogService

public class ConsoleLogService
extends Object
implements LogService

Provides a Log Service class which will log messages to the console or System.out.

ConsoleLogService is the default LogService for Click.

However you can instruct Click to use a different log service implementation. Please see LogService for more details.

Author:
Malcolm Edgar

Field Summary
static int DEBUG_LEVEL
          The debug logging level.
static int ERROR_LEVEL
          The error logging level.
static int INFO_LEVEL
          The info logging level.
protected static String[] LEVELS
          The level names.
protected  int logLevel
          The logging level.
protected  String name
          The log name.
static int TRACE_LEVEL
          The trace logging level.
static int WARN_LEVEL
          The warn logging level.
 
Constructor Summary
ConsoleLogService()
           
 
Method Summary
 void debug(Object message)
          Log the given message at [debug] logging level.
 void debug(Object message, Throwable error)
          Log the given message and error at [debug] logging level.
 void error(Object message)
          Log the given message at [error] logging level.
 void error(Object message, Throwable error)
          Log the given message and error at [error] logging level.
 void info(Object message)
          Log the given message at [info] logging level.
 void info(Object message, Throwable error)
          Log the given message and error at [info] logging level.
 boolean isDebugEnabled()
          Return true if [debug] level logging is enabled.
 boolean isInfoEnabled()
          Return true if [info] level logging is enabled.
 boolean isTraceEnabled()
          Return true if [trace] level logging is enabled.
protected  void log(int level, String message, Throwable error)
          Log the given message and optional error at the specified logging level.
 void onDestroy()
          Destroy the LogService.
 void onInit(ServletContext servletContext)
          Initialize the LogService with the given application servlet context.
 void setLevel(int level)
          Set the logging level [ TRACE_LEVEL | DEBUG_LEVEL | INFO_LEVEL | WARN_LEVEL | ERROR_LEVEL ].
 void trace(Object message)
          Log the given message at [trace] logging level.
 void trace(Object message, Throwable error)
          Log the given message and error at [trace] logging level.
 void warn(Object message)
          Log the given message at [warn] logging level.
 void warn(Object message, Throwable error)
          Log the given message and error at [warn] logging level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE_LEVEL

public static final int TRACE_LEVEL
The trace logging level.

See Also:
Constant Field Values

DEBUG_LEVEL

public static final int DEBUG_LEVEL
The debug logging level.

See Also:
Constant Field Values

INFO_LEVEL

public static final int INFO_LEVEL
The info logging level.

See Also:
Constant Field Values

WARN_LEVEL

public static final int WARN_LEVEL
The warn logging level.

See Also:
Constant Field Values

ERROR_LEVEL

public static final int ERROR_LEVEL
The error logging level.

See Also:
Constant Field Values

LEVELS

protected static final String[] LEVELS
The level names.


logLevel

protected int logLevel
The logging level.


name

protected String name
The log name.

Constructor Detail

ConsoleLogService

public ConsoleLogService()
Method Detail

onInit

public void onInit(ServletContext servletContext)
            throws Exception
Description copied from interface: LogService
Initialize the LogService with the given application servlet context.

This method is invoked after the LogService has been constructed.

Note you can access ConfigService by invoking ClickUtils.getConfigService(javax.servlet.ServletContext)

Specified by:
onInit in interface LogService
Parameters:
servletContext - the application servlet context
Throws:
Exception - if an error occurs initializing the LogService
See Also:
LogService.onInit(ServletContext)

onDestroy

public void onDestroy()
Description copied from interface: LogService
Destroy the LogService.

Specified by:
onDestroy in interface LogService
See Also:
LogService.onDestroy()

setLevel

public void setLevel(int level)
Set the logging level [ TRACE_LEVEL | DEBUG_LEVEL | INFO_LEVEL | WARN_LEVEL | ERROR_LEVEL ].

Parameters:
level - the logging level

debug

public void debug(Object message)
Description copied from interface: LogService
Log the given message at [debug] logging level.

Specified by:
debug in interface LogService
Parameters:
message - the message to log
See Also:
LogService.debug(Object)

debug

public void debug(Object message,
                  Throwable error)
Description copied from interface: LogService
Log the given message and error at [debug] logging level.

Specified by:
debug in interface LogService
Parameters:
message - the message to log
error - the error to log
See Also:
LogService.debug(Object, Throwable)

error

public void error(Object message)
Description copied from interface: LogService
Log the given message at [error] logging level.

Specified by:
error in interface LogService
Parameters:
message - the message to log
See Also:
LogService.error(Object)

error

public void error(Object message,
                  Throwable error)
Description copied from interface: LogService
Log the given message and error at [error] logging level.

Specified by:
error in interface LogService
Parameters:
message - the message to log
error - the error to log
See Also:
LogService.error(Object, Throwable)

info

public void info(Object message)
Description copied from interface: LogService
Log the given message at [info] logging level.

Specified by:
info in interface LogService
Parameters:
message - the message to log
See Also:
LogService.info(Object)

info

public void info(Object message,
                 Throwable error)
Description copied from interface: LogService
Log the given message and error at [info] logging level.

Specified by:
info in interface LogService
Parameters:
message - the message to log
error - the error to log
See Also:
LogService.info(Object, Throwable)

trace

public void trace(Object message)
Description copied from interface: LogService
Log the given message at [trace] logging level.

Specified by:
trace in interface LogService
Parameters:
message - the message to log
See Also:
LogService.trace(Object)

trace

public void trace(Object message,
                  Throwable error)
Description copied from interface: LogService
Log the given message and error at [trace] logging level.

Specified by:
trace in interface LogService
Parameters:
message - the message to log
error - the error to log
See Also:
LogService.trace(Object, Throwable)

warn

public void warn(Object message)
Description copied from interface: LogService
Log the given message at [warn] logging level.

Specified by:
warn in interface LogService
Parameters:
message - the message to log
See Also:
LogService.warn(Object)

warn

public void warn(Object message,
                 Throwable error)
Description copied from interface: LogService
Log the given message and error at [warn] logging level.

Specified by:
warn in interface LogService
Parameters:
message - the message to log
error - the error to log
See Also:
LogService.warn(Object, Throwable)

isDebugEnabled

public boolean isDebugEnabled()
Description copied from interface: LogService
Return true if [debug] level logging is enabled.

Specified by:
isDebugEnabled in interface LogService
Returns:
true if [debug] level logging is enabled
See Also:
LogService.isDebugEnabled()

isInfoEnabled

public boolean isInfoEnabled()
Description copied from interface: LogService
Return true if [info] level logging is enabled.

Specified by:
isInfoEnabled in interface LogService
Returns:
true if [info] level logging is enabled
See Also:
LogService.isInfoEnabled()

isTraceEnabled

public boolean isTraceEnabled()
Description copied from interface: LogService
Return true if [trace] level logging is enabled.

Specified by:
isTraceEnabled in interface LogService
Returns:
true if [trace] level logging is enabled
See Also:
LogService.isTraceEnabled()

log

protected void log(int level,
                   String message,
                   Throwable error)
Log the given message and optional error at the specified logging level.

Parameters:
level - the logging level
message - the message to log
error - the optional error to log