Skip to content

Commit 496cf17

Browse files
committed
refactor: extract all loggers to helper
Signed-off-by: Adam Setch <[email protected]>
1 parent 22ffd1a commit 496cf17

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/renderer/utils/logger.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,19 @@ function logMessage(
99
err?: Error,
1010
notification?: Notification,
1111
) {
12-
if (notification && err) {
13-
logFunction(
14-
`[${type}]:`,
15-
message,
16-
`[${notification.subject.type}]: ${notification.subject.title} for repository ${notification.repository.full_name}`,
17-
err,
18-
);
19-
} else if (notification) {
20-
logFunction(
21-
`[${type}]:`,
22-
message,
12+
const args: (string | Error)[] = [`[${type}]:`, message];
13+
14+
if (notification) {
15+
args.push(
2316
`[${notification.subject.type}]: ${notification.subject.title} for repository ${notification.repository.full_name}`,
2417
);
25-
} else if (err) {
26-
logFunction(`[${type}]:`, message, err);
27-
} else {
28-
logFunction(`[${type}]:`, message);
2918
}
19+
20+
if (err) {
21+
args.push(err);
22+
}
23+
24+
logFunction(...args);
3025
}
3126

3227
export function logInfo(

0 commit comments

Comments
 (0)