mirror of
https://github.com/bitwarden/browser
synced 2026-01-04 09:33:27 +00:00
Use log service for console messages (#221)
* Use logService for console messages * Implement a base ConsoleLog service Use this class as a default for other services that would like to output to console. This service is overriden in CLI and Desktop to use CLI's consoleLogService and electronLogService, respectively. * Use browser-process-hrtime for timing * test LogService implementations * Ignore default import of hrtime * Clean up imports. Require ConsoleLog injection Co-authored-by: Matt Gibson <mdgibson@Matts-MBP.lan>
This commit is contained in:
@@ -5,10 +5,12 @@ import { isDev } from '../utils';
|
||||
|
||||
import { LogLevelType } from '../../enums/logLevelType';
|
||||
|
||||
import { LogService as LogServiceAbstraction } from '../../abstractions/log.service';
|
||||
import { ConsoleLogService as BaseLogService } from '../../services/consoleLog.service';
|
||||
|
||||
export class ElectronLogService implements LogServiceAbstraction {
|
||||
constructor(private filter: (level: LogLevelType) => boolean = null, logDir: string = null) {
|
||||
export class ElectronLogService extends BaseLogService {
|
||||
|
||||
constructor(protected filter: (level: LogLevelType) => boolean = null, logDir: string = null) {
|
||||
super(isDev(), filter);
|
||||
if (log.transports == null) {
|
||||
return;
|
||||
}
|
||||
@@ -19,26 +21,6 @@ export class ElectronLogService implements LogServiceAbstraction {
|
||||
}
|
||||
}
|
||||
|
||||
debug(message: string) {
|
||||
if (!isDev()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.write(LogLevelType.Debug, message);
|
||||
}
|
||||
|
||||
info(message: string) {
|
||||
this.write(LogLevelType.Info, message);
|
||||
}
|
||||
|
||||
warning(message: string) {
|
||||
this.write(LogLevelType.Warning, message);
|
||||
}
|
||||
|
||||
error(message: string) {
|
||||
this.write(LogLevelType.Error, message);
|
||||
}
|
||||
|
||||
write(level: LogLevelType, message: string) {
|
||||
if (this.filter != null && this.filter(level)) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user