bitwarden-estensione-browser/apps/browser/src/background/service_factories/log-service.factory.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
810 B
TypeScript
Raw Normal View History

import { LogService } from "@bitwarden/common/abstractions/log.service";
import { LogLevelType } from "@bitwarden/common/enums/logLevelType";
import { ConsoleLogService } from "@bitwarden/common/services/consoleLog.service";
import { CachedServices, factory, FactoryOptions } from "./factory-options";
type LogServiceFactoryOptions = FactoryOptions & {
logServiceOptions: {
isDev: boolean;
filter?: (level: LogLevelType) => boolean;
};
};
export type LogServiceInitOptions = LogServiceFactoryOptions;
export function logServiceFactory(
cache: { logService?: LogService } & CachedServices,
opts: LogServiceInitOptions
): LogService {
return factory(
cache,
"logService",
opts,
() => new ConsoleLogService(opts.logServiceOptions.isDev, opts.logServiceOptions.filter)
);
}