Debug System
Configurable debug support for development — logging and buffer for tracing resolution and middleware.
Debug is enabled via configuration and provides a log function and an optional buffer used during rendering:
What It Provides:
| Feature | Purpose |
|---|---|
| DebugConfig | Enable debug and optional flags for component resolution, middleware, and reactions logging |
| Debug context | A log(category, message, data?) function and a buffer (add, clear, getAll) passed through middleware and resolution |
| Activation | Set debug={{ enabled: true }} on ScheptaProvider or FormFactory |
Activation:
<ScheptaProvider debug={{ enabled: true }}>
<App />
</ScheptaProvider>
// Or per factory
<FormFactory schema={schema} debug={true} />Result: When enabled, the system can log component resolution, middleware execution, and reactions. Middleware and orchestrator receive a debug context and can log or buffer entries.
Debug Configuration
DebugConfig (from @schepta/core):
| Property | Type | Description |
|---|---|---|
enabled | boolean | Master switch for debug |
logComponentResolution | boolean (optional) | Log when components are resolved |
logMiddlewareExecution | boolean (optional) | Log when middleware runs |
logReactions | boolean (optional) | Log reaction execution |
DebugContextValue (passed when debug is enabled):
isEnabled— true when debug is onlog(category, message, data?)— log a message (e.g. to console)buffer—{ add(entry), clear(), getAll() }for storing debug entries (e.g. for later inspection)
Factories create a debug context when debug.enabled is true and pass it into the middleware context and resolution. Middleware can use context.debug?.log() to output information when debug is enabled.
How It Works
- Provider or FormFactory receives
debug(e.g.{ enabled: true }). - Merged config includes debug; when enabled, a debug context is created (e.g. with
logwriting to console and a buffer). - Middleware context includes
debug. Middleware can callcontext.debug?.log('middleware', 'message', data). - Resolution can use debug to warn when a component is not found or when
x-customis set but no custom component is registered.
This gives you visibility into resolution and middleware without requiring a separate UI; you can extend the buffer or log output as needed in your app.
Related Concepts
Debug is configured and used across concepts:
- 01. Factories: Factories pass debug into the pipeline
- 04. Schema Resolution: Resolution can log resolution steps when debug is enabled
- 05. Renderer: Renderers receive props after middleware (debug may have been used there)
- 06. Middleware: Middleware receives
context.debugand can log or buffer - 03. Provider: Debug configured via Provider
debugprop - 02. Schema Language: Schema is what resolution and middleware process; debug helps trace how it is interpreted