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.