Skip to content

This babel plugin creates a log statement on your functions

License

Notifications You must be signed in to change notification settings

Fimba-Code/babel-logger-plugin

Repository files navigation

babel-logger-plugin 🔍

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);

Installation

$ npm install @codefimba/babel-logger-plugin --save-dev
or
$ yarn add -D @codefimba/babel-logger-plugin

The solution requires you to have babel installed in your project.

Usage

Via .babelrc or babel-loader.

{
  plugins: ["@codefimba/babel-logger-plugin"]
}

Contributing

Pull requests are most welcome!

Authors

See also the list of contributors who participated in this project.