scrwdrv / colorful-log

Simple, lightweight and good looking logger.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

colorful-log

Simple, lightweight and good looking logger.

Installation

npm i colorful-log

Usage

All the options are optional, you can even just use new Logger() without passing any opts.

import Logger from 'colorful-log';

const log = new Logger({
    debug: false, // default is set to true
    path: './logs', // which is default
    system: 'test',
    cluster: 0,
    saveInterval: 60000 // 60 secs
})

log.info('info');
log.warn('warn');
log.error('error');
log.debug('debug'); // won't print out since debug is set to false, but still save to log files

throw new Error('fatal'); 
// uncaughtException & unhandledRejection will be catched and logged, then exit (as it should be)

Manual Save

log.save() method returns a Promise, it's the same method that was called when saveInterval reached.

(async () => await log.save().catch(log.error))();

About

Simple, lightweight and good looking logger.

License:MIT License


Languages

Language:TypeScript 100.0%