The y'all's logger class
Kind: global class
- Logger
- new Logger([options])
- instance
- static
Constructor
Param | Type | Default | Description |
---|---|---|---|
[options] | object |
{} |
|
options.log | object |
The internal logger object (basically an object with four keys: debug, info, warn, error; functions that take a string as their only argument) | |
[options.namespace] | string |
"" |
The namespace for this logger |
[options.log_level] | string |
""info"" |
The log level for this logger |
[options.no_colors] | boolean |
false |
Whether to disable colors |
[options.format] | function |
A custom format function |
Check if the logger is colorized
Kind: instance property of Logger
Get the log level for this logger
Kind: instance property of Logger
Set the log level for this logger
Kind: instance method of Logger
Param | Type | Description |
---|---|---|
level | string |
The log level |
Create a debug log
Kind: instance method of Logger
Param | Type |
---|---|
string | string |
Create an info log
Kind: instance method of Logger
Param | Type |
---|---|
string | string |
Create a warn log
Kind: instance method of Logger
Param | Type |
---|---|
string | string |
Create an error log
Kind: instance method of Logger
Param | Type |
---|---|
string | string |
logger.create_child(namespace, [opts]) ⇒ Logger
Create a new logger namespaced under this one
Kind: instance method of Logger
Returns: Logger
- The new logger
Param | Type | Default | Description |
---|---|---|---|
namespace | string |
The namespace for the new logger (is appended onto this namespace) | |
[opts] | object |
{} |
any options to pass to the new logger's constructor (omissions are defaulted to this logger's options) |
Logger.noop() ⇒ Logger
Create a new logger, which does nothing
Kind: static method of Logger
Returns: Logger
- The new logger
Logger.console([namespace], [opts]) ⇒ Logger
Create a new logger that logs to the console
Kind: static method of Logger
Returns: Logger
- The new logger
Param | Type | Default | Description |
---|---|---|---|
[namespace] | string |
"" |
The namespace for the new logger |
[opts] | object |
{} |
any options to pass to the new logger's constructor |
Logger.callback(cb, [namespace], [opts]) ⇒ Logger
Create a new logger that logs to a callback function
The callback function is called with the following arguments:
- type: the type of log entry (debug, info, warn, error)
- string: the log entry string
Kind: static method of Logger
Returns: Logger
- The new logger
Param | Type | Default | Description |
---|---|---|---|
cb | function |
The callback function | |
[namespace] | string |
"" |
The namespace for the new logger |
[opts] | object |
{} |
any options to pass to the new logger's constructor |