mirror of
https://github.com/zhigang1992/probot.git
synced 2026-06-15 02:18:58 +08:00
* Extract github client extensions into module * Add logging to extended GitHub client * Update test to check output * Inline GitHub App methods * Update node-github links * Remove src, which does not show up with LOG_FORMAT=simple anyway * Fix lint errors
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
const bunyan = require('bunyan')
|
|
|
|
module.exports = {
|
|
repository: repository => repository.full_name,
|
|
event: event => {
|
|
if (typeof event !== 'object' || !event.payload) {
|
|
return event
|
|
} else {
|
|
let name = event.event
|
|
if (event.payload && event.payload.action) {
|
|
name = `${name}.${event.payload.action}`
|
|
}
|
|
|
|
return {
|
|
id: event.id,
|
|
event: name,
|
|
repository: event.payload.repository && event.payload.repository.full_name,
|
|
installation: event.payload.installation && event.payload.installation.id
|
|
}
|
|
}
|
|
},
|
|
installation: installation => {
|
|
if (installation.account) {
|
|
return installation.account.login
|
|
} else {
|
|
return installation
|
|
}
|
|
},
|
|
|
|
err: bunyan.stdSerializers.err,
|
|
|
|
req: bunyan.stdSerializers.req,
|
|
|
|
// Same as buyan's standard serializers, but gets headers as an object
|
|
// instead of a string.
|
|
// https://github.com/trentm/node-bunyan/blob/fe31b83e42d9c7f784e83fdcc528a7c76e0dacae/lib/bunyan.js#L1105-L1113
|
|
res (res) {
|
|
if (!res || !res.statusCode) {
|
|
return res
|
|
} else {
|
|
return {
|
|
duration: res.duration,
|
|
statusCode: res.statusCode,
|
|
headers: res.getHeaders()
|
|
}
|
|
}
|
|
}
|
|
}
|