Logger
@comodinx/logger is a Node.js logger helper based on winston.
Index
Download & Install
NPM
npm install @comodinx/logger
Source code
$ git clone https://gitlab.com/comodinx/logger.git
$ cd logger
$ npm install
How is it used?
Configure
Environment variable | Values | Type | Default value |
---|---|---|---|
LOGGER_ENABLED | true/false | boolean | true |
LOGGER_SILENT | true/false | boolean | false |
LOGGER_LEVEL | http,info,warn or error | string | http |
LOGGER_FORMAT | simple,json or combine | string | combine |
LOGGER_TRANSPORTS | console, | string list (,) | console |
file, | |||
file:<filepath>:<log level>, | |||
stream:<filepath>, | |||
http:<host>:<port>:<path>:<auth>:<ssl> |
Examples,
LOGGER_TRANSPORTS=console,file:.access.log,file:.errors.log:error
Logger
const logger = require('@comodinx/logger');
logger.error(new Error('Not Found')); // [2020-01-28T17:16:50.379Z] - ERROR - ✘ Ooops... Error: Not Found
logger.error('This is an error'); // [2020-01-28T17:16:50.379Z] - ERROR - ✘ Ooops... This is an error
logger.warn('This is a warning'); // [2020-01-28T17:16:50.381Z] - WARN - ⚠ This is a warning
logger.info('Hello World!'); // [2020-01-28T17:16:50.381Z] - INFO - Hello World!
logger.title('Hello World!'); // [2020-01-28T17:16:50.382Z] - INFO - ========== Hello World! ==========
logger.success('Hello World!'); // [2020-01-28T17:16:50.383Z] - INFO - ✔ Hello World!
logger.arrow('Hello World!'); // [2020-01-28T17:16:50.384Z] - INFO - • Hello World!
logger.step('Hello World!'); // [2020-01-28T17:16:50.384Z] - INFO - ✦ Hello World!
logger.lap('Hello World!'); // [2020-01-28T17:16:50.384Z] - INFO - ➜ Hello World!
Tests
In order to see more concrete examples, I INVITE YOU TO LOOK AT THE TESTS :)
Run the unit tests
npm test