org.apache.turbine.services.logging
Class BaseLogger

java.lang.Object
  |
  +--org.apache.turbine.services.logging.BaseLogger
All Implemented Interfaces:
Logger
Direct Known Subclasses:
FileLogger, Log4JavaLogger, ServletLogger

public abstract class BaseLogger
extends java.lang.Object
implements Logger

This is an abbstract class that implements Logger interface. User implementation has to redefine only five methods that can handle different type of destinations.

Version:
$Id$
Author:
Tomasz Zielinski, Jon S. Stevens, Daniel Rall

Field Summary
protected  boolean console
          flag is set when console writing is allowed
protected  boolean initialize
          Store status of the logger
protected  LoggingConfig loggingConfig
          The LoggingConfig object for this logger
protected  int logLevel
          Current log level for logger
protected  java.lang.String name
          Name of the logger
protected  RunDataFilter runDataFilter
          Extracts data from RunData
 
Fields inherited from interface org.apache.turbine.services.logging.Logger
BACKUP_KEY, CONSOLE_KEY, DB_KEY, DB_LOGGER_KEY, DB_POOL_KEY, DEBUG, EMAIL_KEY, EMAILBUFFERSIZE_KEY, EMAILFROM_KEY, EMAILSUBJECT_KEY, EMAILTO_KEY, ERROR, FACILITY_KEY, FILE_KEY, FORMAT_KEY, HOST_KEY, INFO, LEVELDEBUG, LEVELERROR, LEVELINFO, LEVELWARN, PATH_KEY, PORT_KEY, REMOTE_KEY, SIZE_KEY, SYSLOGD_KEY, WARN
 
Constructor Summary
BaseLogger()
          Default Constructor
 
Method Summary
abstract  boolean checkLogger()
          This method should be implemented by user.
protected  void configureConsole(LoggingConfig loggingConfig)
          This method should be implemented by user if the logger can handle remote server.
protected  void configureDatabase(LoggingConfig loggingConfig)
          This method should be implemented by user if the logger can handle database logs.
protected  void configureEmail(LoggingConfig loggingConfig)
          This method should be implemented by user if the logger can handle emailing logs.
protected  void configureFiles(LoggingConfig loggingConfig)
          This method should be implemented by user if the logger can handle files.
protected  void configureRemote(LoggingConfig loggingConfig)
          This method should be implemented by user if the logger can handle console.
protected  void configureSyslog(LoggingConfig loggingConfig)
          This method should be implemented by user if the logger can handle syslog demon.
private  void doBaseInit(LoggingConfig loggingConfig)
          Starts configuration of the logger, sets name, format, loging level (defaults to DEBUG).
protected  void doDispatch(LoggingConfig loggingConfig)
          Dispatches tasks for different types of destinations.
 java.lang.String getName()
          Returns logger's name
 void init(LoggingConfig loggingConfig)
          This method should be reimplemented by user if class use need some objects intialization.
 void setFormat(java.lang.String format)
          Sets format output of the Rundata.
 void setLogLevel(int level)
          Sets the logging level based on the numeric level passed in.
protected  void setLogLevel(java.lang.String level)
          Sets the logging level based on the text passed in.
 void setName(java.lang.String logName)
          Sets the name of the logger
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.logging.Logger
debug, debug, debug, debug, error, error, error, error, error, info, info, info, info, shutdown, warn, warn, warn, warn
 

Field Detail

logLevel

protected int logLevel
Current log level for logger

name

protected java.lang.String name
Name of the logger

initialize

protected boolean initialize
Store status of the logger

runDataFilter

protected RunDataFilter runDataFilter
Extracts data from RunData

loggingConfig

protected LoggingConfig loggingConfig
The LoggingConfig object for this logger

console

protected boolean console
flag is set when console writing is allowed
Constructor Detail

BaseLogger

public BaseLogger()
Default Constructor
Method Detail

init

public void init(LoggingConfig loggingConfig)
This method should be reimplemented by user if class use need some objects intialization.
Specified by:
init in interface Logger
Parameters:
loggingConfig - Configuration describing the logger.

doBaseInit

private void doBaseInit(LoggingConfig loggingConfig)
Starts configuration of the logger, sets name, format, loging level (defaults to DEBUG).
Parameters:
loggingConfig - Configuration describing the logger.

doDispatch

protected void doDispatch(LoggingConfig loggingConfig)
Dispatches tasks for different types of destinations. Checks if the logger were configure properly
Parameters:
loggingConfig - Configuration describing the logger.

getName

public java.lang.String getName()
Returns logger's name
Specified by:
getName in interface Logger

setName

public void setName(java.lang.String logName)
Sets the name of the logger
Specified by:
setName in interface Logger

setFormat

public void setFormat(java.lang.String format)
Sets format output of the Rundata. Format style is defined in the BaseRunDataFilter class.
Specified by:
setFormat in interface Logger
Parameters:
format - Text describing which data should be extracted from RunData
See Also:
BaseRunDataFilter

setLogLevel

protected void setLogLevel(java.lang.String level)
Sets the logging level based on the text passed in. Uses reasonable defaults if passed bogus data. Delegates to setLogLevel(int).
Parameters:
level - The logging level represented as text.

setLogLevel

public void setLogLevel(int level)
Sets the logging level based on the numeric level passed in. Uses reasonable defaults if passed bogus data.
Specified by:
setLogLevel in interface Logger
Parameters:
level - The logging level.

configureFiles

protected void configureFiles(LoggingConfig loggingConfig)
This method should be implemented by user if the logger can handle files. It adds local file as destinations for logger.
Parameters:
LoggingConfig - configuration

configureConsole

protected void configureConsole(LoggingConfig loggingConfig)
This method should be implemented by user if the logger can handle remote server. It adds remote servers as destinations for logger.
Parameters:
loggingConfig - Configuration describing the logger.

configureRemote

protected void configureRemote(LoggingConfig loggingConfig)
This method should be implemented by user if the logger can handle console. It adds console as a destination for logger.
Parameters:
loggingConfig - Configuration describing the logger.

configureSyslog

protected void configureSyslog(LoggingConfig loggingConfig)
This method should be implemented by user if the logger can handle syslog demon. It adds syslog demon as destinations for logger.
Parameters:
loggingConfig - Configuration describing the logger.

configureEmail

protected void configureEmail(LoggingConfig loggingConfig)
This method should be implemented by user if the logger can handle emailing logs. It adds email as a destination for logger.
Parameters:
loggingConfig - Configuration describing the logger.

configureDatabase

protected void configureDatabase(LoggingConfig loggingConfig)
This method should be implemented by user if the logger can handle database logs. It adds a db as a destination for logger.
Parameters:
loggingConfig - Configuration describing the logger.

checkLogger

public abstract boolean checkLogger()
This method should be implemented by user. It performs action that are need for deterimne whether logger was well configured or has any output
Specified by:
checkLogger in interface Logger


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.