mirror of
https://github.com/zhigang1992/probot.git
synced 2026-06-15 10:27:43 +08:00
20 lines
569 B
JavaScript
20 lines
569 B
JavaScript
module.exports = addLogging
|
|
|
|
function addLogging (octokit, logger) {
|
|
if (!logger) {
|
|
return
|
|
}
|
|
|
|
octokit.hook.error('request', (error, options) => {
|
|
const {method, url, headers, ...params} = options
|
|
const msg = `GitHub request: ${method} ${url} - ${error.code} ${error.status}`
|
|
logger.debug({params}, msg)
|
|
throw error
|
|
})
|
|
octokit.hook.after('request', (result, options) => {
|
|
const {method, url, headers, ...params} = options
|
|
const msg = `GitHub request: ${method} ${url} - ${result.meta.status}`
|
|
logger.debug({params}, msg)
|
|
})
|
|
}
|