From f0d4635c5f875c7bcc4843767288376c198d7cb9 Mon Sep 17 00:00:00 2001 From: Chad Scharf <3904944+cscharf@users.noreply.github.com> Date: Tue, 20 Oct 2020 10:07:36 -0400 Subject: [PATCH] Add log service and pass to lowdb storage --- jslib | 2 +- src/bw.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/jslib b/jslib index d84d6da7f7..4cd20f0fa8 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit d84d6da7f77ec89ba69299b1ff982f083fd77203 +Subproject commit 4cd20f0fa8c040989e8b9e8037c00bbafeb9b653 diff --git a/src/bw.ts b/src/bw.ts index 9a42c9f645..e0e48538fb 100644 --- a/src/bw.ts +++ b/src/bw.ts @@ -2,12 +2,15 @@ import * as fs from 'fs'; import * as jsdom from 'jsdom'; import * as path from 'path'; +import { LogLevelType } from 'jslib/enums/logLevelType'; + import { AuthService } from 'jslib/services/auth.service'; import { I18nService } from './services/i18n.service'; import { NodeEnvSecureStorageService } from './services/nodeEnvSecureStorage.service'; import { CliPlatformUtilsService } from 'jslib/cli/services/cliPlatformUtils.service'; +import { ConsoleLogService } from 'jslib/cli/services/consoleLog.service'; import { AppIdService } from 'jslib/services/appId.service'; import { AuditService } from 'jslib/services/audit.service'; @@ -72,6 +75,7 @@ export class Main { authService: AuthService; policyService: PolicyService; program: Program; + logService: ConsoleLogService; constructor() { let p = null; @@ -92,8 +96,10 @@ export class Main { this.i18nService = new I18nService('en', './locales'); this.platformUtilsService = new CliPlatformUtilsService('cli', packageJson); + this.logService = new ConsoleLogService(this.platformUtilsService.isDev(), + (level) => process.env.BITWARDENCLI_DEBUG !== 'true' && level <= LogLevelType.Info); this.cryptoFunctionService = new NodeCryptoFunctionService(); - this.storageService = new LowdbStorageService(null, p, true); + this.storageService = new LowdbStorageService(this.logService, null, p, true); this.secureStorageService = new NodeEnvSecureStorageService(this.storageService, () => this.cryptoService); this.cryptoService = new CryptoService(this.storageService, this.secureStorageService, this.cryptoFunctionService);