org.webmacro.util
Class AbstractLogFile

java.lang.Object
  extended byorg.webmacro.util.AbstractLogFile
All Implemented Interfaces:
LogTarget
Direct Known Subclasses:
LogFile, ServletLog

public abstract class AbstractLogFile
extends java.lang.Object
implements LogTarget

Abstract base class which implements most of the LogTarget interface, to make it easier to write new log targets that plug into WM.


Field Summary
protected  java.lang.String _defaultFormatString
           
protected  int _defaultLevel
           
protected  java.lang.String _formatString
           
protected  java.util.Map _levels
           
protected  java.text.MessageFormat _mf
           
protected  java.lang.String _name
           
protected  java.util.List _observers
           
protected  boolean _trace
           
 
Constructor Summary
AbstractLogFile()
           
AbstractLogFile(Settings s)
           Create a new LogFile instance reading properties from the supplied Settings object.
 
Method Summary
 void addObserver(LogSystem ls)
          A LogSystem will register itself though this method in order to detect changes to the LogTarget.
 void removeObserver(LogSystem ls)
          A LogSystem may remove itself through this method if it de-registeres the LogTarget.
 void setLogLevel(int level)
          Set the log level for this Logfile.
 void setLogLevel(java.lang.String name, int level)
          Set the log level for a specific category name.
 void setTraceExceptions(boolean trace)
          Set whether this LogFile traces exceptions.
 boolean subscribe(java.lang.String category, java.lang.String name, int level)
          Return true or false if this log target would like to receive log messages for the named category, type, and logLevel.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.webmacro.util.LogTarget
flush, log
 

Field Detail

_levels

protected java.util.Map _levels

_trace

protected boolean _trace

_defaultLevel

protected int _defaultLevel

_defaultFormatString

protected java.lang.String _defaultFormatString

_formatString

protected java.lang.String _formatString

_mf

protected java.text.MessageFormat _mf

_observers

protected java.util.List _observers

_name

protected java.lang.String _name
Constructor Detail

AbstractLogFile

public AbstractLogFile(Settings s)

Create a new LogFile instance reading properties from the supplied Settings object.

     LogTraceExceptions: true|false|yes|no|on|off
     LogLevel: Debug|Info|Notice|etc
 


AbstractLogFile

public AbstractLogFile()
Method Detail

toString

public java.lang.String toString()

setLogLevel

public void setLogLevel(int level)
Set the log level for this Logfile. The default is LogSystem.NOTICE


setLogLevel

public void setLogLevel(java.lang.String name,
                        int level)
Set the log level for a specific category name.


setTraceExceptions

public void setTraceExceptions(boolean trace)
Set whether this LogFile traces exceptions. The default is false.


subscribe

public boolean subscribe(java.lang.String category,
                         java.lang.String name,
                         int level)
Description copied from interface: LogTarget
Return true or false if this log target would like to receive log messages for the named category, type, and logLevel. This method must return the same value every time it is called with the same arguments.

The logLevel you will be called with is one of the integers Log.ALL, Log.DEBUG, Log.INFO, Log.NOTICE, Log.WARNING, Log.ERROR, and Log.NONE in ascending order (Log.ERROR is a higher number than Log.WARNING which is a higher number than Log.DEBUG). In other words, the higher the logLevel the more important the log message is.

Specified by:
subscribe in interface LogTarget

addObserver

public void addObserver(LogSystem ls)
Description copied from interface: LogTarget
A LogSystem will register itself though this method in order to detect changes to the LogTarget. LogTargets should notify all observers when any setting changes that might affect the return value of the subscribe(...) method.

Specified by:
addObserver in interface LogTarget

removeObserver

public void removeObserver(LogSystem ls)
Description copied from interface: LogTarget
A LogSystem may remove itself through this method if it de-registeres the LogTarget. After this method the supplied observer should no longer receive notification of updates.

Specified by:
removeObserver in interface LogTarget


Copyright © 1999-2006 WebMacro. All Rights Reserved.