diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-02-23 12:30:17 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-02-23 12:30:17 +0100 |
| commit | e92be2d1736cc2b4e64965a3291325ffe8a637db (patch) | |
| tree | a154472a4a415ae562956fd435d917f8a305df13 /gui/src | |
| parent | a6213b703db127554953d4fb4bbcc58dded97861 (diff) | |
| parent | 8f2c906eff0194d2142301c9f794609f04e2dd7a (diff) | |
| download | mullvadvpn-e92be2d1736cc2b4e64965a3291325ffe8a637db.tar.xz mullvadvpn-e92be2d1736cc2b4e64965a3291325ffe8a637db.zip | |
Merge branch 'improve-logger'
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/main/logging.ts | 6 | ||||
| -rw-r--r-- | gui/src/shared/logging.ts | 7 |
2 files changed, 9 insertions, 4 deletions
diff --git a/gui/src/main/logging.ts b/gui/src/main/logging.ts index fb3730d59e..23c0f6ad1d 100644 --- a/gui/src/main/logging.ts +++ b/gui/src/main/logging.ts @@ -4,7 +4,7 @@ import path from 'path'; import { IpcMainEventChannel } from './ipc-event-channel'; import { LogLevel, ILogInput, ILogOutput } from '../shared/logging-types'; -export const OLD_LOG_FILES = ['frontend-renderer.log']; +export const OLD_LOG_FILES = ['main.log', 'renderer.log']; export class FileOutput implements ILogOutput { private fileDescriptor: number; @@ -37,11 +37,11 @@ export class IpcInput implements ILogInput { } export function getMainLogPath() { - return path.join(getLogDirectoryDir(), 'main.log'); + return path.join(getLogDirectoryDir(), 'frontend-main.log'); } export function getRendererLogPath() { - return path.join(getLogDirectoryDir(), 'renderer.log'); + return path.join(getLogDirectoryDir(), 'frontend-renderer.log'); } export function createLoggingDirectory(): void { diff --git a/gui/src/shared/logging.ts b/gui/src/shared/logging.ts index 43d0b271d9..84eaa5f25c 100644 --- a/gui/src/shared/logging.ts +++ b/gui/src/shared/logging.ts @@ -14,7 +14,8 @@ export class Logger { public log(level: LogLevel, ...data: unknown[]) { const time = moment().format('YYYY-MM-DD HH:mm:ss.SSS'); - const message = `[${time}][${LogLevel[level]}] ${data.join(' ')}`; + const stringifiedData = data.map(this.stringifyData).join(' '); + const message = `[${time}][${LogLevel[level]}] ${stringifiedData}`; this.outputMessage(level, message); } @@ -29,6 +30,10 @@ export class Logger { this.outputs.forEach((output) => output.dispose?.()); } + private stringifyData(data: unknown): string { + return typeof data === 'string' ? data : JSON.stringify(data); + } + private outputMessage(level: LogLevel, message: string) { this.outputs .filter((output) => level <= output.level) |
