wilton/Logger
Log messages to console or log file.
More...
Functions | |
Undefined | debug (String|Object|Error message, Function|Undefined callback) |
Log specified message using DEBUG logging level. | |
Undefined | error (String|Object|Error message, Function|Undefined callback) |
Log specified message using ERROR logging level. | |
Undefined | info (String|Object|Error message, Function|Undefined callback) |
Log specified message using INFO logging level. | |
static Undefined | initConsole (String threshold, Function|Undefined callback) |
Shotcut function for console-only logging initialization. | |
static Undefined | initialize (Object options, Function|Undefined callback) |
Initialize process-wide logging. | |
Undefined | log (String|Object|Error message, Function|Undefined callback) |
Log specified message using DEBUG logging level. | |
Object | Logger (String|Undefined name, Function|Undefined callback) |
Create Logger instance. | |
static Undefined | shutdown (Function|Undefined callback) |
Deinitialize logging subsystem. | |
Undefined | warn (String|Object|Error message, Function|Undefined callback) |
Log specified message using WARN logging level. |
This module allows to log arbitrary messages. It is implemented on top of log4cplus logging library.
Message filtering is based on a specified log level and on a logger name. Loggers are ususally named using "dot notation": myapp.somemodule
, myapp.somemodule.submodule
etc. Allowed logging level configured for "parent" logger (named myapp
in this case will apply to these examples unless special logging level will be configured for them.
For most applications (excluding small scripts) it is expected that logging is configured using Logger.initialize()
during the application startup.
Logger
instances are effectively "stateless" (only state is a logger name) - they don't hold additional native resources through handles.
Usage example:
Undefined Logger::debug | ( | String|Object|Error | message, |
Function|Undefined | callback | ||
) |
Logs specified message using DEBUG
logging level.
String
messages are logged as-is, Object
s are converted to JSON, stacktrace are extracted from specified Error
s.
message | String|Object|Error message to log |
callback | Function|Undefined callback to receive result or error |
Undefined
Undefined Logger::error | ( | String|Object|Error | message, |
Function|Undefined | callback | ||
) |
Logs specified message using ERROR
logging level.
String
messages are logged as-is, Object
s are converted to JSON, stacktrace are extracted from specified Error
s.
message | String|Object|Error message to log |
callback | Function|Undefined callback to receive result or error |
Undefined
Undefined Logger::info | ( | String|Object|Error | message, |
Function|Undefined | callback | ||
) |
Logs specified message using INFO
logging level.
String
messages are logged as-is, Object
s are converted to JSON, stacktrace are extracted from specified Error
s.
message | String|Object|Error message to log |
callback | Function|Undefined callback to receive result or error |
Undefined
|
static |
Initializes logging subsystem using only CONSOLE
appender and without using specific settings for separate logger.
threshold | String threshold logging level for CONSOLE appender, must be one of TRACE , DEBUG , INFO , WARN , ERROR , FATAL |
callback | Function|Undefined callback to receive result or error |
Undefined
|
static |
Initializes logging subsystem
Should be called as early as possible on application startup.
options | Object configuration object, see possible options below |
callback | Function|Undefined callback to receive result or error |
Undefined
Options
Array
list of appenders (log destinations) to configureString
type of the appender, supported values: NULL
, CONSOLE
, FILE
, DAILY_ROLLING_FILE
String|Undefined
path to the log file, relative path is resolved against current application directory path (that is one level above the executable directory path).String|Undefined
formatting layout for log messages, see log4cplus docs for details, default value: d{Y-m-d H:M:S,q} [%-5p %-5.5t %-20.20c] mn
String|Undefined
minimal logging level for this appender, supported values: TRACE
, DEBUG
, INFO
, WARN
, ERROR
, FATAL
Boolean|Undefined
whether to use lock file for DAILY_ROLLING_FILE
appender, default value: false
Integer|Undefined
max number of old (rolled over) log files for DAILY_ROLLING_FILE
appender, default value: 16
Array|Object
list of loggers to configure minimal allowed logging levelsString
logger name (Object
key can be used instead)String
minimal allowed logging level for this logger (Object
value can be used instead), supported values: TRACE
, DEBUG
, INFO
, WARN
, ERROR
, FATAL
Undefined Logger::log | ( | String|Object|Error | message, |
Function|Undefined | callback | ||
) |
Logs specified message using DEBUG
logging level.
String
messages are logged as-is, Object
s are converted to JSON, stacktrace are extracted from specified Error
s.
message | String|Object|Error message to log |
callback | Function|Undefined callback to receive result or error |
Undefined
Object Logger::Logger | ( | String|Undefined | name, |
Function|Undefined | callback | ||
) |
Creates Logger object instace with the specified name, that will be used to select the filtering level for all messages logged through this instance.
Created instance doesn't hold any additional native resources and doesn't need to be closed/destroyed explicitely.
name | String|Undefined logger name, default value: wilton |
callback | Function|Undefined callback to receive result or error |
Object
Logger instance
|
static |
Deinitialization is an optional operation, logging subsystem will be deinitilized automatically during the shutdown.
callback | Function|Undefined callback to receive result or error |
Undefined
Undefined Logger::warn | ( | String|Object|Error | message, |
Function|Undefined | callback | ||
) |
Logs specified message using WARN
logging level.
String
messages are logged as-is, Object
s are converted to JSON, stacktrace are extracted from specified Error
s.
message | String|Object|Error message to log |
callback | Function|Undefined callback to receive result or error |
Undefined