Replace console.warn with logger.warn
Related https://github.com/vector-im/element-web/issues/18425
This commit is contained in:
parent
5e73a212f4
commit
5290afcc4c
71 changed files with 195 additions and 127 deletions
|
@ -28,6 +28,8 @@ import GroupStore from "./GroupStore";
|
|||
import dis from "../dispatcher/dispatcher";
|
||||
import { isNullOrUndefined } from "matrix-js-sdk/src/utils";
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
interface IState {
|
||||
// nothing of value - we use account data
|
||||
}
|
||||
|
@ -134,7 +136,7 @@ export class CommunityPrototypeStore extends AsyncStoreWithClient<IState> {
|
|||
// we use global account data because per-room account data on invites is unreliable
|
||||
await this.matrixClient.setAccountData("im.vector.group_info." + room.roomId, profile);
|
||||
} catch (e) {
|
||||
console.warn("Non-fatal error getting group information for invite:", e);
|
||||
logger.warn("Non-fatal error getting group information for invite:", e);
|
||||
}
|
||||
}
|
||||
} else if (payload.action === "MatrixActions.accountData") {
|
||||
|
|
|
@ -98,7 +98,7 @@ class FlairStore extends EventEmitter {
|
|||
}).catch((err) => {
|
||||
// Indicate whether the homeserver supports groups
|
||||
if (err.errcode === 'M_UNRECOGNIZED') {
|
||||
console.warn('Cannot display flair, server does not support groups');
|
||||
logger.warn('Cannot display flair, server does not support groups');
|
||||
groupSupport = false;
|
||||
// Return silently to avoid spamming for non-supporting servers
|
||||
return;
|
||||
|
|
|
@ -23,6 +23,8 @@ import { ActionPayload } from "../dispatcher/payloads";
|
|||
import { Action } from '../dispatcher/actions';
|
||||
import { SettingLevel } from "../settings/SettingLevel";
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
interface RightPanelStoreState {
|
||||
// Whether or not to show the right panel at all. We split out rooms and groups
|
||||
// because they're different flows for the user to follow.
|
||||
|
@ -180,7 +182,7 @@ export default class RightPanelStore extends Store<ActionPayload> {
|
|||
}
|
||||
}
|
||||
if (!RightPanelPhases[targetPhase]) {
|
||||
console.warn(`Tried to switch right panel to unknown phase: ${targetPhase}`);
|
||||
logger.warn(`Tried to switch right panel to unknown phase: ${targetPhase}`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -867,7 +867,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
|||
try {
|
||||
await this.matrixClient.setRoomAccountData(space.roomId, EventType.SpaceOrder, { order });
|
||||
} catch (e) {
|
||||
console.warn("Failed to set root space order", e);
|
||||
logger.warn("Failed to set root space order", e);
|
||||
if (this.spaceOrderLocalEchoMap.get(space.roomId) === order) {
|
||||
this.spaceOrderLocalEchoMap.delete(space.roomId);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ export default class WidgetStore extends AsyncStoreWithClient<IState> {
|
|||
// Sanity check for https://github.com/vector-im/element-web/issues/15705
|
||||
const existingApp = this.widgetMap.get(widgetUid(app));
|
||||
if (existingApp) {
|
||||
console.warn(
|
||||
logger.warn(
|
||||
`Possible widget ID conflict for ${app.id} - wants to store in room ${app.roomId} ` +
|
||||
`but is currently stored as ${existingApp.roomId} - letting the want win`,
|
||||
);
|
||||
|
|
|
@ -20,6 +20,8 @@ import { AsyncStoreWithClient } from "../AsyncStoreWithClient";
|
|||
import defaultDispatcher from "../../dispatcher/dispatcher";
|
||||
import { ActionPayload } from "../../dispatcher/payloads";
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
interface IState {}
|
||||
|
||||
export default class RoomListLayoutStore extends AsyncStoreWithClient<IState> {
|
||||
|
@ -53,7 +55,7 @@ export default class RoomListLayoutStore extends AsyncStoreWithClient<IState> {
|
|||
|
||||
// Note: this primarily exists for debugging, and isn't really intended to be used by anything.
|
||||
public async resetLayouts() {
|
||||
console.warn("Resetting layouts for room list");
|
||||
logger.warn("Resetting layouts for room list");
|
||||
for (const layout of this.layoutMap.values()) {
|
||||
layout.reset();
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
|
|||
} else if (activeRoomId) {
|
||||
const activeRoom = this.matrixClient.getRoom(activeRoomId);
|
||||
if (!activeRoom) {
|
||||
console.warn(`${activeRoomId} is current in RVS but missing from client - clearing sticky room`);
|
||||
logger.warn(`${activeRoomId} is current in RVS but missing from client - clearing sticky room`);
|
||||
this.algorithm.setStickyRoom(null);
|
||||
} else if (activeRoom !== this.algorithm.stickyRoom) {
|
||||
this.algorithm.setStickyRoom(activeRoom);
|
||||
|
@ -226,7 +226,7 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
|
|||
if (readReceiptChangeIsFor(payload.event, this.matrixClient)) {
|
||||
const room = payload.room;
|
||||
if (!room) {
|
||||
console.warn(`Own read receipt was in unknown room ${room.roomId}`);
|
||||
logger.warn(`Own read receipt was in unknown room ${room.roomId}`);
|
||||
return;
|
||||
}
|
||||
await this.handleRoomUpdate(room, RoomUpdateCause.ReadReceipt);
|
||||
|
@ -258,8 +258,8 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
|
|||
this.updateFn.trigger();
|
||||
};
|
||||
if (!room) {
|
||||
console.warn(`Live timeline event ${eventPayload.event.getId()} received without associated room`);
|
||||
console.warn(`Queuing failed room update for retry as a result.`);
|
||||
logger.warn(`Live timeline event ${eventPayload.event.getId()} received without associated room`);
|
||||
logger.warn(`Queuing failed room update for retry as a result.`);
|
||||
setTimeout(async () => {
|
||||
const updatedRoom = this.matrixClient.getRoom(roomId);
|
||||
await tryUpdate(updatedRoom);
|
||||
|
@ -276,7 +276,7 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
|
|||
}
|
||||
const room = this.matrixClient.getRoom(roomId);
|
||||
if (!room) {
|
||||
console.warn(`Event ${eventPayload.event.getId()} was decrypted in an unknown room ${roomId}`);
|
||||
logger.warn(`Event ${eventPayload.event.getId()} was decrypted in an unknown room ${roomId}`);
|
||||
return;
|
||||
}
|
||||
await this.handleRoomUpdate(room, RoomUpdateCause.Timeline);
|
||||
|
@ -289,7 +289,7 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
|
|||
for (const roomId of roomIds) {
|
||||
const room = this.matrixClient.getRoom(roomId);
|
||||
if (!room) {
|
||||
console.warn(`${roomId} was found in DMs but the room is not in the store`);
|
||||
logger.warn(`${roomId} was found in DMs but the room is not in the store`);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -550,7 +550,7 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
|
|||
* be used if the calling code will manually trigger the update.
|
||||
*/
|
||||
public regenerateAllLists({ trigger = true }) {
|
||||
console.warn("Regenerating all room lists");
|
||||
logger.warn("Regenerating all room lists");
|
||||
|
||||
const rooms = this.getPlausibleRooms();
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ import GroupFilterOrderStore from "../GroupFilterOrderStore";
|
|||
import { CommunityFilterCondition } from "./filters/CommunityFilterCondition";
|
||||
import { arrayDiff, arrayHasDiff } from "../../utils/arrays";
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
/**
|
||||
* Watches for changes in groups to manage filters on the provided RoomListStore
|
||||
*/
|
||||
|
@ -37,7 +39,7 @@ export class TagWatcher {
|
|||
// Selected tags changed, do some filtering
|
||||
|
||||
if (!this.store.matrixClient) {
|
||||
console.warn("Tag update without an associated matrix client - ignoring");
|
||||
logger.warn("Tag update without an associated matrix client - ignoring");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -47,7 +49,7 @@ export class TagWatcher {
|
|||
for (const tag of filterableTags) {
|
||||
const group = this.store.matrixClient.getGroup(tag);
|
||||
if (!group) {
|
||||
console.warn(`Group selected with no group object available: ${tag}`);
|
||||
logger.warn(`Group selected with no group object available: ${tag}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ import { getListAlgorithmInstance } from "./list-ordering";
|
|||
import { VisibilityProvider } from "../filters/VisibilityProvider";
|
||||
import SpaceStore from "../../SpaceStore";
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
/**
|
||||
* Fired when the Algorithm has determined a list has been updated.
|
||||
*/
|
||||
|
@ -126,7 +128,7 @@ export class Algorithm extends EventEmitter {
|
|||
try {
|
||||
this.updateStickyRoom(val);
|
||||
} catch (e) {
|
||||
console.warn("Failed to update sticky room", e);
|
||||
logger.warn("Failed to update sticky room", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,7 +243,7 @@ export class Algorithm extends EventEmitter {
|
|||
// to force the position to zero (top) to ensure we can properly handle it.
|
||||
const wasSticky = this._lastStickyRoom.room ? this._lastStickyRoom.room.roomId === val.roomId : false;
|
||||
if (this._lastStickyRoom.tag && tag !== this._lastStickyRoom.tag && wasSticky && position < 0) {
|
||||
console.warn(`Sticky room ${val.roomId} changed tags during sticky room handling`);
|
||||
logger.warn(`Sticky room ${val.roomId} changed tags during sticky room handling`);
|
||||
position = 0;
|
||||
}
|
||||
|
||||
|
@ -278,13 +280,13 @@ export class Algorithm extends EventEmitter {
|
|||
if (this._stickyRoom.room !== val) {
|
||||
// Check the room IDs just in case
|
||||
if (this._stickyRoom.room.roomId === val.roomId) {
|
||||
console.warn("Sticky room changed references");
|
||||
logger.warn("Sticky room changed references");
|
||||
} else {
|
||||
throw new Error("Sticky room changed while the sticky room was changing");
|
||||
}
|
||||
}
|
||||
|
||||
console.warn(`Sticky room changed tag & position from ${tag} / ${position} `
|
||||
logger.warn(`Sticky room changed tag & position from ${tag} / ${position} `
|
||||
+ `to ${this._stickyRoom.tag} / ${this._stickyRoom.position}`);
|
||||
|
||||
tag = this._stickyRoom.tag;
|
||||
|
@ -322,7 +324,7 @@ export class Algorithm extends EventEmitter {
|
|||
return;
|
||||
}
|
||||
|
||||
console.warn("Recalculating filtered room list");
|
||||
logger.warn("Recalculating filtered room list");
|
||||
const filters = Array.from(this.allowedByFilter.keys());
|
||||
const newMap: ITagMap = {};
|
||||
for (const tagId of Object.keys(this.cachedRooms)) {
|
||||
|
@ -491,7 +493,7 @@ export class Algorithm extends EventEmitter {
|
|||
// We only log this if we're expecting to be publishing updates, which means that
|
||||
// this could be an unexpected invocation. If we're inhibited, then this is probably
|
||||
// an intentional invocation.
|
||||
console.warn("Resetting known rooms, initiating regeneration");
|
||||
logger.warn("Resetting known rooms, initiating regeneration");
|
||||
}
|
||||
|
||||
// Before we go any further we need to clear (but remember) the sticky room to
|
||||
|
@ -657,18 +659,18 @@ export class Algorithm extends EventEmitter {
|
|||
// pass the cause through as NewRoom, we'll fail to lie to the algorithm and thus
|
||||
// lose the room.
|
||||
if (hasTags && !isForLastSticky) {
|
||||
console.warn(`${room.roomId} is reportedly new but is already known - assuming TagChange instead`);
|
||||
logger.warn(`${room.roomId} is reportedly new but is already known - assuming TagChange instead`);
|
||||
cause = RoomUpdateCause.PossibleTagChange;
|
||||
}
|
||||
|
||||
// Check to see if the room is known first
|
||||
let knownRoomRef = this.rooms.includes(room);
|
||||
if (hasTags && !knownRoomRef) {
|
||||
console.warn(`${room.roomId} might be a reference change - attempting to update reference`);
|
||||
logger.warn(`${room.roomId} might be a reference change - attempting to update reference`);
|
||||
this.rooms = this.rooms.map(r => r.roomId === room.roomId ? room : r);
|
||||
knownRoomRef = this.rooms.includes(room);
|
||||
if (!knownRoomRef) {
|
||||
console.warn(`${room.roomId} is still not referenced. It may be sticky.`);
|
||||
logger.warn(`${room.roomId} is still not referenced. It may be sticky.`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -766,7 +768,7 @@ export class Algorithm extends EventEmitter {
|
|||
|
||||
const tags = this.roomIdsToTags[room.roomId];
|
||||
if (!tags) {
|
||||
console.warn(`No tags known for "${room.name}" (${room.roomId})`);
|
||||
logger.warn(`No tags known for "${room.name}" (${room.roomId})`);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ import { OrderingAlgorithm } from "./OrderingAlgorithm";
|
|||
import { NotificationColor } from "../../../notifications/NotificationColor";
|
||||
import { RoomNotificationStateStore } from "../../../notifications/RoomNotificationStateStore";
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
interface ICategorizedRoomMap {
|
||||
// @ts-ignore - TS wants this to be a string, but we know better
|
||||
[category: NotificationColor]: Room[];
|
||||
|
@ -130,7 +132,7 @@ export class ImportanceAlgorithm extends OrderingAlgorithm {
|
|||
} else if (cause === RoomUpdateCause.RoomRemoved) {
|
||||
const roomIdx = this.getRoomIndex(room);
|
||||
if (roomIdx === -1) {
|
||||
console.warn(`Tried to remove unknown room from ${this.tagId}: ${room.roomId}`);
|
||||
logger.warn(`Tried to remove unknown room from ${this.tagId}: ${room.roomId}`);
|
||||
return false; // no change
|
||||
}
|
||||
const oldCategory = this.getCategoryFromIndices(roomIdx, this.indices);
|
||||
|
@ -263,7 +265,7 @@ export class ImportanceAlgorithm extends OrderingAlgorithm {
|
|||
|
||||
if (indices[lastCat] > indices[thisCat]) {
|
||||
// "should never happen" disclaimer goes here
|
||||
console.warn(
|
||||
logger.warn(
|
||||
`!! Room list index corruption: ${lastCat} (i:${indices[lastCat]}) is greater ` +
|
||||
`than ${thisCat} (i:${indices[thisCat]}) - category indices are likely desynced from reality`);
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ import { OrderingAlgorithm } from "./OrderingAlgorithm";
|
|||
import { RoomUpdateCause, TagID } from "../../models";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
/**
|
||||
* Uses the natural tag sorting algorithm order to determine tag ordering. No
|
||||
* additional behavioural changes are present.
|
||||
|
@ -47,7 +49,7 @@ export class NaturalAlgorithm extends OrderingAlgorithm {
|
|||
if (idx >= 0) {
|
||||
this.cachedOrderedRooms.splice(idx, 1);
|
||||
} else {
|
||||
console.warn(`Tried to remove unknown room from ${this.tagId}: ${room.roomId}`);
|
||||
logger.warn(`Tried to remove unknown room from ${this.tagId}: ${room.roomId}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ import { Room } from "matrix-js-sdk/src/models/room";
|
|||
import { RoomUpdateCause, TagID } from "../../models";
|
||||
import { SortAlgorithm } from "../models";
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
/**
|
||||
* Represents a list ordering algorithm. Subclasses should populate the
|
||||
* `cachedOrderedRooms` field.
|
||||
|
@ -71,7 +73,7 @@ export abstract class OrderingAlgorithm {
|
|||
protected getRoomIndex(room: Room): number {
|
||||
let roomIdx = this.cachedOrderedRooms.indexOf(room);
|
||||
if (roomIdx === -1) { // can only happen if the js-sdk's store goes sideways.
|
||||
console.warn(`Degrading performance to find missing room in "${this.tagId}": ${room.roomId}`);
|
||||
logger.warn(`Degrading performance to find missing room in "${this.tagId}": ${room.roomId}`);
|
||||
roomIdx = this.cachedOrderedRooms.findIndex(r => r.roomId === room.roomId);
|
||||
}
|
||||
return roomIdx;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue