2022-08-18 16:23:16 +02:00
|
|
|
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
|
2022-08-29 20:46:42 +02:00
|
|
|
): Promise<LogService> {
|
2022-08-18 16:23:16 +02:00
|
|
|
return factory(
|
|
|
|
cache,
|
|
|
|
"logService",
|
|
|
|
opts,
|
|
|
|
() => new ConsoleLogService(opts.logServiceOptions.isDev, opts.logServiceOptions.filter)
|
|
|
|
);
|
|
|
|
}
|