Skip to content

Documentation / @agentick/gateway / loggingMiddleware

Function: loggingMiddleware() ​

loggingMiddleware(config?): (req, res, next) => void

Defined in: gateway/src/plugins/logging.ts:124

Creates a logging middleware that wraps request handling. Logs method, path, status code, and response time in morgan 'dev' format.

Uses the kernel Logger for structured output. Configure via logger or loggerConfig on the config object.

Parameters ​

config? ​

Pick<LoggingPluginConfig, "logger" | "exclude" | "loggerConfig">

Returns ​

(req, res, next): void

Parameters ​

req ​

IncomingMessage

res ​

ServerResponse

next ​

() => void | Promise<void>

Returns ​

void

Example ​

typescript
// Default — uses Logger.for("HTTP")
const mw = loggingMiddleware();

// Custom logger with debug level
const mw = loggingMiddleware({
  logger: Logger.create({ level: 'debug' }),
  exclude: ["/health"],
});

// In your Express/Fastify/Node handler:
mw(req, res, () => gateway.handleRequest(req, res));

Released under the ISC License.