mirror of
https://github.com/element-hq/element-web
synced 2024-11-29 12:58:53 +03: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
6 changed files with 31 additions and 31 deletions
|
@ -40,7 +40,7 @@ import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
|
||||||
let lastLocationHashSet: string = null;
|
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
|
// Parse the given window.location and return parameters that can be used when calling
|
||||||
// MatrixChat.showScreen(screen, params)
|
// MatrixChat.showScreen(screen, params)
|
||||||
|
@ -57,7 +57,7 @@ function getScreenFromLocation(location: Location) {
|
||||||
function routeUrl(location: Location) {
|
function routeUrl(location: Location) {
|
||||||
if (!window.matrixChat) return;
|
if (!window.matrixChat) return;
|
||||||
|
|
||||||
console.log("Routing URL ", location.href);
|
logger.log("Routing URL ", location.href);
|
||||||
const s = getScreenFromLocation(location);
|
const s = getScreenFromLocation(location);
|
||||||
(window.matrixChat as MatrixChatType).showScreen(s.screen, s.params);
|
(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,
|
// This will be called whenever the SDK changes screens,
|
||||||
// so a web page can update the URL bar appropriately.
|
// so a web page can update the URL bar appropriately.
|
||||||
function onNewScreen(screen: string, replaceLast = false) {
|
function onNewScreen(screen: string, replaceLast = false) {
|
||||||
console.log("newscreen " + screen);
|
logger.log("newscreen " + screen);
|
||||||
const hash = '#/' + screen;
|
const hash = '#/' + screen;
|
||||||
lastLocationHashSet = hash;
|
lastLocationHashSet = hash;
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ function onTokenLoginCompleted() {
|
||||||
|
|
||||||
url.searchParams.delete("loginToken");
|
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);
|
window.history.replaceState(null, "", url.href);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ export async function loadApp(fragParams: {}) {
|
||||||
const params = parseQs(window.location);
|
const params = parseQs(window.location);
|
||||||
|
|
||||||
const urlWithoutQuery = window.location.protocol + '//' + window.location.host + window.location.pathname;
|
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();
|
(platform as VectorBasePlatform).startUpdater();
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ export async function loadApp(fragParams: {}) {
|
||||||
const isReturningFromSso = !!params.loginToken;
|
const isReturningFromSso = !!params.loginToken;
|
||||||
const autoRedirect = config['sso_immediate_redirect'] === true;
|
const autoRedirect = config['sso_immediate_redirect'] === true;
|
||||||
if (!hasPossibleToken && !isReturningFromSso && autoRedirect) {
|
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({
|
const tempCli = createClient({
|
||||||
baseUrl: config['validated_server_config'].hsUrl,
|
baseUrl: config['validated_server_config'].hsUrl,
|
||||||
idBaseUrl: config['validated_server_config'].isUrl,
|
idBaseUrl: config['validated_server_config'].isUrl,
|
||||||
|
@ -190,7 +190,7 @@ export async function loadApp(fragParams: {}) {
|
||||||
async function verifyServerConfig() {
|
async function verifyServerConfig() {
|
||||||
let validatedConfig;
|
let validatedConfig;
|
||||||
try {
|
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
|
// 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
|
// context of email validation. Because we don't respect them otherwise, we do not need
|
||||||
|
@ -221,7 +221,7 @@ async function verifyServerConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hsUrl) {
|
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(
|
console.warn(
|
||||||
"DEPRECATED CONFIG OPTION: In the future, default_hs_url will not be accepted. Please use " +
|
"DEPRECATED CONFIG OPTION: In the future, default_hs_url will not be accepted. Please use " +
|
||||||
"default_server_config instead.",
|
"default_server_config instead.",
|
||||||
|
@ -241,12 +241,12 @@ async function verifyServerConfig() {
|
||||||
|
|
||||||
let discoveryResult = null;
|
let discoveryResult = null;
|
||||||
if (wkConfig) {
|
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);
|
discoveryResult = await AutoDiscovery.fromDiscoveryConfig(wkConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverName) {
|
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(
|
console.warn(
|
||||||
"DEPRECATED CONFIG OPTION: In the future, default_server_name will not be accepted. Please " +
|
"DEPRECATED CONFIG OPTION: In the future, default_server_name will not be accepted. Please " +
|
||||||
"use default_server_config instead.",
|
"use default_server_config instead.",
|
||||||
|
@ -261,7 +261,7 @@ async function verifyServerConfig() {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
console.warn("A session was found - suppressing config error and using the session's homeserver");
|
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);
|
validatedConfig = await AutoDiscoveryUtils.validateServerConfigWithStaticUrls(hsUrl, isUrl, true);
|
||||||
} else {
|
} else {
|
||||||
// the user is not logged in, so scream
|
// the user is not logged in, so scream
|
||||||
|
@ -272,10 +272,10 @@ async function verifyServerConfig() {
|
||||||
validatedConfig.isDefault = true;
|
validatedConfig.isDefault = true;
|
||||||
|
|
||||||
// Just in case we ever have to debug this
|
// 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
|
// 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 });
|
SdkConfig.add({ "validated_server_config": validatedConfig });
|
||||||
|
|
||||||
return SdkConfig.get();
|
return SdkConfig.get();
|
||||||
|
|
|
@ -181,7 +181,7 @@ async function start() {
|
||||||
if (window.localStorage) {
|
if (window.localStorage) {
|
||||||
window.localStorage.setItem('mx_accepts_unsupported_browser', String(true));
|
window.localStorage.setItem('mx_accepts_unsupported_browser', String(true));
|
||||||
}
|
}
|
||||||
console.log("User accepts the compatibility risks.");
|
logger.log("User accepts the compatibility risks.");
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -41,13 +41,13 @@ export const rageshakePromise = initRageshake();
|
||||||
|
|
||||||
export function preparePlatform() {
|
export function preparePlatform() {
|
||||||
if (window.electron) {
|
if (window.electron) {
|
||||||
console.log("Using Electron platform");
|
logger.log("Using Electron platform");
|
||||||
PlatformPeg.set(new ElectronPlatform());
|
PlatformPeg.set(new ElectronPlatform());
|
||||||
} else if (window.matchMedia('(display-mode: standalone)').matches) {
|
} else if (window.matchMedia('(display-mode: standalone)').matches) {
|
||||||
console.log("Using PWA platform");
|
logger.log("Using PWA platform");
|
||||||
PlatformPeg.set(new PWAPlatform());
|
PlatformPeg.set(new PWAPlatform());
|
||||||
} else {
|
} else {
|
||||||
console.log("Using Web platform");
|
logger.log("Using Web platform");
|
||||||
PlatformPeg.set(new WebPlatform());
|
PlatformPeg.set(new WebPlatform());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,9 +84,9 @@ export function loadOlm(): Promise<void> {
|
||||||
return Olm.init({
|
return Olm.init({
|
||||||
locateFile: () => olmWasmPath,
|
locateFile: () => olmWasmPath,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
console.log("Using WebAssembly Olm");
|
logger.log("Using WebAssembly Olm");
|
||||||
}).catch((e) => {
|
}).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) => {
|
return new Promise((resolve, reject) => {
|
||||||
const s = document.createElement('script');
|
const s = document.createElement('script');
|
||||||
s.src = 'olm_legacy.js'; // XXX: This should be cache-busted too
|
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.
|
// not 'Olm' which is still the failed wasm version.
|
||||||
return window.Olm.init();
|
return window.Olm.init();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
console.log("Using legacy Olm");
|
logger.log("Using legacy Olm");
|
||||||
}).catch((e) => {
|
}).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() {
|
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
|
// 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.
|
// 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
|
// load these async so that its code is not executed immediately and we can catch any exceptions
|
||||||
const [sdk, skin] = await Promise.all([
|
const [sdk, skin] = await Promise.all([
|
||||||
import(
|
import(
|
||||||
|
@ -142,7 +142,7 @@ export async function loadSkin() {
|
||||||
"../component-index"),
|
"../component-index"),
|
||||||
]);
|
]);
|
||||||
sdk.loadSkin(skin);
|
sdk.loadSkin(skin);
|
||||||
console.log("Skin loaded!");
|
logger.log("Skin loaded!");
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadTheme() {
|
export async function loadTheme() {
|
||||||
|
|
|
@ -117,7 +117,7 @@ let meetApi: any; // JitsiMeetExternalAPI
|
||||||
if (jitsiAuth === JITSI_OPENIDTOKEN_JWT_AUTH) {
|
if (jitsiAuth === JITSI_OPENIDTOKEN_JWT_AUTH) {
|
||||||
// Request credentials, give callback to continue when received
|
// Request credentials, give callback to continue when received
|
||||||
openIdToken = await widgetApi.requestOpenIDConnectToken();
|
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)
|
// 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.
|
// try to flush the rageshake logs to indexeddb before quit.
|
||||||
electron.on('before-quit', function() {
|
electron.on('before-quit', function() {
|
||||||
console.log('element-desktop closing');
|
logger.log('element-desktop closing');
|
||||||
rageshake.flush();
|
rageshake.flush();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -533,7 +533,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||||
|
|
||||||
setSpellCheckLanguages(preferredLangs: string[]) {
|
setSpellCheckLanguages(preferredLangs: string[]) {
|
||||||
this.ipcCall('setSpellCheckLanguages', preferredLangs).catch(error => {
|
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);
|
logger.error(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,12 +36,12 @@ export function initRageshake() {
|
||||||
// we manually check persistence for rageshakes ourselves
|
// we manually check persistence for rageshakes ourselves
|
||||||
const prom = rageshake.init(/*setUpPersistence=*/false);
|
const prom = rageshake.init(/*setUpPersistence=*/false);
|
||||||
prom.then(() => {
|
prom.then(() => {
|
||||||
console.log("Initialised rageshake.");
|
logger.log("Initialised rageshake.");
|
||||||
console.log("To fix line numbers in Chrome: " +
|
logger.log("To fix line numbers in Chrome: " +
|
||||||
"Meatball menu → Settings → Ignore list → Add /rageshake\\.js$");
|
"Meatball menu → Settings → Ignore list → Add /rageshake\\.js$");
|
||||||
|
|
||||||
window.addEventListener('beforeunload', (e) => {
|
window.addEventListener('beforeunload', (e) => {
|
||||||
console.log('element-web closing');
|
logger.log('element-web closing');
|
||||||
// try to flush the logs to indexeddb
|
// try to flush the logs to indexeddb
|
||||||
rageshake.flush();
|
rageshake.flush();
|
||||||
});
|
});
|
||||||
|
@ -72,9 +72,9 @@ window.mxSendRageshake = function(text: string, withLogs?: boolean) {
|
||||||
sendBugReport(url, {
|
sendBugReport(url, {
|
||||||
userText: text,
|
userText: text,
|
||||||
sendLogs: withLogs,
|
sendLogs: withLogs,
|
||||||
progressCallback: console.log.bind(console),
|
progressCallback: logger.log.bind(console),
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
console.log("Bug report sent!");
|
logger.log("Bug report sent!");
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue