Captain's Log (☠️)
![codecov](https://codecov.io/gh/kwelch/babel-plugin-captains-log/branch/master/graph/badge.svg?style=flat-square)
![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)
![Tweet](https://img.shields.io/twitter/url/https/github.com/kwelch/babel-plugin-captains-log.svg?style=social)
Usage
babel-plugin-captains-log
injects helpful details into console statements.
Default bahavior:
- Prepend console statement scope
- add inject variable name into console statements
Transforms
function add(a, b) {
- console.log(a, b);
+ console.log("add:", "a", a, "b", b);
return a + b;
}
const subtract = (a, b) => {
- console.log(a, b);
+ console.log("subtract:", "a", a, "b", b);
return a - b;
};
See the Roadmap for a future features and oppurtunities to contribute.
Requirements
This is a Babel plugin so it requires Babel v6 to run.
Installation
This module is distributed using npm which comes bundled with node:
npm install --save-dev babel-plugin-captains-log
To include the plugin in your project, create or open your .babelrc file at the root of your project. Then, add namespaces to your plugin list:
{
plugins: ["captains-log"]
}
Options
Methods
This option provides control over which console statments are adjusted. Methods is set within your .babelrc
as an array.
Default: ["debug", "error", "exception", "info", "log", "warn"]
{
plugins: [
["captains-log", {
methods: ['debug', 'info']
}]
]
}
Flags
Flags are values set for all methods and are used to turn that feature on or off. Flags are not merged with defaults to allow for maximum control.
Variable Name
Default: true
{
plugins: [
["captains-log", {
injectVariableName: true
}]
]
}
Inject Scope
Default: true
{
plugins: [
["captains-log", {
injectScope: true
}]
]
}
Inject File Name
Default: false
{
plugins: [
["captains-log", {
injectFileName: true
}]
]
}
Roadmap
License
MIT
Contributors
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!