mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: log JSNLog messages in dev mode. Better initPublisher log
parent
7e739bc2d4
commit
3f0756984a
|
@ -389,6 +389,7 @@ export class Publisher extends StreamManager {
|
||||||
const errorCallback = (openViduError: OpenViduError) => {
|
const errorCallback = (openViduError: OpenViduError) => {
|
||||||
this.accessDenied = true;
|
this.accessDenied = true;
|
||||||
this.accessAllowed = false;
|
this.accessAllowed = false;
|
||||||
|
logger.error(`Publisher initialization failed. ${openViduError.name}: ${openViduError.message}`)
|
||||||
reject(openViduError);
|
reject(openViduError);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -496,7 +497,7 @@ export class Publisher extends StreamManager {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getMediaError = error => {
|
const getMediaError = error => {
|
||||||
logger.error(`getMediaError: ${JSON.stringify(error)}`);
|
logger.error(`getMediaError: ${error.toString()}`);
|
||||||
this.clearPermissionDialogTimer(startTime, timeForDialogEvent);
|
this.clearPermissionDialogTimer(startTime, timeForDialogEvent);
|
||||||
if (error.name === 'Error') {
|
if (error.name === 'Error') {
|
||||||
// Safari OverConstrainedError has as name property 'Error' instead of 'OverConstrainedError'
|
// Safari OverConstrainedError has as name property 'Error' instead of 'OverConstrainedError'
|
||||||
|
|
|
@ -29,12 +29,14 @@ export class OpenViduLogger {
|
||||||
|
|
||||||
static configureJSNLog(openVidu: OpenVidu, token: string) {
|
static configureJSNLog(openVidu: OpenVidu, token: string) {
|
||||||
try {
|
try {
|
||||||
|
// If dev mode
|
||||||
|
if ((window['LOG_JSNLOG_RESULTS']) ||
|
||||||
// If instance is created and it is OpenVidu Pro
|
// If instance is created and it is OpenVidu Pro
|
||||||
if (this.instance && openVidu.webrtcStatsInterval > -1
|
(this.instance && openVidu.webrtcStatsInterval > -1
|
||||||
// If logs are enabled
|
// If logs are enabled
|
||||||
&& openVidu.sendBrowserLogs === OpenViduLoggerConfiguration.debug
|
&& openVidu.sendBrowserLogs === OpenViduLoggerConfiguration.debug
|
||||||
// Only reconfigure it if session or finalUserId has changed
|
// 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
|
// 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.");
|
||||||
|
@ -88,10 +90,15 @@ export class OpenViduLogger {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Cut long messages
|
// Cut long messages
|
||||||
const stringifyJson = JSON.stringify(obj, getCircularReplacer());
|
let stringifyJson = JSON.stringify(obj, getCircularReplacer());
|
||||||
if (stringifyJson.length > this.instance.MAX_LENGTH_STRING_JSON) {
|
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;
|
return stringifyJson;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue