From 27046cb38e08ffdc93800abf63857e4b8b4f7e20 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 23 Feb 2018 23:27:20 -0500 Subject: [PATCH] wire up updater logger --- src/app/services/services.module.ts | 2 +- src/main/updater.main.ts | 3 +++ src/scripts/updaterLogger.ts | 23 +++++++++++++++++++++++ src/services/log.service.ts | 5 +++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/scripts/updaterLogger.ts diff --git a/src/app/services/services.module.ts b/src/app/services/services.module.ts index fef47216ac..4ba895e86d 100644 --- a/src/app/services/services.module.ts +++ b/src/app/services/services.module.ts @@ -11,8 +11,8 @@ import { DesktopPlatformUtilsService } from '../../services/desktopPlatformUtils import { DesktopRendererMessagingService } from '../../services/desktopRendererMessaging.service'; import { DesktopRendererSecureStorageService } from '../../services/desktopRendererSecureStorage.service'; import { DesktopStorageService } from '../../services/desktopStorage.service'; -import { LogService } from '../../services/log.service'; import { I18nService } from '../../services/i18n.service'; +import { LogService } from '../../services/log.service'; import { AuthGuardService } from './auth-guard.service'; import { BroadcasterService } from './broadcaster.service'; diff --git a/src/main/updater.main.ts b/src/main/updater.main.ts index a01d262723..3de545b72d 100644 --- a/src/main/updater.main.ts +++ b/src/main/updater.main.ts @@ -7,6 +7,7 @@ import { import { autoUpdater } from 'electron-updater'; import { Main } from '../main'; +import { UpdaterLogger } from '../scripts/updaterLogger'; import { isAppImage, isDev, @@ -24,6 +25,8 @@ export class UpdaterMain { private canUpdate = false; constructor(private main: Main) { + autoUpdater.logger = new UpdaterLogger(main.logService); + const linuxCanUpdate = process.platform === 'linux' && isAppImage(); const windowsCanUpdate = process.platform === 'win32' && !isWindowsStore() && !isWindowsPortable(); const macCanUpdate = process.platform === 'darwin' && !isMacAppStore(); diff --git a/src/scripts/updaterLogger.ts b/src/scripts/updaterLogger.ts new file mode 100644 index 0000000000..0e91569302 --- /dev/null +++ b/src/scripts/updaterLogger.ts @@ -0,0 +1,23 @@ +import { Logger } from 'electron-updater'; + +import { LogService } from 'jslib/abstractions/log.service'; + +export class UpdaterLogger implements Logger { + constructor(private logService: LogService) { } + + debug(message: string): void { + this.logService.debug(message); + } + + info(message?: any): void { + this.logService.info(message); + } + + warn(message?: any): void { + this.logService.warning(message); + } + + error(message?: any): void { + this.logService.error(message); + } +} diff --git a/src/services/log.service.ts b/src/services/log.service.ts index c8b7199fbc..31b447c69c 100644 --- a/src/services/log.service.ts +++ b/src/services/log.service.ts @@ -9,6 +9,11 @@ import { LogService as LogServiceAbstraction } from 'jslib/abstractions/log.serv export class LogService implements LogServiceAbstraction { constructor(private filter: (level: LogLevelType) => boolean = null, logDir: string = null) { + if (log.transports == null) { + return; + } + + log.transports.file.level = 'info'; if (logDir != null) { log.transports.file.file = path.join(logDir, 'app.log'); }