@aftonbladet/logger

A wrapper around creating bunyan loggers and streams based on hierarchical log names

Stats

stars šŸŒŸissues āš ļøupdated šŸ› created šŸ£size šŸ‹ļøā€ā™€ļø
@aftonbladet/logger
Minified + gzip package size for @aftonbladet/logger in KB

Readme

Logger

Build Status

A wrapper around creating bunyan loggers and streams based on hierarchical log names.

Usage

Minimal example that logs on stdout on level error:

import Logger from '@aftonbladet/logger';

const log = new Logger().getLogger('default');
log.error('Hello world');

Example with configuration:

import { Logger } from '@aftonbladet/logger';
import { defaultLogLevel, logLevels, streams, serializers } from './config';

const logger = new Logger({
    defaultLogLevel,
    logLevels,
    streams,
    serializers,
});

const log = logger.getLogger('myapp.server');

ā€¦

log.debug('Initializing %s', thing);

ā€¦

log.error(err, 'Failed to do that thing');

Configuration

Example config.js:

export const defaultLogLevel = 'error';
export const logLevels = {
    myapp: 'error',
    'myapp.shared': 'info',
    'myapp.shared.specific': 'fatal',
    'myapp.server': 'warn',
};

export const streams = [
    {
        type: 'rotating-file',
        path: `${logDir}/hyperion.log`,
        period: '1d',
        count: 7,
        level: 'trace',
    },
];

Developing

  1. Optional step (if not logged in already): ./npm login --registry=https://registry.npmjs.org/ --scope=@aftonbladet
  2. npm install

Release and Publish

Every push to master will result in a new patch release being tagged and published on npmjs.org.

If you want to bump the minor or major version, just use the npm version command as you please. The version will be tagged and pushed automatically and Travis will publish it on npmjs.org.

E.g if you are on version 1.0.4 and run:

npm version minor

Travis will publish 1.1.0 on npmjs.org for you.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.