| java.lang.Object org.griphyn.vdl.util.Logging
Logging | public class Logging (Code) | | Create a common interface to handle logging of messages,
debugging and streaming. In order to avoid conflicts with
JDK 1.4.*, this class is named Logging instead of Logger.
The logging mechanism works similar to syslog. There is an
arbitrary number of user-named queues, and a "default" queue.
Each queue has a level associated with it. The higher the level,
the less important the message. If the message to be logged
exceeds the level, it will not be logged. Level 0 will always
be logged, if a queue exists for it.
Usage is simple. Each queue has to be registered before use. The
registrations associated the output stream and maximum debug level.
Each log line will be prefixed by a time stamp. The logging class
maintains internal state for each queue, if it requested a line feed
to be printed. Thus, you are able to construct a message in several
pieces, or a multi-line message by smuggling line feeds within the
message.
author: Jens-S. Vöckler author: Yong Zhao version: $Revision: 50 $ |
Method Summary | |
public static Currently | getDateFormat() Accessor: Obtains the default timestamp format for all queues. | public int | getLevel(String handle) Determines the maximum level up to which messages on the given
queue are protocolled. | public int | getVerbose() Obtains the current verbosity level. | public static Logging | instance() | public boolean | isUnset(String handle) Checks if a queue is free to be set up. | public void | log(String handle, int level, String msg) Prints a message on a previously registered stream.
Parameters: handle - is the symbolic queue handle. Parameters: level - is a verbosity level. | public void | log(String handle, int level, String msg, boolean newline) Prints a message on a previously registered stream.
Parameters: handle - is the symbolic queue handle. Parameters: level - is a verbosity level. | public void | register(String handle, String out) Registers a stream with a name to use for logging. | public void | register(String handle, OutputStream out) Registers a stream with a name to use for logging. | public void | register(String handle, OutputStream out, int level) Registers a stream with a name to use for logging. | public void | resetVerbose() Deactivates any verbosity. | public static void | setDateFormat(Currently format) Accessor: Sets the default timestamp format for all queues. | public void | setLevel(String handle, int level) Set the maximum level up to which messages on the given queue are
protocolled. | public void | setVerbose() Sets the maximum verbosity. | public void | setVerbose(int max) Sets or resets the verbosity level. |
getDateFormat | public static Currently getDateFormat()(Code) | | Accessor: Obtains the default timestamp format for all queues.
the currently active timestamp prefix format. |
getLevel | public int getLevel(String handle)(Code) | | Determines the maximum level up to which messages on the given
queue are protocolled. The associated stream is unaffected.
Parameters: handle - is the queue identifier the maximum inclusive log level, or -1 for error See Also: Logging.setLevel(String,int) |
getVerbose | public int getVerbose()(Code) | | Obtains the current verbosity level.
-1 for no verbosity, or the level up to which messages are logged. See Also: Logging.setVerbose(int) |
instance | public static Logging instance()(Code) | | implement the Singleton pattern
|
isUnset | public boolean isUnset(String handle)(Code) | | Checks if a queue is free to be set up. This is important for
initialization to setup default queues, but allow user overrides.
Parameters: handle - names the queue to check for a stream. true, if the queue is not yet connected. |
log | public void log(String handle, int level, String msg)(Code) | | Prints a message on a previously registered stream.
Parameters: handle - is the symbolic queue handle. Parameters: level - is a verbosity level. The higher the level, themore debug like the message. Messages of level 0 will alwaysbe printed. Parameters: msg - is the message to put onto the stream. Please notethat this function will automatically add the line break. |
log | public void log(String handle, int level, String msg, boolean newline)(Code) | | Prints a message on a previously registered stream.
Parameters: handle - is the symbolic queue handle. Parameters: level - is a verbosity level. The higher the level, themore debug like the message. Messages of level 0 will alwaysbe printed. Parameters: msg - is the message to put onto the stream. Parameters: newline - is a boolean, which will call invoke the printlnmethod. |
register | public void register(String handle, String out)(Code) | | Registers a stream with a name to use for logging. The queue
will be set up for maximum logging, e.g. virtually all levels
for this queue are logged.
Parameters: handle - is the queue identifier Parameters: out - is the name of a file to append to. Special names are stdout and stderr , which map to the system's respective streams. See Also: Logging.register(String,OutputStream,int) |
register | public void register(String handle, OutputStream out)(Code) | | Registers a stream with a name to use for logging. The queue
will be set up for maximum logging, e.g. virtually all levels
for this queue are logged.
Parameters: handle - is the queue identifier Parameters: out - is the new output stream See Also: Logging.register(String,OutputStream,int) |
register | public void register(String handle, OutputStream out, int level)(Code) | | Registers a stream with a name to use for logging. The queue
will be set up to use the output stream. If there was another
stream previously registered, it will be closed!
Parameters: handle - is the queue identifier Parameters: out - is the output stream associated with the queue Parameters: level - is the maximum debug level to put into the queue |
setDateFormat | public static void setDateFormat(Currently format)(Code) | | Accessor: Sets the default timestamp format for all queues.
Parameters: format - is the new timestamp prefix format. |
setLevel | public void setLevel(String handle, int level)(Code) | | Set the maximum level up to which messages on the given queue are
protocolled. The associated stream is unaffected.
Parameters: handle - is the queue identifier Parameters: level - is the new maximum log level (non-negative integer) See Also: Logging.setLevel(String,int) |
setVerbose | public void setVerbose(int max)(Code) | | Sets or resets the verbosity level.
Parameters: max - is the maximum inclusive level to which messages on anyqueue should be logged. A value of -1 (or any negative value) willdeactivate verbosity mode. See Also: Logging.getVerbose() |
|
|