tilog

1.0.4 • Public • Published

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')

tilog screenshot

Readme

Keywords

Package Sidebar

Install

npm i tilog

Weekly Downloads

7

Version

1.0.4

License

MIT

Unpacked Size

9.74 kB

Total Files

8

Last publish

Collaborators

  • nanw