1.0.2 • Published 5 years ago
yolog v1.0.2
yoLog
What is it?
yoLog is a comfort
utility for troubleshooting
Node.js apps in dev.
It formats console logs
to make them stand out from the noise, and easy to find
.
- Detects the variable's name, and prints it in colour before rendering its content
- Renders the variable content in prettier and indented JSON format
- Limits the rendering of nested properties to 2 levels deep
- Allows full rendering of deeply nested objects when needed
- For kicks: shows how much time the fancy logging took
See examples below.
Install instructions
Install as an Optional Dependency
npm i -O yolog
Or as a Dev Dependency
npm i -D yolog
Then require it in your projects
const yoLog = require('yolog');
How to use
Instead of typing:
console.log(`myVar: ${myVar}`);
// or
console.log(`myVar: ${JSON.stringify(myVar)}`);
just type:
yoLog({myVar});
and if you need to be able to read the values of deeply nested properties:
yoLog({myVar}, 1);
// or
yoLog({myVar}, true);
Examples
See github page for screenshots.
Why the name
- My name is Johan, pronounced "Yoan".
Y
ouO
nlyLog
one... var at a time!
Misc
The logs have been tested on both black and white background in:
Var names are shown in Magenta because it is one of the most consistant colours accross terminals.