console logger using named-logs facade for minimal lib overhead with full control
npm install named-logs-consolenamed-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)
``bash`
npm install named-logs named-logs-console
or for web page, depending of your bundlerm instead of installing/importng named-logs-console you might be better of simply injecting the following in your html page (in the head) :
``
Note that you still need to install and import named-logs if you intent to use to emit logs from your application. (if you only intent to see logs from extermal libraries, you do not need anything)
in your index.js :
`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= it will enable only the namespaces listed there (separated per commas)
if the query string contains debugLevel= it will set the global log level to the one specified.
if the query string contains traceLevel= it will set the transform any log with level lower or equal as trace (console.trace)
For logging inside the app you can import named-logsnamed-logs-console
This will allow you to extract that code into the library without importing the overhead of
`js
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:
`js`
import {logs} from 'named-logs-console';
logs('myLibrary').enabled = false;
You can also set global settings
`js``
import {logs} from 'named-logs-console';
logs.level = 0; // desactivate all