pinojs / pino-http

🌲 high-speed HTTP logger for Node.js
MIT License
535 stars 117 forks source link

Add support for request-received middleware #66

Open niftylettuce opened 5 years ago

niftylettuce commented 5 years ago

The request-received middleware at https://github.com/cabinjs/request-received exposes a Symbol.for property, which this package could conditionally consume if interested (as opposed to just generating a new Date().

e.g. https://github.com/pinojs/pino-http/blob/master/logger.js#L63 would change as follows:

-    res[startTime] = res[startTime] || Date.now()
+    res[startTime] = res[startTime] || req[Symbol.for('request-received.startTime')] ? req[Symbol.for('request-received.startTime')].getTime() : Date.now()

Ref: #65

niftylettuce commented 5 years ago

PR #67 opened