shared-log
v1.2.8
Published
Decoupled logging for libraries
Downloads
243
Readme
shared-log
Decoupled logging for libraries
Usage
Libraries should import shared-log
and treat it as write-only.
"Reading" the log (via event listener) is reserved for the end user.
import log from 'shared-log'
// The log function is console.log by default
log('all arguments', 'are passed thru')
// Log methods exist for each log level
log.error(new Error('ruh roh'))
log.warn(...)
log.info(...)
log.verbose(...)
log.debug(...)
The end user hooks up their logging library of choice.
import log from 'shared-log'
// Listen to every log level
log.on('all', (level, args, filename) => {...})
// or a specific log level
log.on('error', (args, filename) => {...})
If the end user doesn't add a log listener, the console
is used by default, but the debug
and verbose
log levels are ignored by default.