bunyaner
Deprecation Notice:
This module has been superceded by @northscaler/bunyaner and will no longer be maintained.
Breaking changes in @northscaler/bunyaner:
The following breaking changes need to be addressed when upgrading to @northscaler/bunyaner
:
- The function exported by
require(@northscaler/bunyaner)
uses deconstruction instead of positional parameters. - All object payloads, including
Error
s, are placed under thepayload
field; the field name is configurable via optionpayloadKey
. - When an
Error
is logged, there is a newisError
field in the log record that contains the boolean Literaltrue
(not a string); the field name is configurable via optionerrorIndicatorKey
. - It is also configurable whether you want to include
isError: false
when non-Error
s are logged using optionalwaysShowErrorIndicator
.
Overview
Make bunyan's log level methods much mo' betta' with mo' bunyan-y flavor:
- always returns the first argument given
- if any key on
arguments[0]
conflicts with bunyan's core logging fields, wrapsarguments[0]
with{ object: arguments[0] }
in the logging level call
TL;DR
Install bunyan
(if you haven't already) & bunyaner
:
$ npm i --save bunyan$ npm i --save bunyaner
Create a file that your module will use to get a logger:
// log.jsconst bunyan = const bunyaner = moduleexports =
Now use it:
const log = let gameState = log // logs state object & returns it // ...querky123 plays game to level 5... gameState = log // logs gameState as { object: gameState } & returns gameState if gameStatebadness // log method logs given error, then returns it so it can be thrown throw log