From fbd38789a6c00f088f054c80b9593f42e2ab2240 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Tue, 31 Dec 2024 08:19:42 +0100 Subject: [PATCH] refactor: extract all loggers to helper Signed-off-by: Adam Setch --- src/shared/logger.ts | 46 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/shared/logger.ts b/src/shared/logger.ts index 2a688146e..f9242160f 100644 --- a/src/shared/logger.ts +++ b/src/shared/logger.ts @@ -2,29 +2,6 @@ import log from 'electron-log'; import type { Notification } from '../renderer/typesGitHub'; -function logMessage( - // biome-ignore lint/suspicious/noExplicitAny: - 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, @@ -49,3 +26,26 @@ export function logError( ) { logMessage(log.error, type, message, err, notification); } + +function logMessage( + // biome-ignore lint/suspicious/noExplicitAny: + 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); +}