org.as2lib.core.BasicInterface +--org.as2lib.env.log.Logger
Logger
declares all methods needed to log messages in a well defined
and performant way.
The basic methods to log messages are debug, info, warning and fatal.
The first thing to note is that you can log messages at different levels.
These levels are DEBUG
, INFO
, WARNING
, ERROR
and FATAL
. Depending on what level has been set only messages at a
given level are logged. The levels are organized in a hierarchical manner. That
means if you set the log level to ALL
every messages is logged. If you
set it to ERROR
only messages at ERROR
and FATAL
level
are logged and so on.
To do not waste unnecessary performance in constructing log messages that are not logged you can use the isDebugEnabled, isInfoEnabled, isWarningEnabled, isErrorEnabled and isFatalEnabled methods.
Note that the message does in neither case have to be a string. That means
you can pass-in messages and let the actual handler or logger decide how to
produce a string representation of the message. That is in most cases done by
using the toString
method of the specific message. You can use this
method to do not lose performance in cases where the message is not logged.
The basic workflow of using loggers is as follows:
// MyLogger is an implementation of this interface
var logger:Logger = new MyLogger();
if (logger.isInfoEnabled()) {
logger.info("This is an information message.");
}
Note that we are in the above example not setting a log level. This depends on what configuration methods the implementation of this interface offers.
Note also that depending on the concrete implementation and the message it
may be faster to do not call any of the is*Enabled
methods.
public function isDebugEnabled(Void):Boolean
Checks if this logger is enabled for debug level log messages.
Using this method as shown in the class documentation may improve performance depending on how long the log message construction takes.
true
if debug messagess are logged
public function isInfoEnabled(Void):Boolean
Checks if this logger is enabled for info level log messages.
Using this method as shown in the class documentation may improve performance depending on how long the log message construction takes.
true
if info messages are logged
public function isWarningEnabled(Void):Boolean
Checks if this logger is enabled for warning level log messages.
Using this method as shown in the class documentation may improve performance depending on how long the log message construction takes.
true
if warning messages are logged
public function isErrorEnabled(Void):Boolean
Checks if this logger is enabled for error level log messages.
Using this method as shown in the class documentation may improve performance depending on how long the log message construction takes.
true
if error messages are logged
public function isFatalEnabled(Void):Boolean
Checks if this logger is enabled for fatal level log messages.
Using this method as shown in the class documentation may improve performance depending on how long the log message construction takes.
true
if fatal messages are logged
public function debug(message):Void
Logs the passed-in message
at debug level.
The message is only logged when the level is set to DEBUG
or a level
above.
message | the message object to log |
public function info(message):Void
Logs the passed-in message
at info level.
The message is only logged when the level is set to INFO
or a level
above.
message | the message object to log |
public function warning(message):Void
Logs the passed-in message
at warning level.
The message is only logged when the level is set to WARNING
or a
level above.
message | the message object to log |