setLogger

setLogger

setLogger is an optional function that allows you to replace the default logger used by Svelte 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:

import { setLogger } from '@sveltestack/svelte-query'
import { printLog, printWarn, printError } from 'custom-logger'
// Custom logger
setLogger({
log: printLog,
warn: printWarn,
error: printError,
})
// Sentry logger
setLogger({
log: message => {
Sentry.captureMessage(message)
},
warn: message => {
Sentry.captureMessage(message)
},
error: error => {
Sentry.captureException(error)
},
})
// Winston logger
setLogger(winston.createLogger())

Options

  • logger: Logger
    • Must implement the log, warn, and error methods.
Was this page helpful?

Subscribe to our newsletter

The latest TanStack news, articles, and resources, sent to your inbox.

    I won't send you spam.

    Unsubscribe at any time.

    © 2020 Tanner Linsley. All rights reserved.