Skip to content

Commit

Permalink
[MS] More electron logs in dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-7 committed Jun 18, 2024
1 parent 3af99ca commit 19a2ae0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/electron/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { PageToWindowChannel, WindowToPageChannel } from './communicationChannel
import { ElectronCapacitorApp, setupContentSecurityPolicy, setupReloadWatcher } from './setup';

const PARSEC_CONFIG_DIR_NAME = 'parsec3';
const ELECTRON_CONFIG_DIR_NAME = 'app';
const ELECTRON_CONFIG_DIR_NAME = electronIsDev ? 'app-dev' : 'app';

// Graceful handling of unhandled errors.
unhandled();
Expand Down
19 changes: 11 additions & 8 deletions client/electron/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@ export class ElectronCapacitorApp {
];

log.initialize();
this.logger = require('electron-log/node');
Object.assign(console, log.functions);
if (!electronIsDev) {
Object.assign(console, log.functions);
this.logger.transports.file.level = 'warn';
this.logger.transports.console.level = 'warn';
} else {
this.logger.transports.file.level = 'debug';
this.logger.transports.console.level = 'debug';
}
this.logger = require('electron-log/node');
this.logger.transports.file.level = 'warn';
this.logger.transports.console.level = 'warn';

if (appMenuBarMenuTemplate) {
this.AppMenuBarMenuTemplate = appMenuBarMenuTemplate;
Expand Down Expand Up @@ -145,19 +148,19 @@ export class ElectronCapacitorApp {
log(level: 'debug' | 'info' | 'warn' | 'error', message: string): void {
switch (level) {
case 'debug': {
this.logger.debug(message);
console.debug(message);
break;
}
case 'info': {
this.logger.info(message);
console.info(message);
break;
}
case 'warn': {
this.logger.warn(message);
console.warn(message);
break;
}
case 'error': {
this.logger.error(message);
console.error(message);
break;
}
}
Expand Down

0 comments on commit 19a2ae0

Please sign in to comment.