0.3.10 • Published 3 years ago

@alu0100901214/espree-logging-module v0.3.10

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Espree-logging-module

npm (scoped)

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);
0.3.10

3 years ago

0.3.9

3 years ago

0.3.8

3 years ago

0.3.7

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.5

3 years ago

0.1.1

3 years ago

1.0.0

3 years ago