-
- Notifications
You must be signed in to change notification settings - Fork 602
Description
Is your feature request related to a problem? Please describe.
I'm using Mikro with Express with Winston as a logger (but this doesn't really matter) - when a request is received, we add context to the logger so that all subsequent logs have metadata added to it to easier tracing/filtering in Datadog. We'd like to be able to add this same context to all Mikro logs, but since the logger config property is global, there's no way of adding that per request context to the logs with accuracy.
Describe the solution you'd like
As part of calling RequestContext.create(orm.em, next, { ... });, you could add logger as part of the CreateContextOptions, which would then be passed to the forked EntityManager. There are some things that need to be global no matter what, but I was hoping that anything that could be request context specific be logged as such.
Describe alternatives you've considered
I've tried working with the global logger, logger factory, etc, but because we have many requests per seconds, they keep "competing" with each other over who gets to set the context and most of the data coming out of it is not related to the correct request. Only way to do this would be to initialize Mikro for every request, which seems ridiculous as it would add the overhead of connecting to the DB for every request and make our API slower.
Thanks for all the work that's been done on this library, it's been very useful for us. Cheers.