mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-01 13:13:36 +01:00
43d428b3df
* Work on background service worker. * Work on shortcuts * Work on supporting service worker * Put new background behind version check * Fix build * Use new storage service * create commands from crypto service (#2995) * Work on service worker autofill * Got basic autofill working * Final touches * Work on tests * Revert some changes * Add modifications * Remove unused ciphers for now * Cleanup * Address PR feedback * Update lock file * Update noop service * Add chrome type * Handle "/" in branch names Updates web workflow to handle the `/` in branch names when it's a PR. * Remove any Co-authored-by: Jake Fink <jfink@bitwarden.com> Co-authored-by: Micaiah Martin <77340197+mimartin12@users.noreply.github.com>
58 lines
1.3 KiB
TypeScript
58 lines
1.3 KiB
TypeScript
import { LogService as LogServiceAbstraction } from "../abstractions/log.service";
|
|
import { LogLevelType } from "../enums/logLevelType";
|
|
|
|
export class ConsoleLogService implements LogServiceAbstraction {
|
|
protected timersMap: Map<string, [number, number]> = new Map();
|
|
|
|
constructor(
|
|
protected isDev: boolean,
|
|
protected filter: (level: LogLevelType) => boolean = null
|
|
) {}
|
|
|
|
debug(message: string) {
|
|
if (!this.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;
|
|
}
|
|
|
|
switch (level) {
|
|
case LogLevelType.Debug:
|
|
// eslint-disable-next-line
|
|
console.log(message);
|
|
break;
|
|
case LogLevelType.Info:
|
|
// eslint-disable-next-line
|
|
console.log(message);
|
|
break;
|
|
case LogLevelType.Warning:
|
|
// eslint-disable-next-line
|
|
console.warn(message);
|
|
break;
|
|
case LogLevelType.Error:
|
|
// eslint-disable-next-line
|
|
console.error(message);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|