0.3.10 • Published 3 years ago
@alu0100901214/espree-logging-module v0.3.10
Espree-logging-module
Table of Contents
Installation
npm install @alu0100901214/espree-logging-module --save
Executable
Executable usage:
Usage: logging-espree [options] <filename> [...]
Es un programa para parsear un fragmento de código.
Options:
-V, --version output the version number
-o, --output <filename> write the output on a filename
-p, --pattern <pattern> indicates the pattern of the function you want to add a log
-h, --help display help for command
Code
Code usage:
const addlogging = require('@alu0100901214/espree-logging-module/src/logging-espree');
Example
npx addlogging input.js -o output.js
Input
function foo(a, b, c) {
let x = 'tutu';
let y = (function (x) { return x*x })(2);
let z = (e => { return e +1 })(4);
}
foo(1, 'wut', 3);
Output
function foo(a, b, c) {
console.log(`Entering foo(${ a },${ b },${ c }) at line 1`);
let x = 'tutu';
let y = function (x) {
console.log(`Entering <anonymous function>(${ x }) at line 3`);
return x * x;
}(2);
let z = (e => {
console.log(`Entering <anonymous function>(${ e }) at line 4`);
return e + 1;
})(4);
}
foo(1, 'wut', 3);
addLogging
Add console.log in every Function.
Parameters
code
string String with the code.
Returns string Return the string with the console.log inserted.
Pattern
Pattern option:
You can use a regex pattern that allows you to locate the name of a function and add the console.log to it.
Example
npx addlogging input.js -p fo* -o output.js
Input
function foo(a, b, c) {
let x = 'tutu';
let y = (function (x) { return x*x })(2);
let z = (e => { return e +1 })(4);
}
foo(1, 'wut', 3);
Output
function foo(a, b, c) {
console.log(`Entering foo(${ a },${ b },${ c }) at line 1`);
let x = 'tutu';
let y = function (x) {
return x * x;
}(2);
let z = (e => {
return e + 1;
})(4);
}
foo(1, 'wut', 3);