Volt v0.1 · TypeScript APIs on Bun · Get started
Docs/Plugins Ecosystem/Structured Logging

Structured Logging

Register the logger plugin and read its shared logger service.

Complete logger example

index.ts
import { Volt, loggerPlugin } from 'voltts';

const app = new Volt();
app.plugin(loggerPlugin({ format: 'json' }));
app.get('/health', (c) => {
  c.store.logger.info('Health endpoint called');
  return c.json({ ok: true });
});
if (globalThis._importMeta_.main) app.listen(3000);
export default app;

Verify output

Run bun run index.ts and request /health. The plugin logs requests and exposes c.store.logger.info, warn, error, and debug. format: 'json' emits structured lines; format: 'dev' emits readable development messages. Use logger(options) instead when you only need request middleware.

Avoid sensitive log fields

Supply your own log function through the options if needed. Keep tokens, passwords, and private request bodies out of logs. Timing measures handler processing observed by the middleware, not client network latency.