Access keys

MusicTheoryLogger

Kind of class: class
Inherits from: AbstractLogger < BasicClass
Implements:
Author: Simon Wacker
Classpath: org.as2lib.env.log.logger.MusicTheoryLogger
File last modified: Saturday, 28 May 2005, 12:13:58
MusicTheoryLogger writes messages to the SWF Console from Ricci Adams'
Musictheory.

Using this class to log messages instead of logging them directly to the
Musictheory SWF Console enables you to switch between differnt ouput devices and
Logging APIs without the need to change any logging calls in your application.
This class also gives you the ability to log at differnt log levels and decorates
log messages with a date-time, the level and the logger's name if wished. Refer
to org.as2lib.env.log.LogMessage on how to edit the decoration.

The basic methods to write log messages are log, 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.

Example:

var logger:MusicTheoryLogger = new MusicTheoryLogger("myLogger");
// checks if the message is actually logged
if (logger.isInfoEnabled()) {
      // logs the message at info level
    logger.info("This is a informative log message.");
}

This logger cannot be used with the {@ling LoggerHierarchy} because it does
not offer hierarchy support. If you want to use your logger in a hierarchy use
the SimpleHierarchicalLogger instead, together with a log handler.

Constructor

MusicTheoryLogger

function MusicTheoryLogger (
name:String)
Constructs a new MusicTheoryLogger instance.

The default log level is ALL. This means all messages regardless of
their level are logged.

The name is by default shown in the log message to identify where
the message came from.

Parameters:
name:
(optional) the name of this logger

Instance methods

debug

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.

Parameters:
message:
the message object to log
See also:

error

function error (
message) : Void
Logs the passed-in message at error level.

The message is only logged when the level is set to ERROR or
a level above.

Parameters:
message:
the message object to log
See also:

fatal

function fatal (
message) : Void
Logs the passed-in message at fatal level.

The message is only logged when the level is set to FATAL or
a level above.

Parameters:
message:
the message object to log
See also:

getLevel

function getLevel (
Void) : LogLevel
Returns the set level.
Returns:
the set level

getName

function getName (
Void) : String
Returns the name of this logger.

This method returns null if no name has been set via the
setName method nor on construction.

Returns:
the name of this logger

info

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.

Parameters:
message:
the message object to log
See also:

isDebugEnabled

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.

Returns:
true if debug messages are logged

isEnabled

function isEnabled (
level:LogLevel) : Boolean
Checks whether this logger is enabled for the passed-in level.

false will be returned if:

  • This logger is not enabled for the passed-in level.
  • The passed-in level is null or undefined.

Using this method as shown in the class documentation may improve performance
depending on how long the log message construction takes.

Parameters:
level:
the level to make the check upon
Returns:
true if this logger is enabled for the given level else
false
See also:

isErrorEnabled

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.

Returns:
true if error messages are logged

isFatalEnabled

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.

Returns:
true if fatal messages are logged

isInfoEnabled

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.

Returns:
true if info messages are logged

isWarningEnabled

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.

Returns:
true if warning messages are logged

log

function log (
message, level:LogLevel) : Void
Logs the passed-in message at the given level.

The message is only logged when this logger is enabled for the
passed-in level.

The message is logged to the Musictheory SWF Console.

Parameters:
message:
the message object to log
level :
the specific level at which the message shall be logged
See also:

setLevel

function setLevel (
level:LogLevel) : Void
Sets the log level.

The log level determines which messages are logged and which are not.

A level of value null or undefined is interpreted as level
ALL which is also the default level.

Parameters:
level:
the new log level

setName

function setName (
name:String) : Void
Sets the name of this logger.

The name is by default shown in the log message.

Parameters:
name:
the new name of this logger

warning

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.

Parameters:
message:
the message object to log