@pubsweet/logger
v0.2.61
Published
A module encapsulating standard logging features for pubsweet components and services.
Downloads
646
Readme
A module encapsulating standard logging features for pubsweet components and services.
Usage
Either:
const myLogger = require('winston') // or something else
const logger = require('@pubsweet/logger')
logger.configure(myLogger)
Or set the logger in config:
const myLogger = require('winston') // or something else
{
'pubsweet-server':{
logger: myLogger
}
}
The configured logger can then be imported from anywhere:
const logger = require('@pubsweet/logger')
logger.info('log')
The logger exposes the following methods:
info
debug
error
warn
configure
getRawLogger
(returns the logger passed toconfigure
)
As well as:
stream
(an object for passing tomorgan
)
Note that the logger used to configure the module must implement error
, warn
, info
and debug
functions.