@accubits/logger

1.0.4 • Public • Published

logger

N|Solid

Build Status

A simple Node.js logging library that overrides console methods

Installation

Install the package with:

npm i @accubits/logger

USAGE

  • Require and initalize the logger at the very begening of the entry point of your Node.js application
  • If you are using express require and initalize the logger in bin/www file
  • Logger can override 4 console methods ("debug","info","log","warn"), depending on the initalization, by default it will overide all the four methods.
const logger = require('@accubits/logger');
logger.init({
    methods : ["debug","info","log","warn"],
    env : "production"
});

env value will be production if its not provided.

methods will be ["debug","info","log","warn"] if its not provided.

Logging

index.js

const logger = require('@accubits/logger');
logger.init({
    methods : ["debug","log","warn"],
    env : "production"
});

console.log("logging here");
console.warn("warning log");
console.info("info log");

$ node index.js

Output will be

logging here
warning log
info log

$ production=true node index.js

Output will be

info log

Package Sidebar

Install

npm i @accubits/logger

Weekly Downloads

2

Version

1.0.4

License

MIT

Unpacked Size

4.35 kB

Total Files

5

Last publish

Collaborators