Skip to content

Commit fbd3878

Browse files
committed
refactor: extract all loggers to helper
Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent c59cc2b commit fbd3878

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/shared/logger.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,6 @@ import log from 'electron-log';
22

33
import type { Notification } from '../renderer/typesGitHub';
44

5-
function logMessage(
6-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
7-
logFunction: (...params: any[]) => void,
8-
type: string,
9-
message: string,
10-
err?: Error,
11-
notification?: Notification,
12-
) {
13-
const args: (string | Error)[] = [`[${type}]`, message];
14-
15-
if (notification) {
16-
args.push(
17-
`[${notification.subject.type} >> ${notification.repository.full_name} >> ${notification.subject.title}]`,
18-
);
19-
}
20-
21-
if (err) {
22-
args.push(err);
23-
}
24-
25-
logFunction(...args);
26-
}
27-
285
export function logInfo(
296
type: string,
307
message: string,
@@ -49,3 +26,26 @@ export function logError(
4926
) {
5027
logMessage(log.error, type, message, err, notification);
5128
}
29+
30+
function logMessage(
31+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
32+
logFunction: (...params: any[]) => void,
33+
type: string,
34+
message: string,
35+
err?: Error,
36+
notification?: Notification,
37+
) {
38+
const args: (string | Error)[] = [`[${type}]`, message];
39+
40+
if (notification) {
41+
args.push(
42+
`[${notification.subject.type} >> ${notification.repository.full_name} >> ${notification.subject.title}]`,
43+
);
44+
}
45+
46+
if (err) {
47+
args.push(err);
48+
}
49+
50+
logFunction(...args);
51+
}

0 commit comments

Comments
 (0)