tagged-logger

A logger frontend for Winston that attaches tags to the messages

TaggedLogger

A logger frontend for Winston that attaches tags to the messages.

This module is designed to work together with TaggedConsoleTarget.

npm install tagged-logger

For this example you need to npm install winston tagged-console-target tagged-logger.

var winston = require('winston');
var TaggedConsoleTarget = require('tagged-console-target');
var TaggedLogger = require('tagged-logger');

var winstonLogger = new (winston.Logger)({
    transports: [
        new TaggedConsoleTarget()
    ]
});

function subModule(log) {
    log.info("Log message 2");
}

var log = new TaggedLogger(winstonLogger, ['example']);

log.info("Log message 1");
subModule(log.createSublogger("submodule"));

Example output:

05:33:13.222 2013-04-17 Wednesday
05:33:13.224 [example] Log message 1
05:33:13.224 [example, submodule] Log message 2

It works fine without TaggedConsoleTarget, but the default console target does not know how to format the tags helpfully.

Please refer to the source.