Log
Class Description
Provides methods for sending formatted log messages at various verbosity levels.
Messages that exceed the current verbosity threshold stored in level
will be ignored.
The default level is INFO
(allowing INFO
, WARN
, ERROR
, and FATAL
messages, but
not DEBUG
).
A default formatter is provided. Custom formatters can be used by setting
the value of the formatter
property to a Formatter
-compliant class instance.
A default printer is provided to log to Console.print()
. Custom printers
can be used by setting the value of the printer
property to a Printer
-compliant
class instance.
Logging functions expect a label to indicate the owner of the message, and a function that should evaluate to a message when called. By capturing the message construction in a closure, any costs associated with forming the message are avoided for logging calls above the current verbosity threshold (log level).
See Also
Listing
Fields
version():String | static Version of the Log library |
defaultFormatter():Formatter | static Default formatter. Override by setting value of formatter |
defaultPrinter():Printer | static Default printer. Override by setting value of printer |
defaultLevel():LogLevel | static Default log level. Override by setting value of level |
formatter():Formatter | static Current formatter in use. |
printer():Printer | static Current printer in use. |
level():LogLevel | static Current log level. |
Methods
debug(label:String, messageGenerator:Function):void | static Submit a message at debug level verbosity (the highest verbosity level). |
info(label:String, messageGenerator:Function):void | static Submit a message at info level verbosity |
warn(label:String, messageGenerator:Function):void | static Submit a message at warn level verbosity |
error(label:String, messageGenerator:Function):void | static Submit a message at error level verbosity. |
fatal(label:String, messageGenerator:Function):void | static Submit a message at fatal level verbosity. |
levelToString(value:LogLevel):String | static Convert a log level enumeration into a human-readable string. |
levelFromString(value:String):LogLevel | static Convert a human-readable string into a log level enumeration. |
Details
Fields
versionstatic
public static const version():String
Version of the Log library
defaultFormatterstatic
public static const defaultFormatter():Formatter
Default formatter. Override by setting value of formatter
See Also
defaultPrinterstatic
public static const defaultPrinter():Printer
Default printer. Override by setting value of printer
See Also
defaultLevelstatic
public static const defaultLevel():LogLevel
Default log level. Override by setting value of level
See Also
Methods
debug()static
public static function debug(label:String, messageGenerator:Function):void
Submit a message at debug level verbosity (the highest verbosity level).
DEBUG messages help isolate problems in running systems, by showing what is being executed and the execution context.
DEBUG messages should provide context that makes it easy to spot abnormal values or conditions.
label:String | Name of the message owner |
messageGenerator:Function | A function to generate the message string |
info()static
public static function info(label:String, messageGenerator:Function):void
Submit a message at info level verbosity
INFO messages announce–at a high level–what the running system is doing. The system should be able to run at full speed with INFO level logging.
INFO messages should paint a clear picture of normal system operation.
label:String | Name of the message owner |
messageGenerator:Function | A function to generate the message string |
warn()static
public static function warn(label:String, messageGenerator:Function):void
Submit a message at warn level verbosity
WARN messages signal that something unexpected has occurred; the system is still operating as expected, but some investigation may be warranted.
WARN messages should be clear about what expectation was invalidated.
label:String | Name of the message owner |
messageGenerator:Function | A function to generate the message string |
error()static
public static function error(label:String, messageGenerator:Function):void
Submit a message at error level verbosity.
ERROR messages record that something has gone wrong, the system is unable to recover, and an operator needs to investigate and fix something.
ERROR messages should be clear about what went wrong and how it can be triaged or fixed.
label:String | Name of the message owner |
messageGenerator:Function | A function to generate the message string |
fatal()static
public static function fatal(label:String, messageGenerator:Function):void
Submit a message at fatal level verbosity.
FATAL messages document a failure that prevents the system from starting, and indicate the system is completely unusable.
FATAL messages should be clear about what assertion was violated.
label:String | Name of the message owner |
messageGenerator:Function | A function to generate the message string |
levelToString()static
public static function levelToString(value:LogLevel):String
Convert a log level enumeration into a human-readable string.
See Also
- pixeldroid.util..
value:LogLevel | A verbosity enumeration from |
returns String | A human readable string indicating the log level |