mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Replace console.log with logger.log
Related https://github.com/vector-im/element-web/issues/18425
This commit is contained in:
parent
db01bfc0fd
commit
dc9f77a509
@ -40,7 +40,7 @@ import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
let lastLocationHashSet: string = null;
|
||||
|
||||
console.log(`Application is running in ${process.env.NODE_ENV} mode`);
|
||||
logger.log(`Application is running in ${process.env.NODE_ENV} mode`);
|
||||
|
||||
// Parse the given window.location and return parameters that can be used when calling
|
||||
// MatrixChat.showScreen(screen, params)
|
||||
@ -57,7 +57,7 @@ function getScreenFromLocation(location: Location) {
|
||||
function routeUrl(location: Location) {
|
||||
if (!window.matrixChat) return;
|
||||
|
||||
console.log("Routing URL ", location.href);
|
||||
logger.log("Routing URL ", location.href);
|
||||
const s = getScreenFromLocation(location);
|
||||
(window.matrixChat as MatrixChatType).showScreen(s.screen, s.params);
|
||||
}
|
||||
@ -73,7 +73,7 @@ function onHashChange(ev: HashChangeEvent) {
|
||||
// This will be called whenever the SDK changes screens,
|
||||
// so a web page can update the URL bar appropriately.
|
||||
function onNewScreen(screen: string, replaceLast = false) {
|
||||
console.log("newscreen " + screen);
|
||||
logger.log("newscreen " + screen);
|
||||
const hash = '#/' + screen;
|
||||
lastLocationHashSet = hash;
|
||||
|
||||
@ -135,7 +135,7 @@ function onTokenLoginCompleted() {
|
||||
|
||||
url.searchParams.delete("loginToken");
|
||||
|
||||
console.log(`Redirecting to ${url.href} to drop loginToken from queryparams`);
|
||||
logger.log(`Redirecting to ${url.href} to drop loginToken from queryparams`);
|
||||
window.history.replaceState(null, "", url.href);
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ export async function loadApp(fragParams: {}) {
|
||||
const params = parseQs(window.location);
|
||||
|
||||
const urlWithoutQuery = window.location.protocol + '//' + window.location.host + window.location.pathname;
|
||||
console.log("Vector starting at " + urlWithoutQuery);
|
||||
logger.log("Vector starting at " + urlWithoutQuery);
|
||||
|
||||
(platform as VectorBasePlatform).startUpdater();
|
||||
|
||||
@ -160,7 +160,7 @@ export async function loadApp(fragParams: {}) {
|
||||
const isReturningFromSso = !!params.loginToken;
|
||||
const autoRedirect = config['sso_immediate_redirect'] === true;
|
||||
if (!hasPossibleToken && !isReturningFromSso && autoRedirect) {
|
||||
console.log("Bypassing app load to redirect to SSO");
|
||||
logger.log("Bypassing app load to redirect to SSO");
|
||||
const tempCli = createClient({
|
||||
baseUrl: config['validated_server_config'].hsUrl,
|
||||
idBaseUrl: config['validated_server_config'].isUrl,
|
||||
@ -190,7 +190,7 @@ export async function loadApp(fragParams: {}) {
|
||||
async function verifyServerConfig() {
|
||||
let validatedConfig;
|
||||
try {
|
||||
console.log("Verifying homeserver configuration");
|
||||
logger.log("Verifying homeserver configuration");
|
||||
|
||||
// Note: the query string may include is_url and hs_url - we only respect these in the
|
||||
// context of email validation. Because we don't respect them otherwise, we do not need
|
||||
@ -221,7 +221,7 @@ async function verifyServerConfig() {
|
||||
}
|
||||
|
||||
if (hsUrl) {
|
||||
console.log("Config uses a default_hs_url - constructing a default_server_config using this information");
|
||||
logger.log("Config uses a default_hs_url - constructing a default_server_config using this information");
|
||||
console.warn(
|
||||
"DEPRECATED CONFIG OPTION: In the future, default_hs_url will not be accepted. Please use " +
|
||||
"default_server_config instead.",
|
||||
@ -241,12 +241,12 @@ async function verifyServerConfig() {
|
||||
|
||||
let discoveryResult = null;
|
||||
if (wkConfig) {
|
||||
console.log("Config uses a default_server_config - validating object");
|
||||
logger.log("Config uses a default_server_config - validating object");
|
||||
discoveryResult = await AutoDiscovery.fromDiscoveryConfig(wkConfig);
|
||||
}
|
||||
|
||||
if (serverName) {
|
||||
console.log("Config uses a default_server_name - doing .well-known lookup");
|
||||
logger.log("Config uses a default_server_name - doing .well-known lookup");
|
||||
console.warn(
|
||||
"DEPRECATED CONFIG OPTION: In the future, default_server_name will not be accepted. Please " +
|
||||
"use default_server_config instead.",
|
||||
@ -261,7 +261,7 @@ async function verifyServerConfig() {
|
||||
logger.error(e);
|
||||
console.warn("A session was found - suppressing config error and using the session's homeserver");
|
||||
|
||||
console.log("Using pre-existing hsUrl and isUrl: ", { hsUrl, isUrl });
|
||||
logger.log("Using pre-existing hsUrl and isUrl: ", { hsUrl, isUrl });
|
||||
validatedConfig = await AutoDiscoveryUtils.validateServerConfigWithStaticUrls(hsUrl, isUrl, true);
|
||||
} else {
|
||||
// the user is not logged in, so scream
|
||||
@ -272,10 +272,10 @@ async function verifyServerConfig() {
|
||||
validatedConfig.isDefault = true;
|
||||
|
||||
// Just in case we ever have to debug this
|
||||
console.log("Using homeserver config:", validatedConfig);
|
||||
logger.log("Using homeserver config:", validatedConfig);
|
||||
|
||||
// Add the newly built config to the actual config for use by the app
|
||||
console.log("Updating SdkConfig with validated discovery information");
|
||||
logger.log("Updating SdkConfig with validated discovery information");
|
||||
SdkConfig.add({ "validated_server_config": validatedConfig });
|
||||
|
||||
return SdkConfig.get();
|
||||
|
@ -181,7 +181,7 @@ async function start() {
|
||||
if (window.localStorage) {
|
||||
window.localStorage.setItem('mx_accepts_unsupported_browser', String(true));
|
||||
}
|
||||
console.log("User accepts the compatibility risks.");
|
||||
logger.log("User accepts the compatibility risks.");
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
@ -41,13 +41,13 @@ export const rageshakePromise = initRageshake();
|
||||
|
||||
export function preparePlatform() {
|
||||
if (window.electron) {
|
||||
console.log("Using Electron platform");
|
||||
logger.log("Using Electron platform");
|
||||
PlatformPeg.set(new ElectronPlatform());
|
||||
} else if (window.matchMedia('(display-mode: standalone)').matches) {
|
||||
console.log("Using PWA platform");
|
||||
logger.log("Using PWA platform");
|
||||
PlatformPeg.set(new PWAPlatform());
|
||||
} else {
|
||||
console.log("Using Web platform");
|
||||
logger.log("Using Web platform");
|
||||
PlatformPeg.set(new WebPlatform());
|
||||
}
|
||||
}
|
||||
@ -84,9 +84,9 @@ export function loadOlm(): Promise<void> {
|
||||
return Olm.init({
|
||||
locateFile: () => olmWasmPath,
|
||||
}).then(() => {
|
||||
console.log("Using WebAssembly Olm");
|
||||
logger.log("Using WebAssembly Olm");
|
||||
}).catch((e) => {
|
||||
console.log("Failed to load Olm: trying legacy version", e);
|
||||
logger.log("Failed to load Olm: trying legacy version", e);
|
||||
return new Promise((resolve, reject) => {
|
||||
const s = document.createElement('script');
|
||||
s.src = 'olm_legacy.js'; // XXX: This should be cache-busted too
|
||||
@ -98,9 +98,9 @@ export function loadOlm(): Promise<void> {
|
||||
// not 'Olm' which is still the failed wasm version.
|
||||
return window.Olm.init();
|
||||
}).then(() => {
|
||||
console.log("Using legacy Olm");
|
||||
logger.log("Using legacy Olm");
|
||||
}).catch((e) => {
|
||||
console.log("Both WebAssembly and asm.js Olm failed!", e);
|
||||
logger.log("Both WebAssembly and asm.js Olm failed!", e);
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -127,7 +127,7 @@ export async function loadLanguage() {
|
||||
export async function loadSkin() {
|
||||
// Ensure the skin is the very first thing to load for the react-sdk. We don't even want to reference
|
||||
// the SDK until we have to in imports.
|
||||
console.log("Loading skin...");
|
||||
logger.log("Loading skin...");
|
||||
// load these async so that its code is not executed immediately and we can catch any exceptions
|
||||
const [sdk, skin] = await Promise.all([
|
||||
import(
|
||||
@ -142,7 +142,7 @@ export async function loadSkin() {
|
||||
"../component-index"),
|
||||
]);
|
||||
sdk.loadSkin(skin);
|
||||
console.log("Skin loaded!");
|
||||
logger.log("Skin loaded!");
|
||||
}
|
||||
|
||||
export async function loadTheme() {
|
||||
|
@ -117,7 +117,7 @@ let meetApi: any; // JitsiMeetExternalAPI
|
||||
if (jitsiAuth === JITSI_OPENIDTOKEN_JWT_AUTH) {
|
||||
// Request credentials, give callback to continue when received
|
||||
openIdToken = await widgetApi.requestOpenIDConnectToken();
|
||||
console.log("Got OpenID Connect token");
|
||||
logger.log("Got OpenID Connect token");
|
||||
}
|
||||
|
||||
// TODO: register widgetApi listeners for PTT controls (https://github.com/vector-im/element-web/issues/12795)
|
||||
|
@ -247,7 +247,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||
|
||||
// try to flush the rageshake logs to indexeddb before quit.
|
||||
electron.on('before-quit', function() {
|
||||
console.log('element-desktop closing');
|
||||
logger.log('element-desktop closing');
|
||||
rageshake.flush();
|
||||
});
|
||||
|
||||
@ -533,7 +533,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||
|
||||
setSpellCheckLanguages(preferredLangs: string[]) {
|
||||
this.ipcCall('setSpellCheckLanguages', preferredLangs).catch(error => {
|
||||
console.log("Failed to send setSpellCheckLanguages IPC to Electron");
|
||||
logger.log("Failed to send setSpellCheckLanguages IPC to Electron");
|
||||
logger.error(error);
|
||||
});
|
||||
}
|
||||
|
@ -36,12 +36,12 @@ export function initRageshake() {
|
||||
// we manually check persistence for rageshakes ourselves
|
||||
const prom = rageshake.init(/*setUpPersistence=*/false);
|
||||
prom.then(() => {
|
||||
console.log("Initialised rageshake.");
|
||||
console.log("To fix line numbers in Chrome: " +
|
||||
logger.log("Initialised rageshake.");
|
||||
logger.log("To fix line numbers in Chrome: " +
|
||||
"Meatball menu → Settings → Ignore list → Add /rageshake\\.js$");
|
||||
|
||||
window.addEventListener('beforeunload', (e) => {
|
||||
console.log('element-web closing');
|
||||
logger.log('element-web closing');
|
||||
// try to flush the logs to indexeddb
|
||||
rageshake.flush();
|
||||
});
|
||||
@ -72,9 +72,9 @@ window.mxSendRageshake = function(text: string, withLogs?: boolean) {
|
||||
sendBugReport(url, {
|
||||
userText: text,
|
||||
sendLogs: withLogs,
|
||||
progressCallback: console.log.bind(console),
|
||||
progressCallback: logger.log.bind(console),
|
||||
}).then(() => {
|
||||
console.log("Bug report sent!");
|
||||
logger.log("Bug report sent!");
|
||||
}, (err) => {
|
||||
logger.error(err);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user