Class org.as2lib.env.log.LogMessage

org.as2lib.core.BasicClass
   +--org.as2lib.env.log.LogMessage

Description

LogMessage is a dumb data holder that contains all the information about the message to log.

These information are the the message to log, its level and the name of the logger that is responsible for logging the message.

The toString method uses the set stringifier to obtain its string representation. If you want a different appearance of the log message you can use the static setStringifier method to set your custom stringifier.

The PatternLogMessageStringifier supports different presentation styles. It allows to switch the log level, the logger name and the time on and off.

Method Index

new LogMessage()

getLevel(), getLoggerName(), getMessage(), getStringifier(), getTimeStamp(), setStringifier(), toString()

Constructor Detail

LogMessage

public function LogMessage(message, level:LogLevel, loggerName:String, timeStamp:Number)

Constructs a new LogMessage instance.

If timeStamp is null or undefined this constructor sets it by itself using the current time.

Parameters

messagethe message object to log
levelthe level of the passed-in message
loggerNamethe name of the logger that logs the message
timeStamp(optional) the number of milliseconds elapsed from 1/1/1970 until log this message was created

Method Detail

getStringifier

static public function getStringifier(Void):Stringifier

Returns either the stringifier set via setStringifier or the default one which is an instance of class PatternLogMessageStringifier.

Return

the currently used stringifier

setStringifier

static public function setStringifier(newStringifier:Stringifier):Void

Sets a new stringifier to be used by the toString method.

If newStringifier is null the getStringifier method will return the default stringifier.

Parameters

newStringifierthe new stringifier to be used

getMessage

public function getMessage(Void)

Returns the message object to log

Return

message the message object to log

getLevel

public function getLevel(Void):LogLevel

Returns the level of the message.

Return

the level of the message

getLoggerName

public function getLoggerName(Void):String

Returns the name of the logger that logs the message.

Return

the name of the logging logger

getTimeStamp

public function getTimeStamp(Void):Number

Returns the number of milliseconds elapsed from 1/1/1970 until message was created.

toString

public function toString():String

Uses the stringifier returned by the static getStringifier method to stringify this instance.

Return

the string representation of this log message

Specified By

toString() in org.as2lib.core.BasicInterface

Overrides

toString() in org.as2lib.core.BasicClass