Replace console.logs to logger.log
Related https://github.com/vector-im/element-web/issues/18425pull/21833/head
parent
12632318ef
commit
9c594a8a96
|
@ -29,6 +29,8 @@ import { saveAs } from "file-saver";
|
||||||
import { _t } from "../../languageHandler";
|
import { _t } from "../../languageHandler";
|
||||||
import SdkConfig from "../../SdkConfig";
|
import SdkConfig from "../../SdkConfig";
|
||||||
|
|
||||||
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
|
||||||
type BlobFile = {
|
type BlobFile = {
|
||||||
name: string;
|
name: string;
|
||||||
blob: Blob;
|
blob: Blob;
|
||||||
|
@ -61,7 +63,7 @@ export default abstract class Exporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updateProgress(progress: string, log = true, show = true): void {
|
protected updateProgress(progress: string, log = true, show = true): void {
|
||||||
if (log) console.log(progress);
|
if (log) logger.log(progress);
|
||||||
if (show) this.setProgressText(progress);
|
if (show) this.setProgressText(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,13 +93,13 @@ export default abstract class Exporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected cleanUp(): string {
|
protected cleanUp(): string {
|
||||||
console.log("Cleaning up...");
|
logger.log("Cleaning up...");
|
||||||
window.removeEventListener("beforeunload", this.onBeforeUnload);
|
window.removeEventListener("beforeunload", this.onBeforeUnload);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public async cancelExport(): Promise<void> {
|
public async cancelExport(): Promise<void> {
|
||||||
console.log("Cancelling export...");
|
logger.log("Cancelling export...");
|
||||||
this.cancelled = true;
|
this.cancelled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +214,7 @@ export default abstract class Exporter {
|
||||||
blob = await image.blob();
|
blob = await image.blob();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Error decrypting media");
|
logger.log("Error decrypting media");
|
||||||
}
|
}
|
||||||
return blob;
|
return blob;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,8 @@ import MatrixClientContext from "../../contexts/MatrixClientContext";
|
||||||
import getExportCSS from "./exportCSS";
|
import getExportCSS from "./exportCSS";
|
||||||
import { textForEvent } from "../../TextForEvent";
|
import { textForEvent } from "../../TextForEvent";
|
||||||
|
|
||||||
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
|
||||||
export default class HTMLExporter extends Exporter {
|
export default class HTMLExporter extends Exporter {
|
||||||
protected avatars: Map<string, boolean>;
|
protected avatars: Map<string, boolean>;
|
||||||
protected permalinkCreator: RoomPermalinkCreator;
|
protected permalinkCreator: RoomPermalinkCreator;
|
||||||
|
@ -70,7 +72,7 @@ export default class HTMLExporter extends Exporter {
|
||||||
this.totalSize += blob.size;
|
this.totalSize += blob.size;
|
||||||
this.addFile(avatarPath, blob);
|
this.addFile(avatarPath, blob);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Failed to fetch room's avatar" + err);
|
logger.log("Failed to fetch room's avatar" + err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const avatar = (
|
const avatar = (
|
||||||
|
@ -238,7 +240,7 @@ export default class HTMLExporter extends Exporter {
|
||||||
const blob = await image.blob();
|
const blob = await image.blob();
|
||||||
this.addFile(`users/${member.userId.replace(/:/g, '-')}.png`, blob);
|
this.addFile(`users/${member.userId.replace(/:/g, '-')}.png`, blob);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Failed to fetch user's avatar" + err);
|
logger.log("Failed to fetch user's avatar" + err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,7 +364,7 @@ export default class HTMLExporter extends Exporter {
|
||||||
this.addFile(filePath, blob);
|
this.addFile(filePath, blob);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("Error while fetching file" + e);
|
logger.log("Error while fetching file" + e);
|
||||||
eventTile = await this.getEventTileMarkup(
|
eventTile = await this.getEventTileMarkup(
|
||||||
this.createModifiedEvent(_t("Error fetching file"), mxEv),
|
this.createModifiedEvent(_t("Error fetching file"), mxEv),
|
||||||
joined,
|
joined,
|
||||||
|
|
|
@ -23,6 +23,8 @@ import { ExportType } from "./exportUtils";
|
||||||
import { IExportOptions } from "./exportUtils";
|
import { IExportOptions } from "./exportUtils";
|
||||||
import { EventType } from "matrix-js-sdk/src/@types/event";
|
import { EventType } from "matrix-js-sdk/src/@types/event";
|
||||||
|
|
||||||
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
|
||||||
export default class JSONExporter extends Exporter {
|
export default class JSONExporter extends Exporter {
|
||||||
protected totalSize = 0;
|
protected totalSize = 0;
|
||||||
protected messages: Record<string, any>[] = [];
|
protected messages: Record<string, any>[] = [];
|
||||||
|
@ -67,7 +69,7 @@ export default class JSONExporter extends Exporter {
|
||||||
this.addFile(filePath, blob);
|
this.addFile(filePath, blob);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Error fetching file: " + err);
|
logger.log("Error fetching file: " + err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const jsonEvent: any = mxEv.toJSON();
|
const jsonEvent: any = mxEv.toJSON();
|
||||||
|
@ -94,7 +96,7 @@ export default class JSONExporter extends Exporter {
|
||||||
const res = await this.getRequiredEvents();
|
const res = await this.getRequiredEvents();
|
||||||
const fetchEnd = performance.now();
|
const fetchEnd = performance.now();
|
||||||
|
|
||||||
console.log(`Fetched ${res.length} events in ${(fetchEnd - fetchStart)/1000}s`);
|
logger.log(`Fetched ${res.length} events in ${(fetchEnd - fetchStart)/1000}s`);
|
||||||
|
|
||||||
console.info("Creating output...");
|
console.info("Creating output...");
|
||||||
const text = await this.createOutput(res);
|
const text = await this.createOutput(res);
|
||||||
|
@ -113,7 +115,7 @@ export default class JSONExporter extends Exporter {
|
||||||
console.info("Export cancelled successfully");
|
console.info("Export cancelled successfully");
|
||||||
} else {
|
} else {
|
||||||
console.info("Export successful!");
|
console.info("Export successful!");
|
||||||
console.log(`Exported ${res.length} events in ${(exportEnd - fetchStart)/1000} seconds`);
|
logger.log(`Exported ${res.length} events in ${(exportEnd - fetchStart)/1000} seconds`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cleanUp();
|
this.cleanUp();
|
||||||
|
|
|
@ -24,6 +24,8 @@ import { ExportType } from "./exportUtils";
|
||||||
import { IExportOptions } from "./exportUtils";
|
import { IExportOptions } from "./exportUtils";
|
||||||
import { textForEvent } from "../../TextForEvent";
|
import { textForEvent } from "../../TextForEvent";
|
||||||
|
|
||||||
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
|
||||||
export default class PlainTextExporter extends Exporter {
|
export default class PlainTextExporter extends Exporter {
|
||||||
protected totalSize: number;
|
protected totalSize: number;
|
||||||
protected mediaOmitText: string;
|
protected mediaOmitText: string;
|
||||||
|
@ -94,7 +96,7 @@ export default class PlainTextExporter extends Exporter {
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
mediaText = " (" + _t("Error fetching file") + ")";
|
mediaText = " (" + _t("Error fetching file") + ")";
|
||||||
console.log("Error fetching file " + error);
|
logger.log("Error fetching file " + error);
|
||||||
}
|
}
|
||||||
} else mediaText = ` (${this.mediaOmitText})`;
|
} else mediaText = ` (${this.mediaOmitText})`;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +125,7 @@ export default class PlainTextExporter extends Exporter {
|
||||||
const res = await this.getRequiredEvents();
|
const res = await this.getRequiredEvents();
|
||||||
const fetchEnd = performance.now();
|
const fetchEnd = performance.now();
|
||||||
|
|
||||||
console.log(`Fetched ${res.length} events in ${(fetchEnd - fetchStart)/1000}s`);
|
logger.log(`Fetched ${res.length} events in ${(fetchEnd - fetchStart)/1000}s`);
|
||||||
|
|
||||||
this.updateProgress("Creating output...");
|
this.updateProgress("Creating output...");
|
||||||
const text = await this.createOutput(res);
|
const text = await this.createOutput(res);
|
||||||
|
@ -142,7 +144,7 @@ export default class PlainTextExporter extends Exporter {
|
||||||
console.info("Export cancelled successfully");
|
console.info("Export cancelled successfully");
|
||||||
} else {
|
} else {
|
||||||
console.info("Export successful!");
|
console.info("Export successful!");
|
||||||
console.log(`Exported ${res.length} events in ${(exportEnd - fetchStart)/1000} seconds`);
|
logger.log(`Exported ${res.length} events in ${(exportEnd - fetchStart)/1000} seconds`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cleanUp();
|
this.cleanUp();
|
||||||
|
|
Loading…
Reference in New Issue