-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I enable logging with CustomPrismaModule? #102
Comments
Hi @cjmyles, you have full control over your PrismaClient instance with the extension. You should be able to add export const extendedPrismaClient = new PrismaClient<
Prisma.PrismaClientOptions,
'query' | 'info' | 'warn' | 'error'
>({
log: [
{ level: 'query', emit: 'event' },
{ level: 'info', emit: 'event' },
{ level: 'warn', emit: 'event' },
{ level: 'error', emit: 'event' },
],
})
.$on(...) // should go in here
.$extends({
model: {
...
},
});
export type ExtendedPrismaClient = typeof extendedPrismaClient; |
I might have to update the docs to explain a bit more the differences between Because you use The async function bootstrap() {
const app = await NestFactory.create(AppModule);
// log query events
const prismaService: PrismaService = app.get(PrismaService); // ❌ this won't work because PrismaSerivce is not provided, only CustomPrismaService. But `$on` is not a function for `CustomPrismaService` because you have full control of your PrismaClient instance
prismaService.$on('query', (event) => {
console.log(event);
}); If you have any questions, please let me know. |
@marcjulian Thanks for the responses. I'm with you now. Until the bug is fixed regarding |
@cjmyles yes would be good to create a Issue for |
@marcjulian Done. See prisma/prisma#25153 |
I am utilising the
CustomPrismaModule
in order to make use of client extensions. I have a fileprisma.extension.ts
that has the following code:This is then instantiated in my
app.module.ts
file:According to the docs I need to add the following to my
main.ts
file:However, this results in the following error:
The text was updated successfully, but these errors were encountered: