Plugins
Debug
Development logging
The debug plugin logs detailed request lifecycle information during development.
Installation
npm install @spoosh/plugin-debugUsage
import { debugPlugin } from "@spoosh/plugin-debug";
const plugins = [debugPlugin()];Disable in Production
const plugins = [
debugPlugin({ enabled: process.env.NODE_ENV === "development" }),
];Log Cache State
const plugins = [debugPlugin({ logCache: true })];Custom Logger
const plugins = [
debugPlugin({
logger: (entry) => {
console.log(entry.phase, entry.path, entry.state.data);
},
}),
];Options
Plugin Config
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Enable/disable logging |
logCache | boolean | false | Include cache entries in log output |
logger | (entry: DebugLogEntry) => void | - | Custom logger function |
DebugLogEntry
| Property | Type | Description |
|---|---|---|
phase | string | Current phase (onMount, beforeFetch, etc.) |
operationType | string | "read", "write", or "infiniteRead" |
method | string | HTTP method |
path | string | Request path |
queryKey | string | Unique query key |
requestTimestamp | number | Request timestamp |
tags | string[] | Cache tags |
requestOptions | unknown | Request options |
state | object | Current state (loading, data, error, etc.) |
response | object | Response data (if available) |
cacheEntries | array | Cache entries (if logCache enabled) |