loogy v0.0.5
Loogy
Loogy is another log library written with the intent to be lightweight and customizable
Installation
With npm up to date:
$ npm install loogy
Usage
const log = require('loogy');
log.success('Yayy');
API
log.<level>([text][,options])
,
where <level>
can be one of the following:
- success
- info
- warn
- error
- a custom level created by you
Options
- tag:
<string>
Default:<level>
; The text for the tag - textColor:
<string>
Default:null
; The color of the text passed as first argument. Can be any valid Chalk color chain as defined here
Custom level
You can create a custom logger by setting a new object in log
.
log.customLevel = options
where options
can contain:
- sequence:
<string>
; A string describing the output. - tag:
<string>
Default:customLevel
; The text for the tag
The sequence
property is a string where some variables will be injected. Availables variables are:
- tag : The tag
- time: The time in hh:mm:ss format
- text: The text passed to the function when used
Variables are inside <
and >
.
You can also modify variables color by passing a valid Chalk color chain before the variable name, separated by a space.
Example: <bold.blue.bgGreen time>
You can also modify text outside variables by surrounding it with {
and }
, and using the same process as described before. See examples below.
Examples
const log = require('loogy');
log.info();
log.warn();
log.error();
log.success();
log.error('An error occured.');
log.warn('You should pay attention !!');
log.info(' This is a yellow underline bold text', {
tag: 'waow',
textColor: 'yellow.underline.bold'
});
log.custom1 = {
sequence: '<bgBlue tag> it is <italic.underline.magenta time>, {yellow sweet}<red.bold text>',
tag: 'what time is it ?'
};
log.custom1('heart');
log.incomming = { sequence: '>>> ~~<blue.bold time>~~ <bold text>' };
log.incomming('This is an incomming message');
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.