1.0.2 • Published 7 years ago
mw-hapi-pino v1.0.2
mw-hapi-pino
Registers the Pino logger.
This is a fork of the hapi-pino project.
Options
[extensions]
- an object extending logging capabilities under specified conditions. The object has the extensions name as key and an array of applicable conditions as value, for example:{ responsePayload: ['urlfragment'] }
. Supported extensions:responsePayload
- logs response payload for requests coming to the specified urls).[level]
- the logging level, can be one oftrace
,debug
,info
,warn
, anderror
.[stream]
- the binary stream to write stuff to, defaults toprocess.stdout
.[prettyPrint]
- pretty print the logs (same asnode server | pino
), disable in production. Default isfalse
, enable in development by passingtrue
.[tags]
- a map to specify pairs of Hapi log tags and levels. By default, the tags trace, debug, info, warn, and error map to their corresponding level. Any mappings you supply take precedence over the default mappings. The default level tags are exposed viahapi-pino.levelTags
.[allTags]
- the logging level to apply to all tags not matched bytags
, defaults to'info'
.[instance]
- uses a previously created Pino instance as the logger. The instance'sstream
andserializers
take precedence.[logEvents]
- Takes an array of strings with the events to log. Default is to log all events e.g.['onPostStart', 'onPostStop', 'response', 'request-error']
. Set tofalse/null
to disable all events.[mergeHapiLogData]
- When enabled, Hapi-pino will merge the data received from Hapi's logging interface (server.log(tags, data)
orrequest.log(tags, data)
) into Pino's logged attributes at root level. If data is a string, it will be used as the value for themsg
key. Default isfalse
, in which case data will be logged under adata
key.
Decorations
The Hapi server is decorated with:
server.logger()
, which is a function that returns the current instance of pino, see its doc for the way to actual log.server.app.logger
, same as before, but the logger it is also attached to theserver.app
object.
The Hapi request object is decorated with:
request.logger
, which is an instance of pino bound to the current request, so you can trace all the logs of a given request.
1.0.2
7 years ago