new Log(name)
Constructs a child logger with the same attributes as the default logger.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of this module, which will be logged with each line. |
Methods
-
static addStream(obj)
-
Adds a stream to the logger. See Bunyan documentation for details. Note that NPM has logging streams for nearly any logging service (syslog, CloudWatch, Slack, Logstash, etc.)
Parameters:
Name Type Description obj
object The stream object to be added.
-
static debug(…args) → {undefined}
-
Log a message at the
debug
level.Parameters:
Name Type Attributes Description args
* <repeatable>
See Bunyan documentation for a description of possible args
Returns:
undefined -No return
-
static error(…args) → {undefined}
-
Log a message at the
error
level.Parameters:
Name Type Attributes Description args
* <repeatable>
See Bunyan documentation for a description of possible args
Returns:
undefined -No return
-
static fatal(…args) → {undefined}
-
Log a message at the
fatal
level.Parameters:
Name Type Attributes Description args
* <repeatable>
See Bunyan documentation for a description of possible args
Returns:
undefined -No return
-
static getBaseLogger() → {object}
-
Returns the logger object created by Bunyan
-
static getMainLogger() → {object}
-
Returns the child logger object named
main
-
static getStdoutLevel() → {object}
-
Gets the current logging level for the default stdout stream.
Returns:
object -An object describing the current logging level. Properties are
levelName
, a string describing the current log level name andlevelValue
a corresponding number for the current log level. -
static info(…args) → {undefined}
-
Log a message at the
info
level.Parameters:
Name Type Attributes Description args
* <repeatable>
See Bunyan documentation for a description of possible args
Returns:
undefined -No return
-
static init()
-
Initializes the Logger
-
static levelToName(level) → {number}
-
Convert logging level number to a name (e.g. 50 -> "error")
Parameters:
Name Type Description level
number The logging level number to convert
Returns:
number -The logging level name
-
static nameToLevel(name) → {number}
-
Convert name to a logging level number (e.g. "error" -> 50)
Parameters:
Name Type Description name
string The logging level name to convert
Returns:
number -The logging level number
-
static patch()
-
Patches
console.log
(and kin) to use Log -
static print(…args) → {undefined}
-
Uses the original
console.log
to write the args toprocess.stdout
Parameters:
Name Type Attributes Description args
* <repeatable>
See Console for a description of arguments
Returns:
undefined -No return
-
static printErr(…args) → {undefined}
-
Uses the original
console.error
to write the args toprocess.stderr
Parameters:
Name Type Attributes Description args
* <repeatable>
See Console for a description of arguments
Returns:
undefined -No return
-
static setStdoutLevel(level)
-
Sets the logging level of messages. All messages at or above this level will be logged.
Parameters:
Name Type Description level
"trace" | "debug" | "info" | "warn" | "error" | "fatal" | number A recognized log level string or a number associated with the log level.
-
static trace(…args) → {undefined}
-
Log a message at the
trace
level.Parameters:
Name Type Attributes Description args
* <repeatable>
See Bunyan documentation for a description of possible args
Returns:
undefined -No return
-
static unpatch()
-
After calling Log.patch, returns
console.log
(and kin) to its original state -
static warn(…args) → {undefined}
-
Log a message at the
warn
level.Parameters:
Name Type Attributes Description args
* <repeatable>
See Bunyan documentation for a description of possible args
Returns:
undefined -No return
-
debug(…args) → {undefined}
-
Log a message at the
debug
level.Parameters:
Name Type Attributes Description args
* <repeatable>
See Bunyan documentation for a description of possible args
Returns:
undefined -No return
-
error(…args) → {undefined}
-
Log a message at the
error
level.Parameters:
Name Type Attributes Description args
* <repeatable>
See Bunyan documentation for a description of possible args
Returns:
undefined -No return
-
fatal(…args) → {undefined}
-
Log a message at the
fatal
level.Parameters:
Name Type Attributes Description args
* <repeatable>
See Bunyan documentation for a description of possible args
Returns:
undefined -No return
-
info(…args) → {undefined}
-
Log a message at the
info
level.Parameters:
Name Type Attributes Description args
* <repeatable>
See Bunyan documentation for a description of possible args
Returns:
undefined -No return
-
trace(…args) → {undefined}
-
Log a message at the
trace
level.Parameters:
Name Type Attributes Description args
* <repeatable>
See Bunyan documentation for a description of possible args
Returns:
undefined -No return
-
warn(…args) → {undefined}
-
Log a message at the
warn
level.Parameters:
Name Type Attributes Description args
* <repeatable>
See Bunyan documentation for a description of possible args
Returns:
undefined -No return