@daniel-del-castillo/add-logging
v1.0.0
Published
Adds logs to javascript code
Downloads
1
Maintainers
Readme
add-logging
Daniel del Castillo de la Rosa
add-logging is a package that allows to add logs to javascript code. You can use the binary or call the function addLogging
in your code.
Usage as executable:
Usage: add-logging [options] <filename>
Adds logs to javascript code
Arguments:
filename file with the original code
Options:
-V, --version output the version number
-o, --output <filename> file in which to write the output (default: "output.js")
-p, --pattern <pattern> regexp pattern that matchs the desired functions
-h, --help display help for command
Usage from code:
const addLogging = require('add-logging');
//call the function
The documention of the function.
Example of changes made:
function foo(a, b) {
var x = 'blah';
var y = (function (z) {
return z+3;
})(2);
}
foo(1, 'wut', 3);
function foo(a, b) {
console.log(`Entering foo(${ a }, ${ b }) at line 1`);
var x = 'blah';
var y = function (z) {
console.log(`Entering <anonymous function>(${ z }) at line 3`);
return z + 3;
}(2);
}
foo(1, 'wut', 3);
Installation
npm install @daniel-del-castillo/add-logging --save
Tests
You should be able to run the tests using:
npm i && npm run cov