import { Transport } from '@aomex/logger'; import { WebContext, WebMiddleware } from '@aomex/web'; interface HttpLoggerOptions { /** * 是否禁用请求日志。默认:`false` */ disable?: boolean; /** * 响应输出格式,建议使用 **HttpLoggerToken** 拼接。默认值:`[ip] [method] [url] [statusCode] [duration] [contentLength]` */ format?: string; /** * 日志输出端口。默认使用 `Logger.transport.Console`。 */ transports?: Transport[]; /** * 自定义关键词 * ``` * requestLogger({ * format: ' [request] [time] [href]' * customTokens: { * href: (ctx) => ctx.request.href, * } * }) * ``` */ customTokens?: { [key: string]: (ctx: WebContext) => string | Promise; }; } declare const httpLogger: (options?: HttpLoggerOptions) => WebMiddleware; declare enum HttpLoggerToken { method = "[method]", url = "[url]", statusCode = "[statusCode]", contentLength = "[contentLength]", contentType = "[contentType]", duration = "[duration]", ip = "[ip]" } export { type HttpLoggerOptions, HttpLoggerToken, httpLogger };