Spaces:
Paused
Paused
File size: 518 Bytes
5d0a52f b1107bc 5d0a52f 347f81b 5d0a52f b1107bc 5d0a52f b1107bc 5d0a52f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import type { Context, Next } from "hono";
import { log } from "../utils/logger.js";
export async function logger(c: Context, next: Next): Promise<void> {
const start = Date.now();
const method = c.req.method;
const path = c.req.path;
const rid = c.get("requestId") ?? "-";
log.info(`→ ${method} ${path}`, { rid, method, path });
await next();
const ms = Date.now() - start;
const status = c.res.status;
log.info(`← ${method} ${path} ${status} ${ms}ms`, { rid, method, path, status, ms });
}
|