From afc5f2aa709188ba2872cd8b0fe3dd500e175056 Mon Sep 17 00:00:00 2001 From: Josh Wilson Date: Mon, 16 Dec 2019 17:02:15 +0100 Subject: [PATCH] fix: electron-log updates for v4 --- README.md | 6 ++++++ app/logger.ts | 15 +++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 018061bba..d17c6800b 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,12 @@ Logs are printed to both render console and stdout. Logs are also written to a l `yarn log-osx` will tail the file. Similar commands (as yet untested) exist for linux/windows. +`electron-log`is used under the hood, and ouputs logs to: + +- on Linux: ~/.config/safe-browser/logs/{process type}.log +- on macOS: ~/Library/Logs/Safe Browser/{process type}.log +- on Windows: %USERPROFILE%\AppData\Roaming\Safe Browser\logs\{process type}.log + ## Contributing As an open source project we're excited to accept contributions to the code from outside of MaidSafe, and are striving to make that as easy and clean as possible. diff --git a/app/logger.ts b/app/logger.ts index eaa4d5dc9..ef1287e07 100644 --- a/app/logger.ts +++ b/app/logger.ts @@ -22,8 +22,8 @@ import { if ( log.transports ) { // Log level // error, warn, log, log, debug, silly - // log.transports.console.level = 'silly'; log.transports.file.level = 'silly'; + log.transports.console.format = '[Renderer: {h}:{i}:{s}.{ms}] › {text}'; if ( isRunningSpectronTestProcess || @@ -34,22 +34,21 @@ if ( log.transports ) { log.transports.console.level = 'warn'; } - log.transports.file.file = path.resolve( os.tmpdir(), 'safe-browser.log' ); - - log.transports.console.format = '[{label} {h}:{i}:{s}.{ms}] › {text}'; if ( inTabProcess ) { - log.variables.label = `A Tab: `; + log.transports.file.fileName = 'tab.log'; + log.transports.console.format = '[Tab: {h}:{i}:{s}.{ms}] › {text}'; } if ( currentWindowId ) { - log.variables.label = `window ${currentWindowId}`; + log.transports.console.format = `[Window :${currentWindowId}: {h}:{i}:{s}.{ms}] › {text}`; } if ( inMainProcess ) { log.variables.label = 'main'; - log.transports.console.format = '%c[{label} {h}:{i}:{s}.{ms}]%c › {text}'; + log.transports.console.format = '%c{h}:{i}:{s}.{ms}%c › {text}'; } if ( inBgProcess ) { - log.variables.label = 'background'; + log.transports.file.fileName = 'background.log'; + log.transports.console.format = '[Background: {h}:{i}:{s}.{ms}] › {text}'; } log.transports.file.maxSize = 5 * 1024 * 1024;