logging
Installation
SKILL.md
Logging
We use a centralized, request-scoped logging pattern where loggers are created by middleware and passed through the request/function chain.
API Route Logging (Primary Pattern)
Use middleware wrappers that automatically create loggers with request context:
import { withError, withAuth, withEmailAccount, withEmailProvider } from "@/utils/middleware";
// Basic route with error handling and logging
export const POST = withError("my-route", async (request) => {
const logger = request.logger;
logger.info("Processing request");
// ...
});