@aftonbladet/logger

1.1.1 • Public • Published

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.

Package Sidebar

Install

npm i @aftonbladet/logger

Weekly Downloads

8

Version

1.1.1

License

UNLICENSED

Unpacked Size

23.6 kB

Total Files

20

Last publish

Collaborators

  • aftonbladet