On a server let’s say each request has an id, pris...
# orm-help
i
On a server let’s say each request has an id, prisma is set up so that it’s logging everthing, and you want to do so that associate prisma log messages with the request id. I.e. if 2 user sends request at the same time id 1 and 2 and it each request executes 5 prisma queries, logs I want to see
Copy code
Request#1 prisma query ...  
Request#2 prisma query ...  
Request#1 prisma query ...  
Request#2 prisma query ...  
...
Is there something that one can do to active this? of course naive approach would be to create multiple prisma clients per request. but if you have 100 requsts and each client creates multiple db connection it’s not good. basically some “soft clone” like function is needed on prisma client
const softClone = (c: PrismaClient, context: unknown): PrismaClient
and then in when listening to events on prisma:
Copy code
prisma.$on("query", (e) => {
  console.log(e.context, "query", e.query);
});
and this softClone should not result in new connections (should use previous prisma client. Any suggestions? is there issue for it? (I’ve created an issue here: https://github.com/prisma/prisma/issues/10425)
👍 1
r
@Irakli Safareli 👋 Thanks for creating a feature request. Currently there’s no way of passing the app context to Prisma’s logger.