This babel plugins hacks into your functions by using $log key and adds a console.log() statement with your return value. Here is how:
function sum(a, b) {
$log;
const result = a + b;
return result;
}
add(2, 3);
↓ ↓ ↓ ↓ ↓ ↓
function sum(a, b) {
const result = a + b;
console.log("Final Result 😛 ==> ", result);
return result;
}
add(2, 3);$ npm install @codefimba/babel-logger-plugin --save-dev
or
$ yarn add -D @codefimba/babel-logger-pluginThe solution requires you to have babel installed in your project.
Via .babelrc or babel-loader.
{
plugins: ["@codefimba/babel-logger-plugin"]
}Pull requests are most welcome!
- Faustino Kialungila - Inital code - @Fausto95_
- Bruno Kiafuka - Inital code - @bruno_kiafuka
See also the list of contributors who participated in this project.