npm

Need private packages and team management tools?Check out npm Orgs. »

babel-plugin-simple-logger

1.1.1 • Public • Published

babel-plugin-simple-logger

npm npm

Special thanks to Michael Jungo for helping me put the first version together.

This Babel plugin looks for the string literal "log" after the opening bracket of a function and replaces it with console.log(<function name>, <arg1>, <arg2>, etc...).

const add = (a, b) => { 'log'
    return a + b
}
 
// becomes...
 
const add = (a, b) => {
    console.log('add', a, b)
    return a + b
}

Installation & Usage

Install the package

yarn add babel-plugin-simple-logger --dev

Incorporate the plugin

// .babelrc
...
"env": {
    "development": {
        "presets": ["react", "env", "stage-0"],
        "plugins": ["simple-logger"]
    },
...
}

Test it out

function greeter(name='world') { 'log'
    return `Hello, ${name}!`
}
 
greeter("Gus")
 
// logs...
 
greeter "Gus"

Note: Arrow functions with implicit returns (e.g. (a, b) => a + b) aren't candidates for logging with this plugin's syntax.

install

npm i babel-plugin-simple-logger

Downloadsweekly downloads

0

version

1.1.1

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability