A standard logging package for NewCircuit projects.
Make sure you have an .npmrc in your project that adds the GitHub package registry.
# .npmrc
@newcircuit:registry=https://npm.pkg.github.com
Then install.
npm i @newcircuit/logging.js
const LogFactory = require('@newcircuit/logging.js');
// Put this instance where it's globally accessible.
const log = new LogFactory('info');
class Test {
methodA() {
// The last parameter is optional.
const logger = log.getLogger('main', this, 'methodA');
logger.info('This is a test!');
}
}
const test = new Test();
test.methodA();
Output:
[2021-03-07T14:57:27.258] [INFO] [main] [Test.methodA()]: This is a test!
const LogFactory = require('@newcircuit/logging.js');
// Put this instance where it's globally accessible.
const log = new LogFactory('info');
function test() {
// The last parameter is optional.
const logger = log.getLogger('main', test);
logger.info('This is a test!');
}
test();
Output:
[2021-03-07T14:58:22.631] [INFO] [main] [test()]: This is a test!