diff --git a/app/main.ts b/app/main.ts index da4fb92db1e..cb7037d146f 100644 --- a/app/main.ts +++ b/app/main.ts @@ -30,6 +30,7 @@ import packageJson from '../package.json'; import * as GlobalErrors from './global_errors'; import { setup as setupSpellChecker } from './spell_check'; import { redactAll, addSensitivePath } from '../ts/util/privacy'; +import { consoleLogger } from '../ts/util/consoleLogger'; import { remove as removeUserConfig } from './user_config'; import './startup_config'; @@ -253,7 +254,8 @@ let settingsChannel: SettingsChannel | undefined; function getLogger(): LoggerType { if (!logger) { - throw new Error('getLogger: Logger not yet initialized!'); + console.warn('getLogger: Logger not yet initialized!'); + return consoleLogger; } return logger; diff --git a/ts/sql/Server.ts b/ts/sql/Server.ts index 067da9ba098..ee66e8088ea 100644 --- a/ts/sql/Server.ts +++ b/ts/sql/Server.ts @@ -36,6 +36,7 @@ import { STORAGE_UI_KEYS } from '../types/StorageUIKeys'; import { StoredJob } from '../jobs/types'; import { assert } from '../util/assert'; import { combineNames } from '../util/combineNames'; +import { consoleLogger } from '../util/consoleLogger'; import { dropNull } from '../util/dropNull'; import { isNormalNumber } from '../util/isNormalNumber'; import { isNotNil } from '../util/isNotNil'; @@ -2689,28 +2690,7 @@ function getOurUuid(db: Database): string | undefined { } let globalInstance: Database | undefined; -/* eslint-disable no-console */ -let logger: LoggerType = { - fatal(...args: Array) { - console.error(...args); - }, - error(...args: Array) { - console.error(...args); - }, - warn(...args: Array) { - console.warn(...args); - }, - info(...args: Array) { - console.info(...args); - }, - debug(...args: Array) { - console.debug(...args); - }, - trace(...args: Array) { - console.log(...args); - }, -}; -/* eslint-enable no-console */ +let logger = consoleLogger; let globalInstanceRenderer: Database | undefined; let databaseFilePath: string | undefined; let indexedDBPath: string | undefined; diff --git a/ts/util/consoleLogger.ts b/ts/util/consoleLogger.ts new file mode 100644 index 00000000000..47ed99ee8e1 --- /dev/null +++ b/ts/util/consoleLogger.ts @@ -0,0 +1,27 @@ +// Copyright 2021 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + +import type { LoggerType } from '../types/Logging'; + +/* eslint-disable no-console */ +export const consoleLogger: LoggerType = { + fatal(...args: Array) { + console.error(...args); + }, + error(...args: Array) { + console.error(...args); + }, + warn(...args: Array) { + console.warn(...args); + }, + info(...args: Array) { + console.info(...args); + }, + debug(...args: Array) { + console.debug(...args); + }, + trace(...args: Array) { + console.log(...args); + }, +}; +/* eslint-enable no-console */