Search code examples
node.jswinston

Winston logger profiler time unit


I'm using winston logger profiling.

my question is how can I change the time unit of the profiler.

My code:

this.logger.profile(`some ${jobId}`);
// do the job ....
this.logger.profile(`some ${jobId}`);

In the result I see:

{ ...,"message": "some 1", "durationMs":2500 ... }

My question is how (is) it possible to configure the time unit from ms to seconds/minuets etc...

So that I'll see

{ ...,"message": "some 1", "durationSeconds: 2.5" ... }

Solution

  • The answer is unfortunately no: winston doesn't provide an option of providing the duration in a unit other than ms, see:

    https://github.com/winstonjs/winston/blob/master/lib/winston/profiler.js#L47