winston-this
This is a simple winstone logger module to add on your NodeJS project
Install
npm install winston-this
Usage
Create a log instance
const logger = require('winston-this')();
logger.info('Hello');
// 2017-10-24T12:00:00.000Z - info: Hello - [level:INFO]
Create a log instance with a custom tag to identify it
const logger = require('winston-this')('api');
logger.info('Hello');
// 2017-10-24T12:00:00.000Z - info: Hello - [name:api] [level:INFO]
Tag Usage
You can pass tags to pass more information
logger.info('Hello', { user: 'arielfr' });
// 2017-10-24T12:00:00.000Z - debug: Hello - [name:api] [user:arielfr] [level:DEBUG]
Log Levels
To specify a log level you can use the environmental variable LOG_LEVEL
.
PROCESS.env.LOG_LEVEL = 'DEBUG';
The default log level is INFO
License
Copyright 2017