So we probably all know and love console.log() right? And we sometimes (or always) use it instead of an debugger right?
So why not make it enjoyable?
- Keep cLog statements in your production code. It will not be printed.
- COLORS and Unicode. What would you want more?
- Different message types: Information (probably the most used one), error and sucess
- kind of easy to use ↓
Install ClDebug npm install cldebug
.
As already mentioned your console logs will only be printed in the dev environment. To do this simply call the initClDebug function. Example:
import { initClDebug } from 'cldebug';
//Example:
if(environment === 'DEV') {
initClDebug();
}
First of all import it:
import cLog from "cldebug";
The cLog function takes 2-3 arguments:
cLog('type', 'message/content', 'expected behavior');
Information:
info, inf, if, i
Logs an information in a beautiful blue.
Error:
error, err, er, e
Logs an error in red.
Success:
sucess, suc, su, s
Green message with checkmark, great for "checkpoints".
Self explaining. What you would normally write console.log(HERE).
Optional. Puts the defined expected behavior after the message. Example:
var number = random.nextInt(10 - 1 + 1) + min;
cLog('i', number, '5');