tilog
v1.0.4
Published
New-wheel logger, just do it
Downloads
3
Readme
tilog
A static logger configuration for NodeJs service, wrapping winston.
- Short logging api: as it should be
- File based, rotated log (daily plus size limit)
- Console output is enabled in dev mode
- Log file/module name, instance name (for cluster mode)
- NodeJs default console.log/util.format convension
- Tiny code
const log = require('tilog')(__filename)
//easy api
log('basic')
//explicit level
log.debug('basic')
log.info('basic')
log.warn('basic')
log.error('basic')
//formatting
let d = {a: 1, b:'Transylvania'}
log('Formatting: %d %s %j', 12345, 'welcome to', d)
log('test error with stack:', new Error('demo'))
//Customizable label for cluster environment to distinguish child processes
log.config({
instanceName: 'ClusterWorker/1'
})
log('With instance info. Useful for cluster environment')
const log2 = require('tilog')('/anotherModule/index.js')
log2('Message from another module')