|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.j4me.logging.Log
public class Log
Maintains a recording of the application's operation. The Log
takes
in strings for events that happen during the program's execution. Each event
has a Level
, or priority, associated with it.
The log can be read later to examine problems.
The following two examples illustrate how to record things in the log. The
first statement shows that the logging level should be checked before logging
because it stops the expensive string concatenation when the log level is
off. The second shows logging an exception.
if ( Log.isDebugEnabled() )
{
Log.debug("X = " + x + " which I only care about when debugging");
}
Log.warn("Problem with HTTP", exception);
Level
Constructor Summary | |
---|---|
Log()
|
Method Summary | |
---|---|
static void |
clear()
Empties the log of all messages. |
static void |
debug(java.lang.String message)
Log a message string at the DEBUG Level. |
static void |
debug(java.lang.String message,
java.lang.Throwable t)
Log a message string with the DEBUG level including the
stack trace of the Throwable t passed as
parameter. |
static void |
error(java.lang.String message)
Log a message string with the ERROR Level. |
static void |
error(java.lang.String message,
java.lang.Throwable t)
Log a message string with the ERROR level including the
stack trace of the Throwable t passed as
parameter. |
static Level |
getLogLevel()
Returns the lowest level of statements that are logged. |
static LogMessage[] |
getLogMessages()
Gets all the log messages still in memory. |
static void |
info(java.lang.String message)
Log a message string with the INFO Level. |
static void |
info(java.lang.String message,
java.lang.Throwable t)
Log a message string with the INFO level including the
stack trace of the Throwable t passed as
parameter. |
static boolean |
isDebugEnabled()
Check whether logging at the DEBUG level is enabled. |
static boolean |
isInfoEnabled()
Check whether logging at the INFO level is enabled. |
static void |
setLevel(int level)
Sets the level log statements are evaluated. |
static void |
setLevel(Level level)
Sets the level log statements are evaluated. |
static void |
warn(java.lang.String message)
Log a message string with the WARN Level. |
static void |
warn(java.lang.String message,
java.lang.Throwable t)
Log a message string with the WARN level including the
stack trace of the Throwable t passed as
parameter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Log()
Method Detail |
---|
public static Level getLogLevel()
setLevel
method to
reset the logging level.public static void setLevel(int level)
level
or higher will be logged.
The int
value level
should come from the getLogLevel
method.
level
- is the lowest priority of statements that will be logged.public static void setLevel(Level level)
level
or higher will be logged.
level
- is the lowest priority of statements that will be logged.public static void debug(java.lang.String message)
DEBUG
Level.
This method first checks if this category is DEBUG
enabled
by comparing the level of this category with DEBUG
Level. If the category is DEBUG
enabled, then it will log
the message.
message
- is the message to log.public static void debug(java.lang.String message, java.lang.Throwable t)
DEBUG
level including the
stack trace of the Throwable
t
passed as
parameter.
See debug(String)
for more detailed information.
message
- is the message to log.t
- is the exception to log.public static void info(java.lang.String message)
INFO
Level.
This method first checks if this category is INFO
enabled
by comparing the level of this category with INFO
Level. If the category is INFO
enabled, then it will log
the message.
message
- is the message to log.public static void info(java.lang.String message, java.lang.Throwable t)
INFO
level including the
stack trace of the Throwable
t
passed as
parameter.
See info(String)
for more detailed information.
message
- is the message to log.t
- is the exception to log.public static void warn(java.lang.String message)
WARN
Level.
This method first checks if this category is WARN
enabled
by comparing the level of this category with WARN
Level. If the category is WARN
enabled, then it will log
the message.
message
- is the message to log.public static void warn(java.lang.String message, java.lang.Throwable t)
WARN
level including the
stack trace of the Throwable
t
passed as
parameter.
See warn(String)
for more detailed information.
message
- is the message to log.t
- is the exception to log.public static void error(java.lang.String message)
ERROR
Level.
This method first checks if this category is ERROR
enabled
by comparing the level of this category with ERROR
Level. If the category is ERROR
enabled, then it will log
the message.
message
- is the message to log.public static void error(java.lang.String message, java.lang.Throwable t)
ERROR
level including the
stack trace of the Throwable
t
passed as
parameter.
See error(String)
for more detailed information.
message
- is the message to log.t
- is the exception to log.public static boolean isDebugEnabled()
DEBUG
level is enabled.
This function is intended to lessen the computational cost of disabled log statements. All debug logs that perform string concatenation should be written as:
if ( Log.isDebugEnabled() ) { Log.debug("This is entry number: " + i); }
true
if debug messages are logged; false
if not.public static boolean isInfoEnabled()
INFO
level is enabled.
This function is intended to lessen the computational cost of disabled log statements. All info logs that perform string concatenation should be written as:
if ( Log.isInfoEnabled() ) { Log.info("This is entry number: " + i); }
true
if info messages are logged; false
if not.public static LogMessage[] getLogMessages()
The returned array references all of the log messages and does not stop logging from continuing. In other words the returned logs are a snapshot in time.
length - 1
will
be the last message logged. If no messages have been logged this will
return an array of length zero (i.e. it never returns null
).public static void clear()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |