@alu0101051420/addlogging
v1.5.7
Published
Addlogging ==============
Downloads
49
Readme
Addlogging
A small library providing a method to add logging messages in existing functions (js).
Installation
npm install addlogging --save
Usage
You can import the main function and use it like this:
const { addLogging } = require('@alu0101051420/addlogging');
let code = `function foo() { var x = 'blah'; } foo();`,
commented = addLogging(code);
console.log('Original Code: \n', code);
console.log('Code with logs: \n', commented);
Output:
Original Code:
function foo() { var x = 'blah'; } foo();
Code with logs:
function foo() {
console.log(`Entering foo() at line 1`);
var x = 'blah';
}
foo();
An executable is also imported. You must specify an input file, and may or may not specify an output file and/or a name pattern. This pattern will be used to comment only functions whose name match it. (You can specify "anonymous" in order to comment anonymous functions.)
npx addlogging myfile.js
npx addlogging myfile.js --output output.js
npx addlogging myfile.js --output output.js --pattern foo
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
npm test
Release History
- 1.0.0 Initial release
- 1.4.0 Big changes. Added executable, and --pattern function.
- 1.5.3 Latest version. Minor bug fixes.