Files
probot/lib/serializers.js
Brandon Keepers e35028890a Improve GitHub logging (#351)
* 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
2017-11-27 10:18:58 -06:00

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()
}
}
}
}