Skip to content

Commit 81f5d4d

Browse files
authored
fix: revert logging to the same schema as it used to be (#466)
1 parent f8ea664 commit 81f5d4d

File tree

5 files changed

+94
-115
lines changed

5 files changed

+94
-115
lines changed

api/github/webhooks.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
const { createNodeMiddleware, createProbot } = require("probot");
2-
const pino = require("pino");
32

43
const app = require("../../app");
54

65
module.exports = createNodeMiddleware(app, {
7-
probot: createProbot({
8-
overrides: {
9-
log: pino(),
10-
},
11-
}),
6+
probot: createProbot(),
127
webhooksPath: "/api/github/webhooks",
138
});

lib/process-issue-comment.js

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,8 @@ async function processIssueComment({ context, commentReply }) {
1313

1414
const { action, contributors } = parseComment(commentBody);
1515

16-
const log = context.log.child({
17-
action,
18-
contributors,
19-
account: repo.owner.id,
20-
accountType: repo.owner.type.toLowerCase(),
21-
accountLogin: repo.owner.login,
22-
createdBy: createdBy.id,
23-
createdByLogin: createdBy.login,
24-
createdByType: createdBy.type.toLowerCase(),
25-
repository: repo.id,
26-
private: repo.private,
27-
success: false,
28-
});
29-
3016
if (action !== "add") {
31-
log.info(`Unknown action "${action}"`);
17+
context.log.info(`Unknown action "${action}"`);
3218
commentReply.reply(`I could not determine your intention.`);
3319
commentReply.reply(
3420
`Basic usage: @all-contributors please add @someone for code, doc and infra`
@@ -40,15 +26,44 @@ async function processIssueComment({ context, commentReply }) {
4026
}
4127

4228
for (var contributor in contributors) {
43-
const who = contributor
44-
const contributions = contributors[who]
29+
const who = contributor;
30+
const contributions = contributors[who];
4531
const branchName = `all-contributors/add-${toSafeGitReferenceName(who)}`;
4632

47-
await triggerActionAdd(context, commentReply, log, who, contributions, branchName)
33+
const log = context.log.child({
34+
who,
35+
action,
36+
contributions,
37+
account: repo.owner.id,
38+
accountType: repo.owner.type.toLowerCase(),
39+
accountLogin: repo.owner.login,
40+
createdBy: createdBy.id,
41+
createdByLogin: createdBy.login,
42+
createdByType: createdBy.type.toLowerCase(),
43+
repository: repo.id,
44+
private: repo.private,
45+
success: false,
46+
});
47+
48+
await triggerActionAdd(
49+
context,
50+
commentReply,
51+
log,
52+
who,
53+
contributions,
54+
branchName
55+
);
4856
}
4957
}
5058

51-
async function triggerActionAdd(context, commentReply, log, who, contributions, branchName) {
59+
async function triggerActionAdd(
60+
context,
61+
commentReply,
62+
log,
63+
who,
64+
contributions,
65+
branchName
66+
) {
5267
if (contributions.length === 0) {
5368
log.info("No contributions");
5469
commentReply.reply(
@@ -77,13 +92,13 @@ async function triggerActionAdd(context, commentReply, log, who, contributions,
7792
branchName,
7893
});
7994

80-
if(!pullCreated) {
95+
if (!pullCreated) {
8196
log.info(
82-
{
83-
pullCreated,
84-
success: true,
85-
},
86-
`${who} already have ${contributions.join(", ")}`
97+
{
98+
pullCreated,
99+
success: true,
100+
},
101+
`${who} already have ${contributions.join(", ")}`
87102
);
88103
return;
89104
}

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"got": ">=11.8.5",
3030
"jest": "^27.3.1",
3131
"nock": "^13.1.4",
32-
"pino": "^6.11.2",
3332
"prettier": "^2.4.1",
3433
"smee-client": "^1.2.3",
3534
"vercel": "^28.15.3"

0 commit comments

Comments
 (0)