Use window.log in browser context, turn on console eslint rule

This commit is contained in:
Scott Nonnenberg 2018-07-21 12:00:08 -07:00
parent 4320b125dd
commit 5933a34a18
71 changed files with 816 additions and 559 deletions

View file

@ -156,7 +156,7 @@
async onExpiredCollection(message) {
const removeMessage = () => {
console.log('Remove expired message from collection', {
window.log.info('Remove expired message from collection', {
sentAt: message.get('sent_at'),
});
this.messageCollection.remove(message.id);
@ -347,7 +347,7 @@
return lookup;
})
.catch(error => {
console.log(
window.log.error(
'getIdentityKeys error for conversation',
this.idForLogging(),
error && error.stack ? error.stack : error
@ -361,7 +361,7 @@
lookup[contact.id] = key;
},
error => {
console.log(
window.log.error(
'getIdentityKeys error for group member',
contact.idForLogging(),
error && error.stack ? error.stack : error
@ -375,7 +375,7 @@
replay(error, message) {
const replayable = new textsecure.ReplayableError(error);
return replayable.replay(message.attributes).catch(e => {
console.log('replay error:', e && e.stack ? e.stack : e);
window.log.error('replay error:', e && e.stack ? e.stack : e);
});
},
decryptOldIncomingKeyErrors() {
@ -383,7 +383,10 @@
if (this.get('decryptedOldIncomingKeyErrors')) {
return Promise.resolve();
}
console.log('decryptOldIncomingKeyErrors start for', this.idForLogging());
window.log.info(
'decryptOldIncomingKeyErrors start for',
this.idForLogging()
);
const messages = this.messageCollection.filter(message => {
const errors = message.get('errors');
@ -399,7 +402,7 @@
});
const markComplete = () => {
console.log(
window.log.info(
'decryptOldIncomingKeyErrors complete for',
this.idForLogging()
);
@ -412,7 +415,7 @@
return markComplete();
}
console.log(
window.log.info(
'decryptOldIncomingKeyErrors found',
messages.length,
'messages to process'
@ -449,7 +452,7 @@
)
)
.catch(error => {
console.log(
window.log.error(
'decryptOldIncomingKeyErrors error:',
error && error.stack ? error.stack : error
);
@ -583,7 +586,7 @@
},
addKeyChange(id) {
console.log(
window.log.info(
'adding key change advisory for',
this.idForLogging(),
id,
@ -606,7 +609,7 @@
_.defaults(options, { local: true });
if (this.isMe()) {
console.log(
window.log.info(
'refusing to add verified change advisory for our own number'
);
return;
@ -614,7 +617,7 @@
const lastMessage = this.get('timestamp') || Date.now();
console.log(
window.log.info(
'adding verified change advisory for',
this.idForLogging(),
id,
@ -823,7 +826,7 @@
this.queueJob(async () => {
const now = Date.now();
console.log(
window.log.info(
'Sending message to conversation',
this.idForLogging(),
'with timestamp',
@ -933,7 +936,7 @@
return Promise.resolve();
}
console.log("Update conversation 'expireTimer'", {
window.log.info("Update conversation 'expireTimer'", {
id: this.idForLogging(),
expireTimer,
source,
@ -1085,7 +1088,7 @@
if (this.messageCollection.get(m.id)) {
m = this.messageCollection.get(m.id);
} else {
console.log(
window.log.warn(
'Marked a message as read in the database, but ' +
'it was not in messageCollection.'
);
@ -1117,7 +1120,7 @@
read = read.filter(item => !item.hasErrors);
if (read.length && options.sendReadReceipts) {
console.log('Sending', read.length, 'read receipts');
window.log.info('Sending', read.length, 'read receipts');
promises.push(textsecure.messaging.syncReadMessages(read));
if (storage.get('read-receipt-setting')) {
@ -1173,7 +1176,7 @@
// save identity will close all sessions except for .1, so we
// must close that one manually.
const address = new libsignal.SignalProtocolAddress(id, 1);
console.log('closing session for', address.toString());
window.log.info('closing session for', address.toString());
const sessionCipher = new libsignal.SessionCipher(
textsecure.storage.protocol,
address
@ -1197,7 +1200,7 @@
e => {
if (e.name === 'ProfileDecryptError') {
// probably the profile key has changed.
console.log(
window.log.error(
'decryptProfile error:',
id,
profile,
@ -1209,7 +1212,7 @@
});
})
.catch(error => {
console.log(
window.log.error(
'getProfile error:',
error && error.stack ? error.stack : error
);
@ -1365,7 +1368,7 @@
await wrapDeferred(message.save());
}
} catch (error) {
console.log(
window.log.error(
'Problem upgrading message quoted message from database',
Errors.toLogFormat(error)
);
@ -1532,7 +1535,7 @@
throw new Error('This conversation has no id!');
}
if (this.inProgressFetch) {
console.log('Attempting to start a parallel fetchMessages() call');
window.log.warn('Attempting to start a parallel fetchMessages() call');
return;
}
@ -1550,7 +1553,7 @@
// one-time hit. We do this so we have guarantees about message structure.
await this.upgradeMessages(this.messageCollection);
} catch (error) {
console.log(
window.log.error(
'fetchMessages: failed to upgrade messages',
Errors.toLogFormat(error)
);
@ -1758,7 +1761,7 @@
const messageId = message.id;
const isExpiringMessage = Message.hasExpiration(messageJSON);
console.log('Add notification', {
window.log.info('Add notification', {
conversationId: this.idForLogging(),
isExpiringMessage,
messageSentAt,