-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(*): add optional logger prop to QueryClient config (#3246)
- remove setLogger - add optional `logger` prop to QueryClientConfig - add getLogger public method to QueryClient - add optional `logger` prop to QueryConfig and MutationConfig - add getDefaultLogger function which returns a default logger based on environment, which is used by everything that takes an optional logger in their config - add createQueryClient test util function that uses a mock logger - replace all `new QueryClient` calls with createQueryClient calls - remove mockConsoleError and usages from tests, which are not necessary anymore BREAKING CHANGE: remove setLogger
- Loading branch information
Showing
49 changed files
with
318 additions
and
584 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
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,22 @@ | ||
--- | ||
id: custom-logger | ||
title: Custom Logger | ||
--- | ||
|
||
If you want to change how information is logged by React Query, you can set a custom logger when creating a `QueryClient`. | ||
|
||
```js | ||
const queryClient = new QueryClient({ | ||
logger: { | ||
log: (...args) => { | ||
// Log debugging information | ||
}, | ||
warn: (...args) => { | ||
// Log warning | ||
}, | ||
error: (...args) => { | ||
// Log error | ||
}, | ||
}, | ||
}) | ||
``` |
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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -7,4 +7,5 @@ module.exports = { | |
moduleNameMapper: { | ||
'react-query': '<rootDir>/src/index.ts', | ||
}, | ||
clearMocks: true, | ||
} |
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
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,11 @@ | ||
import type { Logger } from './logger' | ||
|
||
/** | ||
* See https://github.com/tannerlinsley/react-query/issues/795 | ||
* and https://github.com/tannerlinsley/react-query/pull/3246/#discussion_r795105707 | ||
*/ | ||
export const defaultLogger: Logger = { | ||
log: console.log, | ||
warn: console.warn, | ||
error: console.warn, | ||
} |
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
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
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
Oops, something went wrong.