@alu0101017396/addlogging

0.4.18 • Public • Published

addLogging

A small library providing a method that put a console.log after each function with a description of it.

Installation

npm install @alu0101017396/addlogging --save

or

npm install --global @alu0101017396/addlogging 

Usage

How to use the package as a library

Add the followin lines to the head of your program:
let logging_espree = require('@alu0101017396/addlogging');
let addlogging = logging_espree.addLogging; The function addLogging can receive one or two parameters, the first one is a string with the code that will be transform; and the second one is an optional pattern that will filter the function names that are parsed.
An example of use would be:

  let logging_espree = require('@alu0101017396/addlogging');  
  let addlogging = logging_espree.addLogging;  
  let declared = addlogging(`function foo(a, b) {  
    var x = 'blah';  
    var y = function () {  
        return 3;  
    }();  
  }    
  foo(1, 'wut', 3);`);  
  console.log("\n\nNormal Function: ")  
  console.log(declared); 

With the following output:

  Normal Function:
  function foo(a, b) {
    console.log(`Entering foo(${ a }},${ b }}) at line 1`);
    var x = 'blah';
    var y = function () {
        console.log(`Entering <anonymous function>() at line 3`);
        return 3;
  }();
  }
  foo(1, 'wut', 3);

How to execute

This program contains four options:
-V, --version output the version number
-o, --output file where is the output
-p, --pattern <function_name> name of the functions that are parsed
-h, --help output usage information
to use it put in bash:
$ addlogging <filename> [options]

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Tests

If you change any functionality of the package you can add tests to the tests directory and run them with:
npm test

Documentation

https://ull-esit-pl-2021.github.io/espree-logging-module-alu0101017396/

Release History

  • 0.2.4 Initial release
  • 0.3.9 Patten addition
  • 0.4.14 Executable addition

Readme

Keywords

none

Package Sidebar

Install

npm i @alu0101017396/addlogging

Weekly Downloads

0

Version

0.4.18

License

none

Unpacked Size

7.85 MB

Total Files

78

Last publish

Collaborators

  • alu0101017396