Skip to content

Latest commit

 

History

History
156 lines (109 loc) · 5.18 KB

API.md

File metadata and controls

156 lines (109 loc) · 5.18 KB

Logger

The y'all's logger class

Kind: global class

new Logger([options])

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

logger.colorized : boolean

Check if the logger is colorized

Kind: instance property of Logger

logger.log_level : string

Get the log level for this logger

Kind: instance property of Logger

logger.set_log_level(level)

Set the log level for this logger

Kind: instance method of Logger

Param Type Description
level string The log level

logger.debug(string)

Create a debug log

Kind: instance method of Logger

Param Type
string string

logger.info(string)

Create an info log

Kind: instance method of Logger

Param Type
string string

logger.warn(string)

Create a warn log

Kind: instance method of Logger

Param Type
string string

logger.error(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