The package is inspired by ASP.NET tracing API. The main ideas are:
- Each component/module acquires a
tracing tag
to trace messages with - Tracing is configured in a single place - config file
- Tracing configuration specifies transports to be used by a
tracing tag
for a given log level
I found it's a little clumsy to do with winston
, so I created a wrapper that helps me to archive what I need.
Installation:
npm install winston-tracer --save
Resolving:
const tracer = ;
tracer
object has the following API:
winston
- property that referenceswinston
moduleget(tag)
- returnswinston
logger for a giventracing tag
(i.e., label)configure(config)
- configureswinston
loggers
config
is an array of the following objects structure:
pattern
- regex to match tracing tagsgetOptions(tag)
- function that accepttracing tag
as the parameter and returnswinston
configuration object
Below is example of how to use that.
Tracing is configured on an app start up:
// get tracerconst tracer = ; // tracer configuration that enables verbose logging for all tracing tagstracer;
Loggers are used in the following way, for example, in server.js
:
const logger = ; logger;