2.0.4 • Published 8 years ago

log-ew v2.0.4

Weekly downloads
1
License
ISC
Repository
github
Last release
8 years ago

Winston logger wrapper with added inspection functions

Installation

$ npm install --save log-ew

Prerequisites

See winston README: https://github.com/winstonjs/winston

Usage

// require default logger (created with default options)
const log = require('log-ew');

// override default options
const log = require('log-ew')({ logger: console });

// making a logger available to other files
const log = require('log-ew');
log.consoleLogger = log({ logger: console });

Options

logger

Defaults to require('winston')

const log = require('log-ew');

// the log.loggers function comes from winston
log.loggers.add('logger1', {
    console: {
        colorize: true,
        label: 'logger 1',
    },
});
var logger1 = log({
    // logger.log must be a function(level, arguments…)
    logger: log.loggers.get('logger1'),
});

Logging

const log = require('log-ew');

// every property of winston is available by default
log.info('version', log.version);

// inspect arguments in more detail, this can be useful for errors
log.inspect.log(level, arguments…);
log.inspect.error(arguments…);
log.inspect.warn(arguments…);
log.inspect.info(arguments…);
log.inspect.verbose(arguments…);
log.inspect.debug(arguments…);
log.inspect.silly(arguments…);

// logging objects
log.inspect.fields({ firstName: 'John', lastName: 'Smith' }, ['firstName']); // info
log.inspect.fields({ firstName: 'John', lastName: 'Smith' }, ['firstName'], 'debug');
log.inspect.fields({ firstName: 'John', lastName: 'Smith' }, ['firstName'], { level: 'debug' });
log.inspect.hash('Hello', { firstName: 'John', lastName: 'Smith' }); // info
log.inspect.hash('Hello', { firstName: 'John', lastName: 'Smith' }, 'debug');

Running tests

$ npm install
$ npm test
2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago