2

I am developing a RESTful service using node,express and bunyan middleware. Bunyan middleware is generating a UUID and the same is available at req.reqId. So, when the logging is happening via req.log.info("log message") then the reqId is being printed in logs. But the problem i am facing is that there are many internal helpers written that does not have context of req. One solution is to pass req object to every function but this looks like a overhead to me.

Appreciate for any solution.

  • I'd like to know this, too. Agreed, I'd like to log the request ID even if I'm logging something from a utility function that doesn't have the req object. – lagouyn Sep 14 '17 at 15:21

1 Answers1

0

This blog post is explaining the solution.

continuation-local-storage', library helps us to store information associated with each execution thread. The library will help us to share the namespaces among the different modules of our project and to share the information we need.