MugetsuM
tRPC3y ago
2 replies
Mugetsu

LoggerLink logging only via server logger in prod

I have a logger link setup as declared in https://trpc.io/docs/client/links/loggerLink#usage

loggerLink({
      enabled: (op) =>
        process.env.NODE_ENV === 'development' ||
        (op.direction === 'down' && op.result instanceof Error),
    }),

This is logging to console.log by default as I understand correctly. I have a specific logger instance using pino which can be used only on the server side. How do I acommodate this loggerlink to log errors via my logger instance only if it ERRORS in PRODUCTION?
loggerLink is a link that lets you implement a logger for your tRPC client. It allows you to see more clearly what operations are queries, mutations, or subscriptions, their requests, and responses. The link, by default, prints a prettified log to the browser's console. However, you can customize the logging behavior and the way it prints to the...
Logger Link | tRPC
Was this page helpful?