mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 21:33:27 +00:00
[PM-3754] Update electron log (#6680)
This commit is contained in:
@@ -76,6 +76,7 @@ export class Main {
|
||||
}
|
||||
|
||||
this.logService = new ElectronLogService(null, app.getPath("userData"));
|
||||
this.logService.init();
|
||||
this.i18nService = new I18nMainService("en", "./locales/");
|
||||
|
||||
const storageDefaults: any = {};
|
||||
|
||||
@@ -8,16 +8,24 @@ import { ConsoleLogService as BaseLogService } from "@bitwarden/common/platform/
|
||||
import { isDev } from "../../utils";
|
||||
|
||||
export class ElectronLogService extends BaseLogService {
|
||||
constructor(protected filter: (level: LogLevelType) => boolean = null, logDir: string = null) {
|
||||
constructor(
|
||||
protected filter: (level: LogLevelType) => boolean = null,
|
||||
private logDir: string = null
|
||||
) {
|
||||
super(isDev(), filter);
|
||||
}
|
||||
|
||||
// Initialize the log file transport. Only needs to be done once in the main process.
|
||||
init() {
|
||||
if (log.transports == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.transports.file.level = "info";
|
||||
if (logDir != null) {
|
||||
log.transports.file.file = path.join(logDir, "app.log");
|
||||
if (this.logDir != null) {
|
||||
log.transports.file.resolvePathFn = () => path.join(this.logDir, "app.log");
|
||||
}
|
||||
log.initialize();
|
||||
}
|
||||
|
||||
write(level: LogLevelType, message: string) {
|
||||
|
||||
Reference in New Issue
Block a user