named-logs-console

console logger using named-logs facade for minimal lib overhead with full control


Keywords
console, logger, logging
License
MIT
Install
npm install named-logs-console@0.3.0

Documentation

introduction

named-logs-console is an implementation of named-logs facade that redirect all call to console, preserving file/line.

It support namespace filtering like debug as well as log levels

By default the log level is 2 (warn)

install

npm install named-logs named-logs-console

use

in your index.js :

import {hookup} from 'named-logs-console';
hookup();

This will be default log all named-logs call

On a web page,

if the query string contains debug=<namespace> it will enable only the namespaces listed there (separated per commas)

if the query string contains log=<logLevel> it will set the global log level to the one specified.

For logging inside the app you can import named-logs This will allow you to extract that code into the library without importing the overhead of named-logs-console

import {logs} from 'named-logs';
const console = logs('app:test');

console.log('whatever you want');
console.error('an error occured');

But you can still access named logs via named-logs-console even one created by libraries and disable them programmatically for example:

import {logs} from 'named-logs-console';
logs('myLibrary').enabled = false;

You can also set global settings

import {logs} from 'named-logs-console';
logs.level = 0; // desactivate all