|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.iges.anagram.Log
Provides logging services for the server.
Nested Class Summary | |
protected class |
Log.Rotater
Produces rotating filenames either monthly, weekly, or daily. |
Field Summary | |
protected static int |
CONSOLE_MODE
Mode for log output |
static int |
CRITICAL
Level of log output |
protected java.lang.String |
dateTemplate
|
static int |
DEBUG
Level of log output |
protected int |
defaultLevel
|
protected java.text.DateFormat |
entryFormat
|
static int |
ERROR
Level of log output |
protected static int |
FILE_MODE
Mode for log output |
static int |
INFO
Level of log output |
static java.lang.String[] |
LEVEL_NAME
Name associated with each level. |
protected java.lang.String |
logFileName
|
protected java.io.PrintWriter |
logWriter
|
protected int |
mode
|
protected static java.lang.String[] |
MODE_NAME
Name associated with each log mode. |
protected java.lang.String |
moduleName
|
protected java.util.Map |
moduleSettings
|
static int |
NUM_LEVELS
|
protected java.text.FieldPosition |
pos
|
protected boolean |
printMem
|
protected boolean |
printModule
|
protected static int |
ROTATE_MODE
Mode for log output |
protected Log.Rotater |
rotater
|
protected Server |
server
|
static int |
SILENT
Level of log output |
static int |
VERBOSE
Level of log output |
Constructor Summary | |
Log()
|
Method Summary | |
void |
configure(Setting setting)
Configures the module according to the settings provided. |
protected void |
consoleMode()
Directs log output to the console (stderr). |
void |
critical(Module module,
java.lang.String message)
Writes a critical error message to the current log output. |
void |
debug(Module module,
java.lang.String message)
Writes a debug message to the current log output. |
boolean |
enabled(int level,
Module module)
Returns true if logging detail is set to the given level or higher for the specified module. |
void |
error(Module module,
java.lang.String message)
Writes an error message to the current log output. |
static int |
getLevel(java.lang.String levelName)
Translates a given log level name into an integer constant. |
protected static int |
getMode(java.lang.String modeName)
Translates a given log level name into an integer constant. |
java.lang.String |
getModuleID()
Returns an ID for this module. |
java.lang.String |
getModuleName()
Returns the complete name of the module, including parents. |
void |
info(Module module,
java.lang.String message)
Writes an info message to the current log output. |
void |
init(Server server,
Module parent)
Initializes the module. |
void |
log(int level,
Module module,
java.lang.String message)
Writes a message to the current log output. |
protected void |
open(java.lang.String filename)
Directs log output to the filename given. |
protected void |
parseLevel(Setting setting)
Sets flags for what messages should be printed |
protected void |
parseMode(Setting setting)
Sets the log mode to console, file, or rotating. |
protected void |
parseModuleSettings(Setting setting)
Sets up per-module logging configuration |
void |
verbose(Module module,
java.lang.String message)
Writes a verbose message to the current log output. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Server server
protected int defaultLevel
protected int mode
protected boolean printMem
protected boolean printModule
protected java.lang.String dateTemplate
protected java.text.DateFormat entryFormat
protected java.text.FieldPosition pos
protected java.lang.String logFileName
protected Log.Rotater rotater
protected java.io.PrintWriter logWriter
protected java.lang.String moduleName
protected java.util.Map moduleSettings
public static final int DEBUG
public static final int VERBOSE
public static final int INFO
public static final int ERROR
public static final int CRITICAL
public static final int SILENT
public static final int NUM_LEVELS
public static final java.lang.String[] LEVEL_NAME
protected static final int CONSOLE_MODE
protected static final int FILE_MODE
protected static final int ROTATE_MODE
protected static final java.lang.String[] MODE_NAME
Constructor Detail |
public Log()
Method Detail |
public final java.lang.String getModuleID()
Module
getModuleID
in interface Module
public final java.lang.String getModuleName()
Module
complete_name : [parents] module_id
parents : [parents] parent '/'
The complete module name is used as an identifier in log messages.
getModuleName
in interface Module
public final void init(Server server, Module parent)
Module
This method should copy the server and parent references provided to internal fields, so that the module has access to the rest of the module hierarchy, and then call the init() method of any sub-modules. It can also be used to perform any one-time initialization that requires access to other modules.
This method will only be called once, immediately after the module is created, and before it is configured for the first time. Thus it does not need to be thread-safe.
init
in interface Module
public void configure(Setting setting) throws ConfigException
Module
This method is guaranteed to be called at least once before any requests are sent to the module. The server supports dynamic reconfiguration, and thus this method may be called any number of times during the life of the module. However, it is guaranteed that this method will never be called while a servlet request is being processed. Thus it does not need to be thread-safe.
If this module contains other modules, it is responsible for configuring them using the appropriate sub-settings. Each module should receive the sub-setting that matches its module ID, so that the XML tags in the configuration file match up with the module names in the log file.
configure
in interface Module
ConfigException
- If the module is unable to operate using
the settings provided. This will halt the server's operation, and
thus should only be thrown if there is no reasonable default
that can be used in place of a missing or invalid setting.public void log(int level, Module module, java.lang.String message)
Critical error messages are prefaced with the string "CRITICAL: ". Error messages are prefaced with the string "error: ". Debug messages are prefaced with the string "*dbg* ". All other messages are written as is.
level
- The level of message - debug, verbose, info,
error, or criticalmodule
- The module that is generating the messagemessage
- The message itself.public void critical(Module module, java.lang.String message)
module
- The module that is generating the messagemessage
- The message itself.public void error(Module module, java.lang.String message)
module
- The module that is generating the messagemessage
- The message itself.public void info(Module module, java.lang.String message)
module
- The module that is generating the messagemessage
- The message itself.public void verbose(Module module, java.lang.String message)
module
- The module that is generating the messagemessage
- The message itself.public void debug(Module module, java.lang.String message)
module
- The module that is generating the messagemessage
- The message itself.public boolean enabled(int level, Module module)
protected void parseLevel(Setting setting)
protected void parseMode(Setting setting) throws ConfigException
ConfigException
protected void parseModuleSettings(Setting setting)
protected void open(java.lang.String filename)
protected void consoleMode()
public static final int getLevel(java.lang.String levelName)
protected static final int getMode(java.lang.String modeName)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |