domain module is deprecated since node 10 (https://nodejs.org/docs/latest-v10.x/api/domain.html). It is used to improve logging, by storing information related to the request in a per-request domain. The callback provided to function getContext of logops package queries that domain to retrieve request information.
This PR replaces the global logger with a per-request instance, stored in req.logger. This instance is created by a middleware that runs early in the chain, and populates the per-request logger instance with the same information that used to be in the context.
All the middleware and handlers are also refactored to use the per-request logger instead of the global one, so this PR can dispose of the logger.getContext callback and the domain dependency.
Fixes issue https://github.com/telefonicaid/fiware-pep-steelskin/issues/498
domain
module is deprecated since node 10 (https://nodejs.org/docs/latest-v10.x/api/domain.html). It is used to improve logging, by storing information related to the request in a per-request domain. The callback provided to functiongetContext
of logops package queries that domain to retrieve request information.This PR replaces the global logger with a per-request instance, stored in
req.logger
. This instance is created by a middleware that runs early in the chain, and populates the per-request logger instance with the same information that used to be in the context.All the middleware and handlers are also refactored to use the per-request logger instead of the global one, so this PR can dispose of the
logger.getContext
callback and thedomain
dependency.