setLogger
setLogger
setLogger is an optional function that allows you to replace the default logger used by React Query to log errors. By default, the window.console object is used. If no global console object is found in the environment, nothing will be logged.
Examples:
JavaScript
1import { setLogger } from 'react-query'2import { printLog, printWarn, printError } from 'custom-logger'3 4// Custom logger5setLogger({6 log: printLog,7 warn: printWarn,8 error: printError,9})10 11// Sentry logger12setLogger({13 log: message => {14 Sentry.captureMessage(message)15 },16 warn: message => {17 Sentry.captureMessage(message)18 },19 error: error => {20 Sentry.captureException(error)21 },22})23 24// Winston logger25setLogger(winston.createLogger())Options
logger: Logger- Must implement the
log,warn, anderrormethods.
- Must implement the