diff --git a/src/main/services/config/config-manager.ts b/src/main/services/config/config-manager.ts index 24985c1..1281c7a 100644 --- a/src/main/services/config/config-manager.ts +++ b/src/main/services/config/config-manager.ts @@ -9,6 +9,7 @@ import * as fs from 'fs' import * as path from 'path' import { fileURLToPath } from 'url' import { dirname } from 'path' +import { createLogger } from '../logger' import type { SettingsData, DatabaseType, @@ -16,6 +17,8 @@ import type { ValidationDataSource } from '../../types/settings.types' +const log = createLogger('ConfigManager') + const __filename = fileURLToPath(import.meta.url) const __dirname = dirname(__filename) @@ -609,12 +612,12 @@ export class ConfigManager { try { if (fs.existsSync(this.envPath)) { fs.copyFileSync(this.envPath, this.backupPath) - console.log('[ConfigManager] Backup created', this.backupPath) + log.debug('Backup created', { path: this.backupPath }) return true } return false } catch (error) { - console.error('[ConfigManager] Failed to backup .env file:', error) + log.error('Failed to backup .env file', { error }) return false } } @@ -627,12 +630,12 @@ export class ConfigManager { if (fs.existsSync(this.backupPath)) { fs.copyFileSync(this.backupPath, this.envPath) await this.loadEnvFile() - console.log('[ConfigManager] Restored from backup') + log.debug('Restored from backup') return true } return false } catch (error) { - console.error('[ConfigManager] Failed to restore backup:', error) + log.error('Failed to restore backup', { error }) return false } } diff --git a/tests/main/services/config/config-manager.test.ts b/tests/main/services/config/config-manager.test.ts index 8847760..37ed857 100644 --- a/tests/main/services/config/config-manager.test.ts +++ b/tests/main/services/config/config-manager.test.ts @@ -78,10 +78,10 @@ describe('ConfigManager - backup and restore', () => { expect(backupSuccess).toBe(true) - // Check backup file exists (in same location as .env file) + // Check backup file exists (in same location as .env file, which is src/main/) const fs = await import('fs') const path = await import('path') - const backupPath = path.resolve('src/main/.env.backup') + const backupPath = path.resolve(process.cwd(), 'src/main/.env.backup') expect(fs.existsSync(backupPath)).toBe(true) })