|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jlf.log.Log
Log
is the base class which defines
all of the logging constants and implements any
general logging responsibilities. It dispatches the actual
logging information over to a concrete subclass of
AbstractLoggingMechanism
to do the work of writing
out the log information.
This class could be extended to do application-specific behavior,
or better yet you could create a class "wrapper" like AppLog
to make instances well-known Singletons with handy static/class methods.
AbstractLoggingMechanism
,
AppLog
Field Summary | |
static int |
CRITICAL_ERROR_LEVEL
The system encountered a critical error at this logging level, which affects the accuracy, integrity, reliability, or capability of the system. |
protected int |
currentLoggingLevel
Keep the logging level the log is currently operating at. |
protected java.util.Date |
dateOpened
Keeps the date the log opened |
static int |
DEACTIVATE_LEVEL
Turns the log off, no messages are logged |
static int |
DETAIL_LEVEL
Moderately detailed logging level to be used to help debug typical problems in the system. |
static int |
ERROR_LEVEL
The system encountered an unexpected error at this logging level, which probably means the code intercepted an error it cannot handle. |
static int |
INFO_LEVEL
Normal logging level. |
protected java.lang.String |
logFieldSeparator
Keeps a string demarking fields within the log file. |
static java.lang.String[] |
LOGGING_MECHANISMS
List of all available logging mechanisms. |
protected java.util.Vector |
loggingMechanisms
Keeps a collection of logging mechanisms to use when writing out the log. |
protected java.lang.String |
name
Keeps the name of the Log instance. |
static java.lang.String |
SHARED_DATED_FILE_MECHANISM
Logging mechanism to log all messages to a shared file for any Log instances using this mechanism. |
static java.lang.String |
SHARED_FILE_MECHANISM
Logging mechanism to log all messages to a shared file for any Log instances using this mechanism. |
static java.lang.String |
SMTP_MECHANISM
Logging mechanism to log certain priority messages to an email mailbox via SMTP. |
static java.lang.String |
STANDARD_ERR_MECHANISM
Logging mechanism to log all messages to System.err |
static int |
TRACE_LEVEL
Most detailed logging level. |
static java.lang.String |
UNIQUE_DATED_FILE_MECHANISM
Logging mechanism to log all messages to a unique file specific to that Log instance. |
static java.lang.String |
UNIQUE_FILE_MECHANISM
Logging mechanism to log all messages to a unique file specific to that Log instance. |
static int |
WARNING_LEVEL
The system encountered an expected error situation. |
Constructor Summary | |
protected |
Log()
Class constructor to properly create and register a new log. |
|
Log(java.lang.String name)
Public constructor to register a new log with a particular name. |
Method Summary | |
AbstractLoggingMechanism |
addLoggingMechanism(java.lang.String loggingMechanismName)
Adds a Logging Mechanism to the list of mechanisms that this log writes to. |
protected void |
finalize()
Must close the log for the application if the application did not or could not. |
java.util.Date |
getDateOpened()
Return the date the log was opened, only valid if the log is currently open. |
java.lang.String |
getLogFieldSeparator()
Gets the string that delimits the various fields of a log entry |
int |
getLoggingLevel()
Gets the logging level of the current log. |
AbstractLoggingMechanism |
getLoggingMechanism(java.lang.String loggingMechanismName)
If a logging mechanism of the type input is in effect for this log, return the logging mechanism instance matching the name given as input. |
java.util.Vector |
getLoggingMechanisms()
Returns a Vector of logging mechanisms
currently active for the log. |
java.lang.String |
getName()
Return the name of the log, usually passed in by the constructor. |
boolean |
isLoggingEnabledFor(int loggingLevel)
Returns true if the current logging level of the log is set to enable logging a string at the input logging level. |
boolean |
isOpen()
Return whether the log is open (is not deactivated). |
void |
logString(java.lang.String logString,
int loggingLevel)
Adds a message string to the log if the log's level is currently set at or above the loggingLevel passed in. |
void |
removeAllLoggingMechanisms()
Removes all Logging Mechanisms from the list of mechanisms that this log writes to. |
void |
removeLoggingMechanism(java.lang.String loggingMechanismName)
Removes an active Logging Mechanism from the list of mechanisms that this log writes to. |
void |
setLogFieldSeparator(java.lang.String logFieldSeparator)
Sets the string that delimits the various fields of a log entry |
void |
setLoggingLevel(int newLoggingLevel)
Changes the logging level of the current log. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEACTIVATE_LEVEL
public static final int CRITICAL_ERROR_LEVEL
public static final int ERROR_LEVEL
public static final int WARNING_LEVEL
public static final int INFO_LEVEL
public static final int DETAIL_LEVEL
public static final int TRACE_LEVEL
public static final java.lang.String STANDARD_ERR_MECHANISM
public static final java.lang.String UNIQUE_FILE_MECHANISM
Log
instance. Reuse the same
log file name (append to it) if it already exists.
public static final java.lang.String UNIQUE_DATED_FILE_MECHANISM
Log
instance. Don't append
to an existing log, instead create a new one with a date stamp.
public static final java.lang.String SHARED_FILE_MECHANISM
Log
instances using this mechanism.
Append to an existing log, if it already exists.
public static final java.lang.String SHARED_DATED_FILE_MECHANISM
Log
instances using this mechanism.
Don't append to an existing log, instead create a new one with a
date stamp.
public static final java.lang.String SMTP_MECHANISM
public static final java.lang.String[] LOGGING_MECHANISMS
protected java.lang.String name
protected int currentLoggingLevel
protected java.util.Vector loggingMechanisms
protected java.util.Date dateOpened
protected java.lang.String logFieldSeparator
Constructor Detail |
protected Log()
public Log(java.lang.String name)
Method Detail |
public int getLoggingLevel()
public boolean isLoggingEnabledFor(int loggingLevel)
public void setLoggingLevel(int newLoggingLevel)
public java.util.Vector getLoggingMechanisms()
Vector
of logging mechanisms
currently active for the log.
Vector
of logging mechanisms
currently active for the log.public AbstractLoggingMechanism getLoggingMechanism(java.lang.String loggingMechanismName)
loggingMechanismName
- Name of the logging mechanism to search for,
one of the constants in the Log
class.
AbstractLoggingMechanism
that is currently in effect for the Log if one found, null if not.public AbstractLoggingMechanism addLoggingMechanism(java.lang.String loggingMechanismName)
loggingMechanismName
- The name of the Logging Mechanism.
AbstractLoggingMechanism
that implements the mechanism just added, null if an error
occurred like the log could not be opened or that log was
previously opened!public void removeLoggingMechanism(java.lang.String loggingMechanismName)
loggingMechanismName
- The name of the Logging Mechanism to remove.public void removeAllLoggingMechanisms()
public void logString(java.lang.String logString, int loggingLevel)
logString
- The string to write to all logging mechanismsloggingLevel
- The level at which to log the string.protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
- Default finalizer exceptionpublic java.lang.String getLogFieldSeparator()
public void setLogFieldSeparator(java.lang.String logFieldSeparator)
public java.lang.String getName()
public boolean isOpen()
public java.util.Date getDateOpened()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |