I’m trying to figure out how to use prismaClient to write logs to a db using sinks/interceptors. I’m running into problems no being able to use PrismaClient in either. I feel like I’m missing a step. I first thought it should be placed in the context, but not sure how that would go. Kinda new to the logging from Temporal, so sorry if this is a simple matter.
For logging from a workflow, you’ll need a sink, for activities, you can log directly from your activity.
If you want to add context to the activity logger, I suggest using an interceptor to attach a logger to the activity context or in your logger getting the activity info from the current context.
To access your logger from your activity or sink, pass it in during worker initialization.
If all you want is to customize the built-in SDK logger, which logs activity and workflow invocations, take a look at this sample: samples-typescript/worker.ts at main · temporalio/samples-typescript · GitHub
To inject a client into your activities, see this sample: samples-typescript/worker.ts at main · temporalio/samples-typescript · GitHub
1 Like