2019.1.0 • Published 5 years ago

console-logging v2019.1.0

Weekly downloads
8
License
ISC
Repository
github
Last release
5 years ago

console-logging

A wrapper around usual console.log() - This is a utility that I want to use along my frontend projects where I need to include logs for debugging and can easily turn them on/off by setting the logging level.

Usage

const logging = require("console-logging");
const logger = logging.logger;

or ES6 import

import {LOGGING_LEVELS, logger } from 'console-logging';

The use case of logger.setLevel() is in production environment, just switch on/off the logger and you have extra debug logs! So remember to include logger.xyz() during app development.

logger.setLevel(logging.LOGGING_LEVELS.CRITICAL)
logger.setLevel("CRITICAL")  // Supports string levels: DEBUG, INFO, WARNING, ERROR, CRITICAL

// or get level from environment variable
logger.setLevel(process.env.LOGGING_LEVEL)  // process.env.LOGGING_LEVEL = "DEBUG|INFO|WARNING|ERROR|CRITICAL"

logger.error("Transaction fail, transaction id 1")  // No output

logger.setLevel(logging.LOGGING_LEVELS.ERROR)
logger.error("Transaction fail, transaction id 1")  // Output 'Transaction fail, transaction id 1'

// multi-args is supported
logger.error("Hi", "I am", "an error")  // Output 'Hi I am an error'
2019.1.0

5 years ago

2018.1.1

6 years ago

2017.0.5

7 years ago

2017.0.4

7 years ago

2017.0.3

7 years ago

2017.0.2

7 years ago

2017.0.1

7 years ago