|Definition|| class Logger|
Logger objects provide a convenient and consistent method to capture and store logging information.
Loggers can direct output to Streams and may be aggregated in a hierarchical manner. The verbosity of
logging can be managed and messages can be filtered.
Hierarchies of loggers can be constructed by specifying a parent logger when creating a logger instance.
For example, a logger can be created for each class in a package with all such loggers having a single parent.
Loggers can send log messages to their parent and inherit their parent's log level.
The top level logger for an application is defined by App.log.
Each logger may define a filter function that returns true or false depending on whether a specific message
should be logged or not. A matching pattern can alternatively be used to filter messages.
An Application will have a default Logger instance created and stored in App.log at startup. This Logger uses
the LogFile class to communicate with the Application's native log file. This is typically initialized
by the "--log" command line switch and otherwise defaults to send messages to the standard error console.
| static const ||All||Number||Logging level to output all messages. |
| static const ||Config||Number||Logging level for configuration output. |
| static const ||Error||Number||Logging level for most serious errors. (.|
| static const ||Info||Number||Logging level for informational messages. |
| static const ||Off||Number||Logging level for no logging. |
| static const ||Warn||Number||Logging level for warnings. |
| get set ||filter||Function||Filter function for this logger. The filter function is called with the following signature:
with "this" set to the Logger instance. The log parameter is set to the original logger that created the
function filter(log: Logger, name: String, level: Number, kind: String, msg: String): Boolean.|
| get set ||level||Number||The numeric verbosity setting (0-9) of this logger. Zero is least verbose, nine is the most verbose.
Messages with a lower (or equal) verbosity level than the logger's level are emitted.
| get ||location|| ||The logging location parameter specified when constructing or redirecting the logger. |
| get set ||match||RegExp||Matching expression to filter log messages. The match regular expression is used to match
against the Logger names.|
| get set ||name||String||The name of this logger. |
| get set ||outStream||Stream||The output stream used by the logger. |
Logger Class Methods
(No own class methods defined)
Logger Instance Methods
- Logger constructor. The Logger constructor can create different types of loggers based on the three (optional) arguments.
|name: String ||Unique name of the logger. Loggers are typically named after the module, class or subsystem they are associated with.|
|location ||Optional output stream or Logger to send messages to. If a parent Logger instance is provided for the output parameter, messages are sent to the parent for rendering.|
|level: Number ||Optional integer verbosity level. Messages with a message level less than or equal to the defined logger level will be emitted. Range is 0 (least verbose) to 9. [default: 0]|
var file = File("progress.log", "w")
var log = new Logger("name", file, 5)
- Close the logger.
- Emit a configuration message.
- Emit a debug message. The message level will be compared to the logger setting to determine
whether it will be output to the devices or not. Also, if the logger has a filter function set that
may filter the message out before logging.
|level: Number ||The level of the message.|
|msgs: Array ||The string message to log.|
- Emit an error message.
- Emit an informational message.
- Redirect log output.
|location ||Optional output stream, Logger or location specification to send messages to. If a parent Logger instance is provided, messages are sent to the parent for rendering. A location specification is of the form: file:level.|
|level: Number ||Optional integer verbosity level. Messages with a message level less than or equal to the defined logger level will be emitted. Range is 0 (least verbose) to 9. H. [default: null]|
- Emit a warning message.
|msgs: Array ||The data to log.|
- Write data to the stream.Write messages to the logger stream. If the stream can accept all the write data, the call returns immediately with the number of bytes written.
If writing more data than the stream can absorb in sync mode, the call will block until the data is written.
If writing more data than the stream can absorb in async mode, the call will not block and will buffer the
data and return immediately. Some streams will require a flush() call to actually send the data.
A "writable" event will be issued when the stream can again absorb more data.NOTE: for the Logger class, I/O errors will not throw exceptions.
|data: Array ||Data to write.|
|readable||Issued when data is written and a consumer can read without blocking.
||writable||Issued when the stream becomes empty and it is ready to be written to.
- A count of the bytes actually written.
IOError: if there is an I/O error.