Import log instead of using it off of window

This commit is contained in:
Josh Perez 2021-09-17 14:27:53 -04:00 committed by GitHub
parent 8eb0dd3116
commit 65ddf0a9e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
155 changed files with 3654 additions and 3433 deletions

View file

@ -39,6 +39,7 @@ import * as preferredReactionEmoji from '../reactions/preferredReactionEmoji';
import { UUID } from '../types/UUID';
import * as Errors from '../types/errors';
import { SignalService as Proto } from '../protobuf';
import * as log from '../logging/log';
const { updateConversation } = dataInterface;
@ -70,7 +71,7 @@ function addUnknownFields(
conversation: ConversationModel
): void {
if (record.__unknownFields) {
window.log.info(
log.info(
'storageService.addUnknownFields: Unknown fields found for',
conversation.idForLogging()
);
@ -82,7 +83,7 @@ function addUnknownFields(
} else if (conversation.get('storageUnknownFields')) {
// If the record doesn't have unknown fields attached but we have them
// saved locally then we need to clear it out
window.log.info(
log.info(
'storageService.addUnknownFields: Clearing unknown fields for',
conversation.idForLogging()
);
@ -96,7 +97,7 @@ function applyUnknownFields(
): void {
const storageUnknownFields = conversation.get('storageUnknownFields');
if (storageUnknownFields) {
window.log.info(
log.info(
'storageService.applyUnknownFields: Applying unknown fields for',
conversation.get('id')
);
@ -126,9 +127,7 @@ export async function toContactRecord(
try {
maybeUuid = uuid ? new UUID(uuid) : undefined;
} catch (error) {
window.log.warn(
`Invalid uuid in contact record: ${Errors.toLogFormat(error)}`
);
log.warn(`Invalid uuid in contact record: ${Errors.toLogFormat(error)}`);
}
const identityKey = maybeUuid
@ -296,7 +295,7 @@ export async function toAccountRecord(
pinnedConversationClass !== undefined
);
window.log.info(
log.info(
'storageService.toAccountRecord: pinnedConversations',
pinnedConversations.length
);
@ -403,7 +402,7 @@ function doRecordsConflict(
if (localValue instanceof Uint8Array) {
const areEqual = Bytes.areEqual(localValue, remoteValue);
if (!areEqual) {
window.log.info(
log.info(
'storageService.doRecordsConflict: Conflict found for ArrayBuffer',
key,
idForLogging
@ -422,7 +421,7 @@ function doRecordsConflict(
Long.fromValue(remoteValue)
);
if (!areEqual) {
window.log.info(
log.info(
'storageService.doRecordsConflict: Conflict found for Long',
key,
idForLogging
@ -434,7 +433,7 @@ function doRecordsConflict(
if (key === 'pinnedConversations') {
const areEqual = arePinnedConversationsEqual(localValue, remoteValue);
if (!areEqual) {
window.log.info(
log.info(
'storageService.doRecordsConflict: Conflict found for pinnedConversations',
idForLogging
);
@ -462,7 +461,7 @@ function doRecordsConflict(
const areEqual = isEqual(localValue, remoteValue);
if (!areEqual) {
window.log.info(
log.info(
'storageService.doRecordsConflict: Conflict found for',
key,
idForLogging
@ -532,14 +531,14 @@ export async function mergeGroupV1Record(
const fields = deriveGroupFields(new FIXMEU8(masterKeyBuffer));
const derivedGroupV2Id = Bytes.toBase64(fields.id);
window.log.info(
log.info(
'storageService.mergeGroupV1Record: failed to find group by v1 id ' +
`attempting lookup by v2 groupv2(${derivedGroupV2Id})`
);
conversation = window.ConversationController.get(derivedGroupV2Id);
}
if (conversation) {
window.log.info(
log.info(
'storageService.mergeGroupV1Record: found existing group',
conversation.idForLogging()
);
@ -552,7 +551,7 @@ export async function mergeGroupV1Record(
groupId,
'group'
);
window.log.info(
log.info(
'storageService.mergeGroupV1Record: created a new group locally',
conversation.idForLogging()
);
@ -587,7 +586,7 @@ export async function mergeGroupV1Record(
// We cannot preserve unknown fields if local group is V2 and the remote is
// still V1, because the storageItem that we'll put into manifest will have
// a different record type.
window.log.info(
log.info(
'storageService.mergeGroupV1Record marking v1' +
' group for an update to v2',
conversation.idForLogging()
@ -660,10 +659,7 @@ export async function mergeGroupV2Record(
const masterKeyBuffer = groupV2Record.masterKey;
const conversation = await getGroupV2Conversation(masterKeyBuffer);
window.log.info(
'storageService.mergeGroupV2Record:',
conversation.idForLogging()
);
log.info('storageService.mergeGroupV2Record:', conversation.idForLogging());
conversation.set({
isArchived: Boolean(groupV2Record.archived),
@ -763,10 +759,7 @@ export async function mergeContactRecord(
'private'
);
window.log.info(
'storageService.mergeContactRecord:',
conversation.idForLogging()
);
log.info('storageService.mergeContactRecord:', conversation.idForLogging());
if (contactRecord.profileKey) {
await conversation.setProfileKey(Bytes.toBase64(contactRecord.profileKey), {
@ -924,7 +917,7 @@ export async function mergeAccountRecord(
.filter(id => !modelPinnedConversationIds.includes(id));
if (missingStoragePinnedConversationIds.length !== 0) {
window.log.info(
log.info(
'mergeAccountRecord: pinnedConversationIds in storage does not match pinned Conversation models'
);
}
@ -940,11 +933,11 @@ export async function mergeAccountRecord(
)
);
window.log.info(
log.info(
'storageService.mergeAccountRecord: Local pinned',
locallyPinnedConversations.length
);
window.log.info(
log.info(
'storageService.mergeAccountRecord: Remote pinned',
pinnedConversations.length
);
@ -965,13 +958,13 @@ export async function mergeAccountRecord(
conversationId = groupId;
} else {
window.log.error(
log.error(
'storageService.mergeAccountRecord: Invalid identifier received'
);
}
if (!conversationId) {
window.log.error(
log.error(
'storageService.mergeAccountRecord: missing conversation id.'
);
return undefined;
@ -996,12 +989,12 @@ export async function mergeAccountRecord(
({ id }) => !remotelyPinnedConversationIds.includes(id)
);
window.log.info(
log.info(
'storageService.mergeAccountRecord: unpinning',
conversationsToUnpin.length
);
window.log.info(
log.info(
'storageService.mergeAccountRecord: pinning',
remotelyPinnedConversations.length
);