export function createRequestLoggingMiddleware(options) {
    const defaultLogger = isRequestLoggingOptions(options) ? options.logger : options;
    const resolveLogger = isRequestLoggingOptions(options) ? options.resolveLogger : undefined;
    return (request, response, next) => {
        const startedAt = Date.now();
        const requestLogger = resolveLogger?.(request) ?? defaultLogger;
        response.once('finish', () => {
            requestLogger.info({
                method: request.method,
                path: request.originalUrl,
                statusCode: response.statusCode,
                durationMs: Date.now() - startedAt,
            }, 'HTTP request');
        });
        next();
    };
}
function isRequestLoggingOptions(options) {
    return 'logger' in options;
}
//# sourceMappingURL=request-logging.js.map