Logger Hook
The logger hook logs requests with method, URL, status code, response time, and optional extras. Install it with:
burger-api add logger
Usage
Compose it in src/hooks.ts. The logger decorates the response, so it runs as a beforeRoute hook:
src/hooks.ts
import { logger } from "../ecosystem/hooks/logger/logger";
export const beforeRoute = [logger()];
Options
colors: colorized output. Defaulttrue.format:"text"or"json".logQuery,logHeaders,logBody: extra request details. Defaultfalse.logBodymay log sensitive data; use only in development.requestId: attach and log a request ID, read fromrequestIdHeaderwhen present. Defaulttrue. The ID is available asctx.requestId(typed by the hook's module augmentation).requestIdHeader: header an existing request ID is read from. Default"X-Request-ID".includeRequestIdInLog: include the ID in each log line. Defaulttrue.skip: a string, regex, or function to skip certain requests. Strings and regexes match the request pathname, not the full URL.formatter: custom log format.logFn: custom output function (file, external service).
src/hooks.ts
import { createLogger } from "../ecosystem/hooks/logger/logger";
export const beforeRoute = [
createLogger({ format: "json", skip: /^\/(health|metrics)/ }),
];
Check the package README in ecosystem/hooks/logger/ for the full option list.