Fast and lightweight colorful JS Logger for the browser and Nodejs. It is a perfect logger that supports all browsers.
It allows to print color logs with pre-defined 5 levels of logging (info
, warning
, error
, success
, debug
). You can enable the VERBOSE
flag to print debug logs during the development phase and you can disable it by setting VERBOSE
flag to false to avoid printing confidential logs in production.
- Fast and lightweight
- Supports multi-color for browser console logs
- Records all types of logs and allow download it as a file
- None
You can install colorjslogger as a dependency using NPM.
$ npm install colorjslogger --save
You can install colorjslogger as a dependency using Yarn.
$ yarn add colorjslogger
json2csv plainjs modules is packaged as an ES6 modules. If your browser supports modules, you can load json2csv plainjs modules directly on the browser from the CDN.
You can import the latest version:
<script type="module">
import jslogger from 'https://cdn.jsdelivr.net/npm/colorjslogger@latest/src/jslogger.min.js';
jslogger.info('JSLOGGER', 'Imported ES6Module directly in the browser');
</script>
You can also select a specific version:
<script type="module">
import jslogger from 'https://cdn.jsdelivr.net/npm/colorjslogger@3.0.1/src/jslogger.min.js';
jslogger.info('JSLOGGER', 'Imported ES6Module directly in the browser');
</script>
try {
jslogger.info(process, message);
jslogger.warning(process, message);
jslogger.error(process, message);
jslogger.success(process, message);
jslogger.internal(process, message);
jslogger.debug(process, message);
} catch (err) {
console.error(err);
}
- process (string): Name of the process or a function in which it is used.
- message (string): Actual log message that needs to log in the console.
Debug logs will only work if the VERBOSE
property is set to true. Here is an example how to do it:
jslogger.setLevelToVerbose(true);
jslogger.info('Authentication', 'Connection in progress');
Mon Aug 12 2019 22:37:57 | JSLogger | [Authentication] :: Connection in progress
Date and Time | AppName | [Process] :: Message
jslogger.setAppName('SuhaibJanjuaLogger');
jslogger.info('Authentication', 'Connection in progress');
Mon Aug 12 2019 22:37:57 | SuhaibJanjuaLogger | [Authentication] :: Connection in progress
Use the internal method to skip the confidential or sensitive data to appear in the console logs. It will be helpful to record the logs in the memory and will be a part of the log file when you download it.
jslogger.internal('Authentication', 'User with email su****************.com just logged in.');
You can download the recorded logs by the following method:
jslogger.downloadLogs()
See LICENSE.md.