Skip to content

Commit

Permalink
chore: correct log messages and add metadata to logger output
Browse files Browse the repository at this point in the history
Removed comma in log messages and included issue URL as metadata in logs.
  • Loading branch information
gentlementlegen committed Nov 2, 2024
1 parent 11529fb commit 903692e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/helpers/remind-and-remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function remindAssigneesForIssue(context: ContextPlugin, issue: Lis
} else if (config.pullRequestRequired && !hasLinkedPr) {
await unassignUserFromIssue(context, issue);
} else {
logger.info(`Passed the reminder threshold on ${issue.html_url}, sending a reminder.`);
logger.info(`Passed the reminder threshold on ${issue.html_url} sending a reminder.`);
await remindAssignees(context, issue);
}
}
Expand Down Expand Up @@ -96,7 +96,9 @@ async function removeAllAssignees(context: ContextPlugin, issue: ListIssueForRep
return false;
}
const logins = issue.assignees.map((o) => o?.login).filter((o) => !!o) as string[];
const logMessage = logger.info(`Passed the deadline and no activity is detected, removing assignees: ${logins.map((o) => `@${o}`).join(", ")}.`);
const logMessage = logger.info(`Passed the deadline and no activity is detected, removing assignees: ${logins.map((o) => `@${o}`).join(", ")}.`, {
issue: issue.html_url,
});
const metadata = createStructuredMetadata(UNASSIGN_HEADER, logMessage);

await octokit.rest.issues.createComment({
Expand Down
6 changes: 3 additions & 3 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe("User start/stop", () => {

expect(errorSpy).toHaveBeenCalledWith(`Failed to update activity for ${getIssueHtmlUrl(1)}, there is no assigned event.`);
expect(infoSpy).toHaveBeenCalledWith(`Nothing to do for ${getIssueHtmlUrl(2)}, still within due-time.`);
expect(infoSpy).toHaveBeenCalledWith(`Passed the reminder threshold on ${getIssueHtmlUrl(3)}, sending a reminder.`);
expect(infoSpy).toHaveBeenCalledWith(`Passed the reminder threshold on ${getIssueHtmlUrl(3)} sending a reminder.`);
expect(infoSpy).toHaveBeenCalledWith(`@user2, this task has been idle for a while. Please provide an update.\n\n`, {
taskAssignees: [2],
caller: STRINGS.LOGS_ANON_CALLER,
Expand All @@ -138,7 +138,7 @@ describe("User start/stop", () => {
await expect(run(context)).resolves.toEqual({ message: "OK" });

expect(infoSpy).toHaveBeenCalledWith(`Nothing to do for ${getIssueHtmlUrl(2)}, still within due-time.`);
expect(infoSpy).toHaveBeenCalledWith(`Passed the reminder threshold on ${getIssueHtmlUrl(3)}, sending a reminder.`);
expect(infoSpy).toHaveBeenCalledWith(`Passed the reminder threshold on ${getIssueHtmlUrl(3)} sending a reminder.`);
expect(infoSpy).toHaveBeenCalledWith(`@user2, this task has been idle for a while. Please provide an update.\n\n`, {
taskAssignees: [2],
caller: STRINGS.LOGS_ANON_CALLER,
Expand All @@ -157,7 +157,7 @@ describe("User start/stop", () => {
await run(context);

expect(infoSpy).toHaveBeenCalledWith(`Nothing to do for ${getIssueHtmlUrl(2)}, still within due-time.`);
expect(infoSpy).toHaveBeenCalledWith(`Passed the reminder threshold on ${getIssueHtmlUrl(3)}, sending a reminder.`);
expect(infoSpy).toHaveBeenCalledWith(`Passed the reminder threshold on ${getIssueHtmlUrl(3)} sending a reminder.`);
expect(infoSpy).toHaveBeenCalledWith(`@user2, this task has been idle for a while. Please provide an update.\n\n`, {
taskAssignees: [2],
caller: STRINGS.LOGS_ANON_CALLER,
Expand Down

0 comments on commit 903692e

Please sign in to comment.