tagged-console-target
v1.1.2
Published
A log target for Winston that expects tagged log messages
Downloads
132
Keywords
Readme
TaggedConsoleTarget
A log target for Winston that expects tagged log messages and writes them with lots of colors to the console or a given output stream.
This module is designed to work together with TaggedLogger
.
Install
npm install tagged-console-target
Example
For this example you need to npm install winston tagged-console-target
.
var winston = require('winston');
var TaggedConsoleTarget = require('tagged-console-target');
var logger = new (winston.Logger)({
transports: [
new TaggedConsoleTarget()
]
});
logger.info("Log message 1", {tags: ['module a']});
logger.info("Log message 2", {tags: ['module a', 'submodule a1']});
logger.info("Log message 3", {tags: ['module b']});
Example output:
16:46:06.004 2013-04-17 Wednesday
16:46:06.007 [module a] Log message 1
16:46:06.008 [module a, submodule a1] Log message 2
16:46:06.008 [module b] Log message 3
Except the output is in glorious color!
Options
TaggedConsoleTarget
accepts an object with options for the constructor. The accepted options are:
target
: The target output stream. Defaults toprocess.stdout
level
: The minimum level of log messages to output to this logger, for example"info"
. Keep this unset to allow all messages that are accepted by the logger objecthandleExceptions
: Set totrue
to intercept unhandled exceptions and output them to this log targetexceptionsLevel
: The log level at which to log exceptions. Defaults toerror
humanReadableUnhandledException
: Format exception log output in a more readable fashion