I have an Express application. I would like to track all the records that were made in one query.
Apache has a module called mod_unique_id , which introduces a special one containing a unique hash into the request headers. I would like to use such a hash when registering (anything).
For example, if the user is assigned apache a unique value "abcdefg" and somewhere in my code (controller, model, or something else), I create a debug log that I would like to have "abcdefg" attached to each log entry.
The only idea that appears in my head is to create a journal instance using app.use() and pass this journal instance to ALL the functions that are needed (models, libraries, etc.) to generate the correct answer.
Unfortunately, this will force me to rewrite a lot of code so that old functions can accept this new instance of the log.
Does anyone know a better way to have one instance of "logger" per "request" that is in some way accessible without passing this "request handler" to anything?
PS: I am currently using winston to register
source share