Skip to content

Commit

Permalink
refactor: extract all loggers to helper
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Setch <adam.setch@outlook.com>
  • Loading branch information
setchy committed Dec 31, 2024
1 parent c59cc2b commit fbd3878
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/shared/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,6 @@ import log from 'electron-log';

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

function logMessage(
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
logFunction: (...params: any[]) => void,
type: string,
message: string,
err?: Error,
notification?: Notification,
) {
const args: (string | Error)[] = [`[${type}]`, message];

if (notification) {
args.push(
`[${notification.subject.type} >> ${notification.repository.full_name} >> ${notification.subject.title}]`,
);
}

if (err) {
args.push(err);
}

logFunction(...args);
}

export function logInfo(
type: string,
message: string,
Expand All @@ -49,3 +26,26 @@ export function logError(
) {
logMessage(log.error, type, message, err, notification);
}

function logMessage(
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
logFunction: (...params: any[]) => void,
type: string,
message: string,
err?: Error,
notification?: Notification,
) {
const args: (string | Error)[] = [`[${type}]`, message];

if (notification) {
args.push(
`[${notification.subject.type} >> ${notification.repository.full_name} >> ${notification.subject.title}]`,
);
}

if (err) {
args.push(err);
}

logFunction(...args);
}

0 comments on commit fbd3878

Please sign in to comment.