import type { Context, Next } from "hono";
import { logger } from "./logger";

export async function requestLogger(c: Context, next: Next) {
  const start = performance.now();
  const method = c.req.method;
  const path = c.req.path;

  logger.info(`→ ${method} ${path}`);

  await next();

  const duration = (performance.now() - start).toFixed(2);
  logger.info(`← ${method} ${path} ${duration}ms`);
}
