vv-logger
v0.1.7
Published
Small logger for nodejs backend app
Downloads
12
Readme
vv-logger
Small logger for nodejs backend app
License
MIT
Install
npm i vv-logger
Example
import path from 'path'
import {Create as LoggerManagerCreate} from 'vv-logger'
const logPath = path.join(__dirname, 'log')
const loggerManager = LoggerManagerCreate()
loggerManager.onError(error => {
console.error(error)
})
const logger = loggerManager.addLogger ({
consoleLevel: 'trace',
transports: [
{kind: 'file', dir: logPath, levels: ['error'], fileNamePrefix: 'error', fileLifeDay: 4},
{kind: 'file', dir: logPath, levels: ['debug', 'error'], fileNamePrefix: 'debug', fileLifeDay: 1},
{kind: 'file', dir: logPath, levels: ['trace', 'debug', 'error'], fileNamePrefix: 'trace'},
]
})
logger.trace('trace', {aa: 5}, {ccc: 23})
logger.debug('debug')
logger.debug('debug', {aa: 5}, {ccc: 23})
logger.error(new Error('error'))
logger.error('when i do anything', new Error('error'))
loggerManager.finish(() => {
console.log('LOGGER FINISH, ALL LOGGER BUFFERS SAVE TO TRANSPORTS (FOR EXAMPLE - IN FILES))
})