org.webmacro.util
Class LogSystem

java.lang.Object
  extended byorg.webmacro.util.LogSystem

public final class LogSystem
extends java.lang.Object

The LogSystem class allows you to create and manage log objects and log targets. The LogSystem takes responsibility for ensuring that the appropriate targets are connected to the appropriate log objects.

There is a global LogSystem in place which you can access by calling getInstance(). Alternately you can create a new Logsystem by calling getInstance(category). Each category is a singleton with only one instance corresponding to its name existing in the JVM at any given time.


Field Summary
static int ALL
           
static int DEBUG
           
static int ERROR
           
static int INFO
           
protected static java.lang.String[] LEVELS
          Mapping of numbers to names.
static int NONE
           
static int NOTICE
           
static int WARNING
           
 
Method Summary
 void addTarget(LogTarget t)
          Add a new LogTarget to the LogSystem.
 void flush()
          Flush all of the LogTarget objects in the system
static void flushAll()
          Flush all log systems
static LogSystem getInstance()
          Get the global, system-wide, default log system
static LogSystem getInstance(java.lang.String category)
          Return the log-system with the specified category
static int getLevel(java.lang.String levelName)
          Convert a string like "DEBUG" into a level number.
 Log getLog(java.lang.String type)
          Get an instance of a Log object for the specified type.
 Log getLog(java.lang.String type, java.lang.String description)
          Get the Log object within this LogSystem that has the specified Log type.
static Log getSystemLog(java.lang.String type)
          Get a system-wide log
static Log getSystemLog(java.lang.String type, java.lang.String description)
          Get a system log, providing it with a description of itself
static void main(java.lang.String[] arg)
          Test out the logging system
 void removeTarget(LogTarget t)
          Remove a LogTarget from the LogSystem.
 void update(LogTarget target, java.lang.String type)
          LogTarget should call this method to notify LogSystem that conditions have changed and that the subscribe() method on LogTarget may now return a different value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL

public static final int ALL
See Also:
Constant Field Values

DEBUG

public static final int DEBUG
See Also:
Constant Field Values

INFO

public static final int INFO
See Also:
Constant Field Values

NOTICE

public static final int NOTICE
See Also:
Constant Field Values

WARNING

public static final int WARNING
See Also:
Constant Field Values

ERROR

public static final int ERROR
See Also:
Constant Field Values

NONE

public static final int NONE
See Also:
Constant Field Values

LEVELS

protected static final java.lang.String[] LEVELS
Mapping of numbers to names. The index into this array is the number corresponding to the log level.

Method Detail

getLevel

public static int getLevel(java.lang.String levelName)
Convert a string like "DEBUG" into a level number. This method also converts the strings ALL and NONE to the lowest (ALL) and one past highest (NONE) values.


getInstance

public static LogSystem getInstance()
Get the global, system-wide, default log system


getSystemLog

public static Log getSystemLog(java.lang.String type)
Get a system-wide log


getSystemLog

public static Log getSystemLog(java.lang.String type,
                               java.lang.String description)
Get a system log, providing it with a description of itself


getInstance

public static LogSystem getInstance(java.lang.String category)
Return the log-system with the specified category


getLog

public Log getLog(java.lang.String type)
Get an instance of a Log object for the specified type.


getLog

public Log getLog(java.lang.String type,
                  java.lang.String description)
Get the Log object within this LogSystem that has the specified Log type. These are the common Log objects which you write Log messages to. The description will be used to print out an explanation of the log in various places.


addTarget

public void addTarget(LogTarget t)
Add a new LogTarget to the LogSystem. The LogSystem will ask the target whether it wants to receive log messages for all of the Log objects existing in the system now or in the future.


removeTarget

public void removeTarget(LogTarget t)
Remove a LogTarget from the LogSystem. It will be disconnected from any Log objects that are feeding it messages.


update

public void update(LogTarget target,
                   java.lang.String type)
LogTarget should call this method to notify LogSystem that conditions have changed and that the subscribe() method on LogTarget may now return a different value. The type field may be null, or it may be a String type if conditions have changed only for a single Log source.


flush

public void flush()
Flush all of the LogTarget objects in the system


flushAll

public static void flushAll()
Flush all log systems


main

public static void main(java.lang.String[] arg)
                 throws java.lang.Exception
Test out the logging system

Throws:
java.lang.Exception