openvidu-browser: log JSNLog messages in dev mode. Better initPublisher log

pull/634/head
pabloFuente 2021-06-22 12:58:00 +02:00
parent 7e739bc2d4
commit 3f0756984a
2 changed files with 27 additions and 19 deletions

View File

@ -389,6 +389,7 @@ export class Publisher extends StreamManager {
const errorCallback = (openViduError: OpenViduError) => {
this.accessDenied = true;
this.accessAllowed = false;
logger.error(`Publisher initialization failed. ${openViduError.name}: ${openViduError.message}`)
reject(openViduError);
};
@ -496,7 +497,7 @@ export class Publisher extends StreamManager {
};
const getMediaError = error => {
logger.error(`getMediaError: ${JSON.stringify(error)}`);
logger.error(`getMediaError: ${error.toString()}`);
this.clearPermissionDialogTimer(startTime, timeForDialogEvent);
if (error.name === 'Error') {
// Safari OverConstrainedError has as name property 'Error' instead of 'OverConstrainedError'

View File

@ -29,12 +29,14 @@ export class OpenViduLogger {
static configureJSNLog(openVidu: OpenVidu, token: string) {
try {
// If dev mode
if ((window['LOG_JSNLOG_RESULTS']) ||
// If instance is created and it is OpenVidu Pro
if (this.instance && openVidu.webrtcStatsInterval > -1
(this.instance && openVidu.webrtcStatsInterval > -1
// If logs are enabled
&& openVidu.sendBrowserLogs === OpenViduLoggerConfiguration.debug
// Only reconfigure it if session or finalUserId has changed
&& this.instance.canConfigureJSNLog(openVidu, this.instance)) {
&& this.instance.canConfigureJSNLog(openVidu, this.instance))) {
// isJSNLogSetup will not be true until completed setup
this.instance.isJSNLogSetup = false;
this.instance.info("Configuring JSNLogs.");
@ -88,10 +90,15 @@ export class OpenViduLogger {
};
// Cut long messages
const stringifyJson = JSON.stringify(obj, getCircularReplacer());
let stringifyJson = JSON.stringify(obj, getCircularReplacer());
if (stringifyJson.length > this.instance.MAX_LENGTH_STRING_JSON) {
return `${stringifyJson.substring(0, this.instance.MAX_LENGTH_STRING_JSON)}...`;
stringifyJson = `${stringifyJson.substring(0, this.instance.MAX_LENGTH_STRING_JSON)}...`;
}
if (window['LOG_JSNLOG_RESULTS']) {
console.log(stringifyJson);
}
return stringifyJson;
};