logrx
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

logrx, a javascript logger built with rxjs

build status

Features:

  • [x] mimic a subset of the Console API
  • [x] support log level configuration
  • [x] support having multiple logger implementation running in parallel
  • [x] support multiple configurations
  • [x] support multiple logging backend
  • [x] provide an extensible API
  • [ ] leverage rxjs whenever possible
  • [ ] is lightweight

Getting Started

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);

Contributing

This project is at a very early stage and will be open to contributions as soon as it proved to be an interesting library.

Readme

Keywords

none

Package Sidebar

Install

npm i logrx

Weekly Downloads

0

Version

1.1.3

License

MIT

Unpacked Size

333 kB

Total Files

76

Last publish

Collaborators

  • oliamb