openvidu-browser: Don't add HTMLElements to openvidu-browser logs

pull/630/head
cruizba 2021-05-11 18:53:53 +02:00
parent eb3c28d0be
commit 43339f7df8
1 changed files with 16 additions and 17 deletions

View File

@ -28,14 +28,13 @@ export class OpenViduLogger {
private constructor() {} private constructor() {}
static configureJSNLog(openVidu: OpenVidu, token: string) { static configureJSNLog(openVidu: OpenVidu, token: string) {
// If instance is created and it is OpenVidu Pro try {
if (this.instance && openVidu.webrtcStatsInterval > -1 // If instance is created and it is OpenVidu Pro
// If logs are enabled if (this.instance && openVidu.webrtcStatsInterval > -1
&& openVidu.sendBrowserLogs === OpenViduLoggerConfiguration.debug // If logs are enabled
// Only reconfigure it if session or finalUserId has changed && openVidu.sendBrowserLogs === OpenViduLoggerConfiguration.debug
&& this.instance.canConfigureJSNLog(openVidu, this.instance)) { // Only reconfigure it if session or finalUserId has changed
&& this.instance.canConfigureJSNLog(openVidu, this.instance)) {
try {
// isJSNLogSetup will not be true until completed setup // isJSNLogSetup will not be true until completed setup
this.instance.isJSNLogSetup = false; this.instance.isJSNLogSetup = false;
this.instance.info("Configuring JSNLogs."); this.instance.info("Configuring JSNLogs.");
@ -79,7 +78,7 @@ export class OpenViduLogger {
const seen = new WeakSet(); const seen = new WeakSet();
return (key, value) => { return (key, value) => {
if (typeof value === "object" && value != null) { if (typeof value === "object" && value != null) {
if (seen.has(value)) { if (seen.has(value) || value instanceof HTMLElement) {
return; return;
} }
seen.add(value); seen.add(value);
@ -109,14 +108,14 @@ export class OpenViduLogger {
this.instance.loggingSessionId = sessionId; this.instance.loggingSessionId = sessionId;
this.instance.loggingFinalUserId = finalUserId; this.instance.loggingFinalUserId = finalUserId;
this.instance.info("JSNLog configured."); this.instance.info("JSNLog configured.");
} catch (e) {
console.error("Error configuring JSNLog: ");
console.error(e);
this.instance.isJSNLogSetup = false;
this.instance.loggingSessionId = undefined;
this.instance.loggingFinalUserId = undefined;
this.instance.currentAppender = undefined;
} }
} catch (e) {
console.error("Error configuring JSNLog: ");
console.error(e);
this.instance.isJSNLogSetup = false;
this.instance.loggingSessionId = undefined;
this.instance.loggingFinalUserId = undefined;
this.instance.currentAppender = undefined;
} }
} }
@ -133,7 +132,7 @@ export class OpenViduLogger {
private canConfigureJSNLog(openVidu: OpenVidu, logger: OpenViduLogger): boolean { private canConfigureJSNLog(openVidu: OpenVidu, logger: OpenViduLogger): boolean {
return openVidu.session.sessionId != logger.loggingSessionId && return openVidu.session.sessionId != logger.loggingSessionId &&
openVidu.finalUserId != logger.loggingFinalUserId openVidu.finalUserId != logger.loggingFinalUserId
} }
log(...args: any[]){ log(...args: any[]){