From 45c081c6b2422f05003a849befcdc6f74639c8f3 Mon Sep 17 00:00:00 2001 From: Sebastian Richner Date: Wed, 21 Feb 2024 13:58:13 +0100 Subject: [PATCH] Increase logging --- src/electron/electron/main/index.ts | 2 +- .../electron/main/services/trackers/TrackerService.ts | 4 ++++ src/electron/electron/shared/Logger.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/electron/electron/main/index.ts b/src/electron/electron/main/index.ts index ad818017..5a48593e 100644 --- a/src/electron/electron/main/index.ts +++ b/src/electron/electron/main/index.ts @@ -53,7 +53,7 @@ if (!app.requestSingleInstanceLock()) { // Optional, initialize the logger for any renderer process log.initialize(); -const LOG = getLogger('Main', true); +const LOG = getLogger('Main'); app.whenReady().then(async () => { app.setAppUserModelId('ch.ifi.hasel.personal-analytics'); diff --git a/src/electron/electron/main/services/trackers/TrackerService.ts b/src/electron/electron/main/services/trackers/TrackerService.ts index a9483348..14daac43 100644 --- a/src/electron/electron/main/services/trackers/TrackerService.ts +++ b/src/electron/electron/main/services/trackers/TrackerService.ts @@ -1,6 +1,9 @@ import { Tracker } from './Tracker'; import { TrackerConfig } from '../../../types/StudyConfig'; import { TrackerType } from '../../../enums/TrackerType.enum'; +import { getLogger } from '../../../shared/Logger'; + +const LOG = getLogger('TrackerService'); export class TrackerService { private trackers: Tracker[] = []; @@ -17,6 +20,7 @@ export class TrackerService { if (this.isTrackerAlreadyRegistered(trackerType)) { throw new Error(`Tracker ${trackerType} already registered!`); } + LOG.info(`Registering tracker ${trackerType}...`); if ( this.config.windowActivityTracker.enabled && diff --git a/src/electron/electron/shared/Logger.ts b/src/electron/electron/shared/Logger.ts index e564cc2b..61cc329c 100644 --- a/src/electron/electron/shared/Logger.ts +++ b/src/electron/electron/shared/Logger.ts @@ -2,7 +2,7 @@ import logger from 'electron-log/main'; import { LogFunctions } from 'electron-log'; import { LOG_FILE_NAME, LOG_LEVEL } from '../config/logger.config'; -const getLogger = (loggerName: string, background = false): LogFunctions => { +const getLogger = (loggerName: string, background = true): LogFunctions => { const currentDate: string = new Date().toISOString().split('T')[0]; const processName: string = background ? LOG_FILE_NAME.BACKGROUND : LOG_FILE_NAME.RENDERER; logger.transports.file.fileName = `${currentDate}-${processName}.log`;