0.0.1 • Published 4 years ago

@comodinx/logger v0.0.1

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
4 years ago

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 variableValuesTypeDefault value
LOGGER_ENABLEDtrue/falsebooleantrue
LOGGER_SILENTtrue/falsebooleanfalse
LOGGER_LEVELhttp,info,warn or errorstringhttp
LOGGER_FORMATsimple,json or combinestringcombine
LOGGER_TRANSPORTSconsole,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