Spoosh
Plugins

Debug

Development logging

The debug plugin logs detailed request lifecycle information during development.

Installation

npm install @spoosh/plugin-debug

Usage

import { Spoosh } from "@spoosh/core";
import { debugPlugin } from "@spoosh/plugin-debug";

const client = new Spoosh<ApiSchema, Error>("/api").use([debugPlugin()]);

Disable in Production

import { Spoosh } from "@spoosh/core";
import { debugPlugin } from "@spoosh/plugin-debug";

const client = new Spoosh<ApiSchema, Error>("/api").use([
  debugPlugin({ enabled: process.env.NODE_ENV === "development" }),
]);

Log Cache State

import { Spoosh } from "@spoosh/core";
import { debugPlugin } from "@spoosh/plugin-debug";

const client = new Spoosh<ApiSchema, Error>("/api").use([
  debugPlugin({ logCache: true }),
]);

Custom Logger

import { Spoosh } from "@spoosh/core";
import { debugPlugin } from "@spoosh/plugin-debug";

const client = new Spoosh<ApiSchema, Error>("/api").use([
  debugPlugin({
    logger: (entry) => {
      console.log(entry.phase, entry.path, entry.state.data);
    },
  }),
]);

Options

Plugin Config

OptionTypeDefaultDescription
enabledbooleantrueEnable/disable logging
logCachebooleanfalseInclude cache entries in log output
logger(entry: DebugLogEntry) => void-Custom logger function

DebugLogEntry

PropertyTypeDescription
phasestringCurrent phase (onMount, beforeFetch, etc.)
operationTypestring"read", "write", or "infiniteRead"
methodstringHTTP method
pathstringRequest path
queryKeystringUnique query key
requestTimestampnumberRequest timestamp
tagsstring[]Cache tags
requestOptionsunknownRequest options
stateobjectCurrent state (loading, data, error, etc.)
responseobjectResponse data (if available)
cacheEntriesarrayCache entries (if logCache enabled)

On this page