fg-devs / logging.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@NewCircuit/logging.js

A standard logging package for NewCircuit projects.

Install

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

Configuration

See log4js configuration

Class Example

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!

Function Example

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!

About

License:GNU General Public License v3.0


Languages

Language:TypeScript 100.0%