com.mortbay.Base
Class Log

java.lang.Object
  |
  +--com.mortbay.Base.Log

public class Log
extends java.lang.Object

Log formatted and tagged messages. Multiple LogSinks instances can be configured, but by default a System.err sink is created.

The Log log format is controlled by the LOG_OPTIONS property supplied to the VM.

If LOG_OPTIONS is set, then the default output format is controlled by the option characters in the string:

 t Timestamp log output
 T Show the log tag name
 L Show log label (thread, method and file names).
 s Show indication of stack depth
 S Stack trace for each output line (VERY VERBOSE)
 O Place each log one One line of output
 

If the property LOG_CLASSES is set, it is interpreted as a semi-colon-separated list of fully-qualified LogSink class names. An instance of each class, created with a default constructor, is added to the list of log sinks. Some possibilities for LOG_CLASSES are com.mortbay.Base.LogSink - log to System.err com.mortbay.Base.FileLogSink - log to file whose name is in LOG_FILE com.mortbay.Base.RolloverFileLogSink - log to daily rollover logs

If the property LOG_CLASSES is missing, a single LogSink is used to output to System.err.

If the property LOG_DATE_FORMAT is set, then it is interpreted as a format string for java.text.SimpleDateFormat and used to format the log timestamps. Note: The character '+' is replaced with space in the date format string. If LOG_TIMEZONE is set, it is used to set the timezone of the log date format, otherwise GMT is used.

As an alternative to the above behavior, you can create LogSinks in code and add() them to the Log. If you do this before the first use of the log, the default initialization will be skipped.


Field Summary
 java.lang.String _logOptions
           
 LogSink[] _sinks
           
static java.lang.String CODE_ASSERT
           
static java.lang.String CODE_DEBUG
           
static java.lang.String CODE_FAIL
           
static java.lang.String CODE_WARN
           
static java.lang.String EVENT
           
static char LABEL
           
static char ONELINE
           
static char STACKSIZE
           
static char STACKTRACE
           
static char TAG
           
static char TIMESTAMP
           
static java.lang.String WARN
           
 
Method Summary
 void add(LogSink logSink)
          Add a Log Sink.
 void disableLog()
          No logging.
static void event(java.lang.String message)
          Log an event
static void event(java.lang.String message, int stackDepth)
          Log an event
static java.lang.String getEVENT()
           
 java.lang.String getOptions()
           
static void initParamsFromApplet(java.applet.Applet appl)
          Initialize default behaviour from applet parameters Initializes the default instance from applet parameters of the same name as the system properties used to config Log
static Log instance()
           
static void message(java.lang.String tag, java.lang.String msg, Frame frame)
           
 void message(java.lang.String tag, java.lang.String msg, Frame frame, long time)
          Log a message
 void setOptions(java.lang.String logOptions)
           
 void setOptions(java.lang.String logOptions, java.lang.String logFile, java.lang.String dateFormat, java.lang.String timezone)
           
static void warning(java.lang.String message)
          Log an warning
static void warning(java.lang.String message, int stackDepth)
          Log an warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EVENT

public static final java.lang.String EVENT

WARN

public static final java.lang.String WARN

CODE_ASSERT

public static final java.lang.String CODE_ASSERT

CODE_WARN

public static final java.lang.String CODE_WARN

CODE_FAIL

public static final java.lang.String CODE_FAIL

CODE_DEBUG

public static final java.lang.String CODE_DEBUG

TIMESTAMP

public static char TIMESTAMP

LABEL

public static char LABEL

TAG

public static char TAG

STACKSIZE

public static char STACKSIZE

STACKTRACE

public static char STACKTRACE

ONELINE

public static char ONELINE

_sinks

public LogSink[] _sinks

_logOptions

public java.lang.String _logOptions
Method Detail

getEVENT

public static java.lang.String getEVENT()

instance

public static Log instance()

initParamsFromApplet

public static void initParamsFromApplet(java.applet.Applet appl)
Initialize default behaviour from applet parameters Initializes the default instance from applet parameters of the same name as the system properties used to config Log
Parameters:
appl - Applet

add

public void add(LogSink logSink)
Add a Log Sink.
Parameters:
logSink -  

disableLog

public void disableLog()
No logging. All log sinks are stopped and removed.

message

public static void message(java.lang.String tag,
                           java.lang.String msg,
                           Frame frame)

message

public void message(java.lang.String tag,
                    java.lang.String msg,
                    Frame frame,
                    long time)
Log a message
Parameters:
tag - Tag for type of log
msg - The message
frame - The frame that generated the message.
time - The time stamp of the message.

event

public static void event(java.lang.String message,
                         int stackDepth)
Log an event

event

public static void event(java.lang.String message)
Log an event

warning

public static void warning(java.lang.String message,
                           int stackDepth)
Log an warning

warning

public static void warning(java.lang.String message)
Log an warning

setOptions

public void setOptions(java.lang.String logOptions,
                       java.lang.String logFile,
                       java.lang.String dateFormat,
                       java.lang.String timezone)

setOptions

public void setOptions(java.lang.String logOptions)

getOptions

public java.lang.String getOptions()
Returns:
null;