expressjs / morgan

HTTP request logger middleware for node.js
MIT License
7.95k stars 536 forks source link

Expose `stream.write` as option #279

Closed agnjunio closed 1 year ago

agnjunio commented 1 year ago

I love what Morgan does, but I only have the need to customize this line:

stream.write(line + '\n')

I want to be able to pass custom req.properties as metadata to my logger, so in my use-case I would need morgan to call:

stream.write(line, ...customStuffThatDependsOnUpdatedRes)

Is there a way I can do that?

agnjunio commented 1 year ago

Noticed that this is addressed by https://github.com/expressjs/morgan/pull/272

dougwilson commented 1 year ago

Hi @agnjunio there isn't, but .write method cannot accept just random extra parameters, it seems. This is the method signature: https://nodejs.org/api/stream.html#writablewritechunk-encoding-callback

writable.write(chunk[, encoding][, callback])