probot
Version:
A framework for building GitHub Apps to automate and improve your workflow
18 lines • 917 B
JavaScript
export function probotRequestLogging(octokit) {
octokit.hook.error("request", (error, options) => {
if ("status" in error) {
const { method, url, ...params } = octokit.request.endpoint.parse(options);
const msg = `GitHub request: ${method} ${url} - ${error.status}`;
// @ts-expect-error log.debug is a pino log method and accepts a fields object
octokit.log.debug(params.body || {}, msg);
}
throw error;
});
octokit.hook.after("request", (result, options) => {
const { method, url, ...params } = octokit.request.endpoint.parse(options);
const msg = `GitHub request: ${method} ${url} - ${result.status}`;
// @ts-expect-error log.debug is a pino log method and accepts a fields object
octokit.log.debug(params.body || {}, msg);
});
}
//# sourceMappingURL=octokit-plugin-probot-request-logging.js.map