Replace console.error with logger.error
Related https://github.com/vector-im/element-web/issues/18425
This commit is contained in:
parent
9c594a8a96
commit
5e73a212f4
124 changed files with 417 additions and 250 deletions
|
@ -20,6 +20,8 @@ import { _t, _td, newTranslatableError } from "../languageHandler";
|
|||
import { makeType } from "./TypeUtils";
|
||||
import SdkConfig from '../SdkConfig';
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
const LIVELINESS_DISCOVERY_ERRORS: string[] = [
|
||||
AutoDiscovery.ERROR_INVALID_HOMESERVER,
|
||||
AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER,
|
||||
|
@ -198,7 +200,7 @@ export default class AutoDiscoveryUtils {
|
|||
if (!discoveryResult || !discoveryResult["m.homeserver"]) {
|
||||
// This shouldn't happen without major misconfiguration, so we'll log a bit of information
|
||||
// in the log so we can find this bit of codee but otherwise tell teh user "it broke".
|
||||
console.error("Ended up in a state of not knowing which homeserver to connect to.");
|
||||
logger.error("Ended up in a state of not knowing which homeserver to connect to.");
|
||||
throw newTranslatableError(_td("Unexpected error resolving homeserver configuration"));
|
||||
}
|
||||
|
||||
|
@ -218,7 +220,7 @@ export default class AutoDiscoveryUtils {
|
|||
if (isResult && isResult.state === AutoDiscovery.SUCCESS) {
|
||||
preferredIdentityUrl = isResult["base_url"];
|
||||
} else if (isResult && isResult.state !== AutoDiscovery.PROMPT) {
|
||||
console.error("Error determining preferred identity server URL:", isResult);
|
||||
logger.error("Error determining preferred identity server URL:", isResult);
|
||||
if (isResult.state === AutoDiscovery.FAIL_ERROR) {
|
||||
if (AutoDiscovery.ALL_ERRORS.indexOf(isResult.error) !== -1) {
|
||||
throw newTranslatableError(isResult.error);
|
||||
|
@ -234,7 +236,7 @@ export default class AutoDiscoveryUtils {
|
|||
}
|
||||
|
||||
if (hsResult.state !== AutoDiscovery.SUCCESS) {
|
||||
console.error("Error processing homeserver config:", hsResult);
|
||||
logger.error("Error processing homeserver config:", hsResult);
|
||||
if (!syntaxOnly || !AutoDiscoveryUtils.isLivelinessError(hsResult.error)) {
|
||||
if (AutoDiscovery.ALL_ERRORS.indexOf(hsResult.error) !== -1) {
|
||||
throw newTranslatableError(hsResult.error);
|
||||
|
@ -251,7 +253,7 @@ export default class AutoDiscoveryUtils {
|
|||
|
||||
// It should have been set by now, so check it
|
||||
if (!preferredHomeserverName) {
|
||||
console.error("Failed to parse homeserver name from homeserver URL");
|
||||
logger.error("Failed to parse homeserver name from homeserver URL");
|
||||
throw newTranslatableError(_td("Unexpected error resolving homeserver configuration"));
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ function safariVersionCheck(ua: string): boolean {
|
|||
return colrFontSupported;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Error in Safari COLR version check", err);
|
||||
logger.error("Error in Safari COLR version check", err);
|
||||
}
|
||||
console.warn("Couldn't determine Safari version to check COLR font support, assuming no.");
|
||||
return false;
|
||||
|
@ -96,7 +96,7 @@ async function isColrFontSupported(): Promise<boolean> {
|
|||
logger.log("Canvas check revealed COLR is supported? " + colrFontSupported);
|
||||
return colrFontSupported;
|
||||
} catch (e) {
|
||||
console.error("Couldn't load COLR font", e);
|
||||
logger.error("Couldn't load COLR font", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ import { SERVICE_TYPES } from 'matrix-js-sdk/src/service-types';
|
|||
import SdkConfig from '../SdkConfig';
|
||||
import { MatrixClientPeg } from '../MatrixClientPeg';
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
export function getDefaultIdentityServerUrl(): string {
|
||||
return SdkConfig.get()['validated_server_config']['isUrl'];
|
||||
}
|
||||
|
@ -36,7 +38,7 @@ export async function doesIdentityServerHaveTerms(fullUrl: string): Promise<bool
|
|||
try {
|
||||
terms = await MatrixClientPeg.get().getTerms(SERVICE_TYPES.IS, fullUrl);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
logger.error(e);
|
||||
if (e.cors === "rejected" || e.httpStatus === 404) {
|
||||
terms = null;
|
||||
} else {
|
||||
|
|
|
@ -188,7 +188,7 @@ export default class MultiInviter {
|
|||
return;
|
||||
}
|
||||
|
||||
console.error(err);
|
||||
logger.error(err);
|
||||
|
||||
let errorText;
|
||||
let fatal = false;
|
||||
|
|
|
@ -24,6 +24,8 @@ import ErrorDialog from "../components/views/dialogs/ErrorDialog";
|
|||
import SpaceStore from "../stores/SpaceStore";
|
||||
import Spinner from "../components/views/elements/Spinner";
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
interface IProgress {
|
||||
roomUpgraded: boolean;
|
||||
roomSynced?: boolean;
|
||||
|
@ -78,7 +80,7 @@ export async function upgradeRoom(
|
|||
({ replacement_room: newRoomId } = await cli.upgradeRoom(room.roomId, targetVersion));
|
||||
} catch (e) {
|
||||
if (!handleError) throw e;
|
||||
console.error(e);
|
||||
logger.error(e);
|
||||
|
||||
Modal.createTrackedDialog("Room Upgrade Error", "", ErrorDialog, {
|
||||
title: _t('Error upgrading room'),
|
||||
|
|
|
@ -39,7 +39,7 @@ function log(msg: string) {
|
|||
}
|
||||
|
||||
function error(msg: string, ...args: string[]) {
|
||||
console.error(`StorageManager: ${msg}`, ...args);
|
||||
logger.error(`StorageManager: ${msg}`, ...args);
|
||||
}
|
||||
|
||||
function track(action: string) {
|
||||
|
|
|
@ -17,6 +17,8 @@ limitations under the License.
|
|||
import { IDestroyable } from "./IDestroyable";
|
||||
import { arrayFastClone } from "./arrays";
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
export type WhenFn<T> = (w: Whenable<T>) => void;
|
||||
|
||||
/**
|
||||
|
@ -73,7 +75,7 @@ export abstract class Whenable<T> implements IDestroyable {
|
|||
try {
|
||||
listener.fn(this);
|
||||
} catch (e) {
|
||||
console.error(`Error calling whenable listener for ${condition}:`, e);
|
||||
logger.error(`Error calling whenable listener for ${condition}:`, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ import { objectClone } from "./objects";
|
|||
import { _t } from "../languageHandler";
|
||||
import { IApp } from "../stores/WidgetStore";
|
||||
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
// How long we wait for the state event echo to come back from the server
|
||||
// before waitFor[Room/User]Widget rejects its promise
|
||||
const WIDGET_WAIT_TIME = 20000;
|
||||
|
@ -92,7 +94,7 @@ export default class WidgetUtils {
|
|||
*/
|
||||
static isScalarUrl(testUrlString: string): boolean {
|
||||
if (!testUrlString) {
|
||||
console.error('Scalar URL check failed. No URL specified');
|
||||
logger.error('Scalar URL check failed. No URL specified');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -246,7 +248,7 @@ export default class WidgetUtils {
|
|||
try {
|
||||
delete userWidgets[widgetId];
|
||||
} catch (e) {
|
||||
console.error(`$widgetId is non-configurable`);
|
||||
logger.error(`$widgetId is non-configurable`);
|
||||
}
|
||||
|
||||
const addingWidget = Boolean(widgetUrl);
|
||||
|
|
|
@ -379,7 +379,7 @@ export default class HTMLExporter extends Exporter {
|
|||
} else eventTile = await this.getEventTileMarkup(mxEv, joined);
|
||||
} catch (e) {
|
||||
// TODO: Handle callEvent errors
|
||||
console.error(e);
|
||||
logger.error(e);
|
||||
eventTile = await this.getEventTileMarkup(
|
||||
this.createModifiedEvent(textForEvent(mxEv), mxEv, false),
|
||||
joined,
|
||||
|
|
|
@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copy plaintext to user's clipboard
|
||||
* It will overwrite user's selection range
|
||||
|
@ -21,6 +20,8 @@ limitations under the License.
|
|||
* Tries to use new async clipboard API if available
|
||||
* @param text the plaintext to put in the user's clipboard
|
||||
*/
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
export async function copyPlaintext(text: string): Promise<boolean> {
|
||||
try {
|
||||
if (navigator && navigator.clipboard && navigator.clipboard.writeText) {
|
||||
|
@ -49,7 +50,7 @@ export async function copyPlaintext(text: string): Promise<boolean> {
|
|||
return successful;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("copyPlaintext failed", e);
|
||||
logger.error("copyPlaintext failed", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue