Logging decorator for Node and Browsers
npm install log-decorator --save
babel.config.js
const plugins = [
['@babel/plugin-proposal-decorators', { 'legacy': true }]
]
module.exports = { plugins }
import log from 'log-decorator';
class A {
constructor() {}
@log
get(a,b,c) {
return 3;
}
}
new A().get({ a: 2 }, 2)
$ get method called with [ { a: 2 }, 2 ]
$ get method returns 3