-
-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure the Verbosity of Blitz RPC Logging (#4162)
* improve blitz rpc logging * implement improved setup with jsdoc comments * make it verbose by default * change routePath to resolverName for easier use * Update packages/blitz-rpc/src/index-server.ts * rename to make language more inclusive * set output as debug * Create sixty-rockets-count.md * Update sixty-rockets-count.md * Update sixty-rockets-count.md * fix verbose bug * Apply suggestions from code review Co-authored-by: Brandon Bayer <[email protected]> --------- Co-authored-by: Brandon Bayer <[email protected]>
- Loading branch information
1 parent
831a493
commit 7277349
Showing
3 changed files
with
152 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
"@blitzjs/rpc": patch | ||
"blitz": patch | ||
--- | ||
|
||
### Now we can configure Blitz RPC in the following way, | ||
|
||
In your `[[...blitz]].ts` api file you can see the following settings | ||
```ts | ||
logging?: { | ||
/** | ||
* allowList Represents the list of routes for which logging should be enabled | ||
* If whiteList is defined then only those routes will be logged | ||
*/ | ||
allowList?: string[] | ||
/** | ||
* blockList Represents the list of routes for which logging should be disabled | ||
* If blockList is defined then all routes except those will be logged | ||
*/ | ||
blockList?: string[] | ||
/** | ||
* verbose Represents the flag to enable/disable logging | ||
* If verbose is true then Blitz RPC will log the input and output of each resolver | ||
*/ | ||
verbose?: boolean | ||
/** | ||
* disablelevel Represents the flag to enable/disable logging for a particular level | ||
*/ | ||
disablelevel?: "debug" | "info" | ||
} | ||
``` | ||
```ts | ||
import { rpcHandler } from "@blitzjs/rpc" | ||
import { api } from "src/blitz-server" | ||
|
||
export default api( | ||
rpcHandler({ | ||
onError: console.log, | ||
formatError: (error) => { | ||
error.message = `FormatError handler: ${error.message}` | ||
return error | ||
}, | ||
logging: { | ||
... | ||
} | ||
}) | ||
) | ||
``` | ||
|
||
Example: | ||
```ts | ||
export default api( | ||
rpcHandler({ | ||
onError: console.log, | ||
formatError: (error) => { | ||
error.message = `FormatError handler: ${error.message}` | ||
return error | ||
}, | ||
logging: { | ||
verbose: true, | ||
blockList: ["getCurrentUser", ...], //just write the resolver name [which is the resolver file name] | ||
}, | ||
}) | ||
) | ||
``` | ||
|
||
This is enable verbose blitz rpc logging for all resolvers except the resolvers `getCurrentUser` and others mentioned in the `blockList` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters