Files
n8n-nodes-gwezz-changdunovel/node_modules/@octokit/plugin-request-log/dist-src/index.js
2025-10-26 23:10:15 +08:00

27 lines
959 B
JavaScript

import { VERSION } from "./version.js";
function requestLog(octokit) {
octokit.hook.wrap("request", (request, options) => {
octokit.log.debug("request", options);
const start = Date.now();
const requestOptions = octokit.request.endpoint.parse(options);
const path = requestOptions.url.replace(options.baseUrl, "");
return request(options).then((response) => {
const requestId = response.headers["x-github-request-id"];
octokit.log.info(
`${requestOptions.method} ${path} - ${response.status} with id ${requestId} in ${Date.now() - start}ms`
);
return response;
}).catch((error) => {
const requestId = error.response?.headers["x-github-request-id"] || "UNKNOWN";
octokit.log.error(
`${requestOptions.method} ${path} - ${error.status} with id ${requestId} in ${Date.now() - start}ms`
);
throw error;
});
});
}
requestLog.VERSION = VERSION;
export {
requestLog
};