Features:
- mimic a subset of the Console API
- support log level configuration
- support having multiple logger implementation running in parallel
- support multiple configurations
- support multiple logging backend
- provide an extensible API
- leverage rxjs whenever possible
- is lightweight
Using the global context, without customization.
const logger = getLogger('db');
logger.log('Hello World');
Configure a logger using its name.
import { configure, getLogger, Level } from 'logrx';
configure({
name: 'api-call',
appenders: ['console'],
level: Level.ERROR
});
const logger = getLogger('api-call');
logger.error('Hello Error', new Error('some issue'));
Using a separate context:
import { configure, getLogger, Level, ROOT_LOGGER_NAME } from 'logrx';
export const context = new LoggerContext();
context.configure({
name: ROOT_LOGGER_NAME,
appenders: [],
level: Level.OFF
}, {
name: 'api-call',
appenders: ['console'],
level: Level.INFO
});
// ---- //
const logger = getLogger('db');
logger.log('SELECT', 'ID=', 5);
This project is at a very early stage and will be open to contributions as soon as it proved to be an interesting library.