Skip to content

NOALVO/unlogger

 
 

Repository files navigation

unlogger

lerna

Unopinionated & provider-oriented logger, with conditional logging, custom formatting and targeted levels control.

The main purpose of unlogger is the ability to create providers that behave as different logging targets. That means you can build your logger to log into a file, or to console, or a database, etc.

Features

  • Provider-oriented logger, with official, community and your own custom providers
  • Conditional logging
  • Custom log formatting
  • Configurable levels to target per log provider

Usage

1: Install the core package using npm in your project:

$ npm i -s @unlogger/core

2: Install and require the desired providers, choosing one of the following options:

$ npm i -s @unlogger/theprovidernameyouwanthere
const { logger } = require('@unlogger/core');
const provider = require('@unlogger/theprovidernameyouwanthere');
logger.addProvider(provider);

3: Use the logger normally as any other logger:

logger.log('A message');
logger.warn({ an: 'object' });
logger.error({ an: 'object' }, { a: 'context required by your provider' });

Default levels

Unlogger defaults to three logging levels (log, warn and error), but it depends on the providers you are using. Some providers can extend the logging levels, like the @unlogger/env-console provider.

If you want to customize these levels, see Customizing levels.

Async providers

Some providers will require setup functions and need to be added in an async way. To use them you will need to call the method addProviderAsync instead addProvider and pass the required data to setup as the second argument.

await logger.addProviderAsync(asyncProvider, { required: 'options here' });

Avaiable providers

Officially distributed providers

We built some providers ourselves but you can find other community providers at the @unlogger scope in npm.

Community-built providers

We need contributors! Make a provider, fork this repo and make a pull request to include your provider in this section.

Custom providers

Create your own customized provider by following the Custom provider docs

Spread the word!

Donate a post in Facebook, Twitter or your favourite social network.

License

MIT

Curiosity

unlogger name comes from the acronym of the words "unopinionated" and "logger" 😀

Where are the old providers' repos?

We recently converted Unlogger to a monorepo with Lerna. You can find the original providers' repos under /packages folder. The packages are still published with their original names under the @unlogger scope.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%