From eac2e4e53e3a0b3be4db1655ac51a99eb8f13490 Mon Sep 17 00:00:00 2001 From: Demian Caldelas Date: Wed, 23 Feb 2022 13:37:41 -0300 Subject: [PATCH] Silence trpc logging by default (#1949) Co-authored-by: Bailey Pumfleet Co-authored-by: Peer Richelsen --- README.md | 8 ++++++++ apps/web/pages/_app.tsx | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8cc9a77247..fb74e2bdd0 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,14 @@ Here is what you need to be able to run Cal. yarn dx ``` +#### Development tip + +> Add `NEXT_PUBLIC_DEBUG=1` anywhere in your `apps/web/.env` to get logging information for all the queries and mutations driven by **trpc**. + +```sh +echo 'NEXT_PUBLIC_DEBUG=1' >> apps/web/.env +``` + #### Manual setup 1. Configure environment variables in the .env file. Replace ``, ``, ``, `` with their applicable values diff --git a/apps/web/pages/_app.tsx b/apps/web/pages/_app.tsx index 7d67ff4085..1c7a4ad479 100644 --- a/apps/web/pages/_app.tsx +++ b/apps/web/pages/_app.tsx @@ -45,8 +45,7 @@ export default withTRPC({ // adds pretty logs to your console in development and logs errors in production loggerLink({ enabled: (opts) => - process.env.NODE_ENV === "development" || - (opts.direction === "down" && opts.result instanceof Error), + !!process.env.NEXT_PUBLIC_DEBUG || (opts.direction === "down" && opts.result instanceof Error), }), httpBatchLink({ url: `/api/trpc`,