0.0.5 • Published 5 years ago

loogy v0.0.5

Weekly downloads
1
License
MIT
Repository
gitlab
Last release
5 years ago

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();

tags.png

log.error('An error occured.');

error.png

log.warn('You should pay attention !!');

warn.png

log.info('      This is a yellow underline bold text', {
        tag: 'waow',
        textColor: 'yellow.underline.bold'
});

waow.png

log.custom1 = {
        sequence: '<bgBlue tag> it is <italic.underline.magenta time>, {yellow sweet}<red.bold text>',
        tag: 'what time is it ?'
};
log.custom1('heart');

custom1.png

log.incomming = { sequence: '>>> ~~<blue.bold time>~~ <bold text>' };
log.incomming('This is an incomming message');

incomming.png

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.

License

MIT

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago