Import log instead of using it off of window
This commit is contained in:
parent
8eb0dd3116
commit
65ddf0a9e8
155 changed files with 3654 additions and 3433 deletions
|
@ -2,7 +2,7 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
/* eslint-env node */
|
||||
/* global log, Signal */
|
||||
/* global Signal, window */
|
||||
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
|
@ -58,7 +58,7 @@ exports.createConversation = async ({
|
|||
await Promise.all(
|
||||
range(0, numMessages).map(async index => {
|
||||
await sleep(index * 100);
|
||||
log.info(`Create message ${index + 1}`);
|
||||
window.SignalWindow.log.info(`Create message ${index + 1}`);
|
||||
const message = await createRandomMessage({ conversationId });
|
||||
return Signal.Data.saveMessage(message);
|
||||
})
|
||||
|
@ -108,7 +108,10 @@ const createRandomMessage = async ({ conversationId } = {}) => {
|
|||
};
|
||||
|
||||
const message = _createMessage({ commonProperties, conversationId, type });
|
||||
return Message.initializeSchemaVersion({ message, logger: log });
|
||||
return Message.initializeSchemaVersion({
|
||||
message,
|
||||
logger: window.SignalWindow.log,
|
||||
});
|
||||
};
|
||||
|
||||
const _createMessage = ({ commonProperties, conversationId, type } = {}) => {
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
|
||||
/* eslint-env node, browser */
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
const log = typeof window !== 'undefined' ? window.log : console;
|
||||
|
||||
exports.setup = (locale, messages) => {
|
||||
if (!locale) {
|
||||
throw new Error('i18n: locale parameter is required');
|
||||
|
@ -15,6 +12,10 @@ exports.setup = (locale, messages) => {
|
|||
}
|
||||
|
||||
function getMessage(key, substitutions) {
|
||||
// eslint-disable-next-line no-console
|
||||
const log =
|
||||
typeof window !== 'undefined' ? window.SignalWindow.log : console;
|
||||
|
||||
const entry = messages[key];
|
||||
if (!entry) {
|
||||
log.error(
|
||||
|
|
|
@ -16,7 +16,7 @@ class IdleDetector extends EventEmitter {
|
|||
}
|
||||
|
||||
start() {
|
||||
window.log.info('Start idle detector');
|
||||
window.SignalWindow.log.info('Start idle detector');
|
||||
this._scheduleNextCallback();
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ class IdleDetector extends EventEmitter {
|
|||
return;
|
||||
}
|
||||
|
||||
window.log.info('Stop idle detector');
|
||||
window.SignalWindow.log.info('Stop idle detector');
|
||||
this._clearScheduledCallbacks();
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,9 @@ module.exports = {
|
|||
};
|
||||
|
||||
async function doesDatabaseExist() {
|
||||
window.log.info('Checking for the existence of IndexedDB data...');
|
||||
window.SignalWindow.log.info(
|
||||
'Checking for the existence of IndexedDB data...'
|
||||
);
|
||||
return new Promise((resolve, reject) => {
|
||||
const { id } = Whisper.Database;
|
||||
const req = window.indexedDB.open(id);
|
||||
|
@ -20,7 +22,7 @@ async function doesDatabaseExist() {
|
|||
let existed = true;
|
||||
|
||||
setTimeout(() => {
|
||||
window.log.warn(
|
||||
window.SignalWindow.log.warn(
|
||||
'doesDatabaseExist: Timed out attempting to check IndexedDB status'
|
||||
);
|
||||
return resolve(false);
|
||||
|
@ -41,6 +43,8 @@ async function doesDatabaseExist() {
|
|||
}
|
||||
|
||||
function removeDatabase() {
|
||||
window.log.info(`Deleting IndexedDB database '${Whisper.Database.id}'`);
|
||||
window.SignalWindow.log.info(
|
||||
`Deleting IndexedDB database '${Whisper.Database.id}'`
|
||||
);
|
||||
window.indexedDB.deleteDatabase(Whisper.Database.id);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ exports.processNext = async ({
|
|||
}
|
||||
);
|
||||
} catch (error) {
|
||||
window.log.error(
|
||||
window.SignalWindow.log.error(
|
||||
'processNext error:',
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
|
|
|
@ -53,7 +53,7 @@ function buildAvatarUpdater({ field }) {
|
|||
const { hash, path } = avatar;
|
||||
const exists = await doesAttachmentExist(path);
|
||||
if (!exists) {
|
||||
window.log.warn(
|
||||
window.SignalWindow.log.warn(
|
||||
`Conversation.buildAvatarUpdater: attachment ${path} did not exist`
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue