Logger
Structured, redacted logging for the whole application.
The middleware ships with a structured logger (GCP-compatible JSON output) that automatically attaches request context - integration name, method name - to every entry and redacts secrets before anything is written.
Configure it
Logging is configured once, in
MiddlewareConfig; individual
integrations can override the application-wide settings.
export const config = {
logger: {
verbosity: "info",
redactKeys: ["session-id", /^x-internal-/i],
},
integrations: {
// per-integration override:
commerce: { logger: { verbosity: "debug" }, /* ... */ },
},
};Prop
Type
Use it
Inside API methods, extensions, hooks, and error handlers, getLogger hands
you the request-scoped logger - never construct your own:
import { getLogger } from "@alokai/connect/middleware";
async function getProduct(context, params) {
const logger = getLogger(context);
logger.info("Fetching product", { productId: params.id });
// ...
}Every method maps to one of the RFC 5424 severities - debug, info,
notice, warning, error, critical, alert, emergency - and takes an
optional metadata object that is merged (and redacted) into the structured
entry.