# AddLogging


**API Documentation:**


**Installation:**

Globally:

`$ npm i -g @alu0101140469/addlogging`

Locally:

`$ npm i -D @alu0101140469/addlogging`


**Import to use:**

`const { addLogging } = require('@alu0101140469/addlogging');`

**Method:**

This method add new line of log before your code in functions and return a new string. It receives two parameters, code and pattern.

Code {string} code to read and find functions to write the new line

Pattern {string} word you want to choose, and find only functions match with that word.

`const output = addLogging(input, 'foo')`

**Tests:**

You can test the program using this command:

`$ npm test`

**Usage: Commands**

Execuatble add-logging:

`$ add-logging`
```
Usage: ejecutable [options]

Options:
  -V, --version                                           output the version number
  -o, --output <output_filename> <input_file>             introducir el fichero de salida del resultado del programa
  -p, --pattern <pattern> <output_filename> <input_file>  introducir patrón, el fichero de salida del resultado del programa
  -h, --help                                              output usage information
```
Help:

`$ add-logging -h`
```
Usage: ejecutable [options]

Options:
  -V, --version                                           output the version number
  -o, --output <output_filename> <input_file>             introducir el fichero de salida del resultado del programa
  -p, --pattern <pattern> <output_filename> <input_file>  introducir patrón, el fichero de salida del resultado del programa
  -h, --help                                              output usage information
```

Version:

`$ add-logging -V`

`  1.1.0`

`$ add-logging --version`

 ` 1.1.0 `

Output:

`$ add-logging -o output1.js input1.js`

```
function foo(a, b) {
    var x = 'blah';
    var y = (function (z) {
      return z+3;
    })(2);
  }
  foo(1, 'wut', 3);

  Salida en fichero output1.js
```

Pattern:

`$ add-logging --pattern foo output3.js input1.js`

```
function foo(a, b) {
    var x = 'blah';
    var y = (function (z) {
      return z+3;
    })(2);
  }
  foo(1, 'wut', 3);

  Salida en fichero output3.js
```

**License MIT: https://github.com/ULL-ESIT-PL-2021/espree-logging-module-Daniel-palenzuela-alvarez-alu0101140469-DanielPA57/blob/master/LICENSE**
