README
Logger
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
- Optional step (if not logged in already):
./npm login --registry=https://registry.npmjs.org/ --scope=@aftonbladet
- username is
aftonbladet
- password can be found in https://password.int.aftonbladet.se:1583/PassTrixMain.cc (search for
npm
) - email is
tobias.jarlund@aftonbladet.se
- username is
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.