Replace console.warn with logger.warn

Related https://github.com/vector-im/element-web/issues/18425
This commit is contained in:
Dariusz Niemczyk 2021-10-15 16:31:29 +02:00 committed by Dariusz Niemczyk
parent 5e73a212f4
commit 5290afcc4c
71 changed files with 195 additions and 127 deletions

View file

@ -20,6 +20,8 @@ import { MatrixClient } from "matrix-js-sdk/src/client";
import { MatrixClientPeg } from '../MatrixClientPeg';
import { logger } from "matrix-js-sdk/src/logger";
/**
* Class that takes a Matrix Client and flips the m.direct map
* so the operation of mapping a room ID to which user it's a DM
@ -196,7 +198,7 @@ export default class DMRoomMap {
// to avoid multiple devices fighting to correct
// the account data, only try to send the corrected
// version once.
console.warn(`Invalid m.direct account data detected ` +
logger.warn(`Invalid m.direct account data detected ` +
`(self-chats that shouldn't be), patching it up.`);
if (neededPatching && !this.hasSentOutPatchDirectAccountDataPatch) {
this.hasSentOutPatchDirectAccountDataPatch = true;

View file

@ -41,7 +41,7 @@ function safariVersionCheck(ua: string): boolean {
} catch (err) {
logger.error("Error in Safari COLR version check", err);
}
console.warn("Couldn't determine Safari version to check COLR font support, assuming no.");
logger.warn("Couldn't determine Safari version to check COLR font support, assuming no.");
return false;
}

View file

@ -22,6 +22,8 @@ import { IMediaEventContent } from "../customisations/models/IMediaEventContent"
import { IDestroyable } from "./IDestroyable";
import { EventType, MsgType } from "matrix-js-sdk/src/@types/event";
import { logger } from "matrix-js-sdk/src/logger";
// TODO: We should consider caching the blobs. https://github.com/vector-im/element-web/issues/17192
export class MediaEventHelper implements IDestroyable {
@ -91,7 +93,7 @@ export class MediaEventHelper implements IDestroyable {
return decryptFile(content.info.thumbnail_file, content.info.thumbnail_info);
} else {
// "Should never happen"
console.warn("Media claims to have thumbnail and is encrypted, but no thumbnail_file found");
logger.warn("Media claims to have thumbnail and is encrypted, but no thumbnail_file found");
return Promise.resolve(null);
}
}

View file

@ -22,6 +22,8 @@ import { IContent } from "matrix-js-sdk/src/models/event";
import { bodyToHtml, checkBlockNode, IOptsReturnString } from "../HtmlUtils";
import { logger } from "matrix-js-sdk/src/logger";
const decodeEntities = (function() {
let textarea = null;
return function(str: string): string {
@ -218,7 +220,7 @@ function renderDifferenceInDOM(originalRootNode: Node, diff: IDiff, diffMathPatc
}
default:
// Should not happen (modifyComment, ???)
console.warn("MessageDiffUtils::editBodyDiffToHtml: diff action not supported atm", diff);
logger.warn("MessageDiffUtils::editBodyDiffToHtml: diff action not supported atm", diff);
}
}

View file

@ -219,7 +219,7 @@ export default class MultiInviter {
case "M_PROFILE_NOT_FOUND":
if (!ignoreProfile) {
// Invite without the profile check
console.warn(`User ${address} does not have a profile - inviting anyways automatically`);
logger.warn(`User ${address} does not have a profile - inviting anyways automatically`);
this.doInvite(address, true).then(resolve, reject);
return;
}

View file

@ -138,7 +138,7 @@ export async function upgradeRoom(
}
} catch (e) {
// These errors are not critical to the room upgrade itself
console.warn("Failed to update parent spaces during room upgrade", e);
logger.warn("Failed to update parent spaces during room upgrade", e);
}
}

View file

@ -55,30 +55,30 @@ export default class WidgetUtils {
*/
static canUserModifyWidgets(roomId: string): boolean {
if (!roomId) {
console.warn('No room ID specified');
logger.warn('No room ID specified');
return false;
}
const client = MatrixClientPeg.get();
if (!client) {
console.warn('User must be be logged in');
logger.warn('User must be be logged in');
return false;
}
const room = client.getRoom(roomId);
if (!room) {
console.warn(`Room ID ${roomId} is not recognised`);
logger.warn(`Room ID ${roomId} is not recognised`);
return false;
}
const me = client.credentials.userId;
if (!me) {
console.warn('Failed to get user ID');
logger.warn('Failed to get user ID');
return false;
}
if (room.getMyMembership() !== "join") {
console.warn(`User ${me} is not in room ${roomId}`);
logger.warn(`User ${me} is not in room ${roomId}`);
return false;
}

View file

@ -28,6 +28,8 @@ import ElementPermalinkConstructor from "./ElementPermalinkConstructor";
import matrixLinkify from "../../linkify-matrix";
import SdkConfig from "../../SdkConfig";
import { logger } from "matrix-js-sdk/src/logger";
// The maximum number of servers to pick when working out which servers
// to add to permalinks. The servers are appended as ?via=example.org
const MAX_SERVER_CANDIDATES = 3;
@ -109,7 +111,7 @@ export class RoomPermalinkCreator {
// currentState, at least potentially at the early stages of joining a room.
// To avoid breaking everything, we'll just warn rather than throw as well as
// not bother updating the various aspects of the share link.
console.warn("Tried to load a permalink creator with no room state");
logger.warn("Tried to load a permalink creator with no room state");
return;
}
this.updateAllowedServers();