Skip to content

Commit

Permalink
fix: electron-log updates for v4
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuef committed Dec 17, 2019
1 parent b936802 commit afc5f2a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 7 additions & 8 deletions app/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand All @@ -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;
Expand Down

0 comments on commit afc5f2a

Please # to comment.