probot
Version:
A framework for building GitHub Apps to automate and improve your workflow
17 lines (16 loc) • 687 B
JavaScript
export function probotRequestLogging(octokit) {
const log = octokit.log;
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}`;
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}`;
log.debug(params.body || {}, msg);
});
}