griffinwinston3

0.9.5 • Public • Published

griffinwinston

Wraps around winston to create a plug'n play logger. Unlike winston, it's not a pain to setup.

TL;DR

Run npm install griffinwinston

Add to code

import {logger as GWinston} from 'griffinWinston';
const logger = new GWinston();
// test examples
logger.debug('debug');
logger.info('info');
logger.error('error');

Less will be logged to files if process.env.NODE_ENV === "production", and nothing will be logged to console.

Configuration

import {logger as GWinston} from 'griffinWinston';
const config { consoleColors: true, // Shall colors be used in console? (Default true)
consoleJson: 'silly', // consoleJson or consoleText can be used depending on what format you want the data in.
fileColors: true, // Shall colors be used in files? (Default false)
fileJson: 'silly', // Level of logging to Json log files
fileText: ['debug','info','warn', 'error'] // Level of logging to text log files
label: 'myApp' // Label on the lines in the logging. Defaults to folder + running program filename. }

const logger = new GWinston(config);
logger.debug('debug');
logger.info('info');
logger.error('error');

Already using console.log, console.debug, console.error

The following will replace console.* to the one one with the same name that exists in winston.
Please note that this is global, so don't use this if you are building a module as it will change things for mainprogram and other modules, and that will surprise users as well as future you ;)

Add to code

import {logger as GWinston} from 'griffinWinston';
const logger = new GWinston();
console.error = (...args) => logger.error(...args); // standard console
console.warn = (...args) => logger.warn(...args); 
console.log = (...args) => logger.info(...args); // standard console
console.info = (...args) => logger.info(...args); // standard console
console.verbose = (...args) => logger.verbose(...args);
console.debug = (...args) => logger.debug(...args);
console.silly = (...args) => logger.silly(...args);

Readme

Keywords

Package Sidebar

Install

npm i griffinwinston3

Weekly Downloads

2

Version

0.9.5

License

ISC

Unpacked Size

10.8 kB

Total Files

5

Last publish

Collaborators

  • andreasgrip