mirror of https://github.com/OpenVidu/openvidu.git
Max length for log messages sent to not miss important information
parent
b7da22180c
commit
68eac029c1
|
@ -175,7 +175,7 @@ export class Connection {
|
|||
this.addStream(stream);
|
||||
});
|
||||
|
||||
logger.debug("Remote 'Connection' with 'connectionId' [" + this.connectionId + '] is now configured for receiving Streams with options: ', this.stream!.inboundStreamOpts);
|
||||
logger.info("Remote 'Connection' with 'connectionId' [" + this.connectionId + '] is now configured for receiving Streams with options: ', this.stream!.inboundStreamOpts);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -74,9 +74,9 @@ export abstract class EventDispatcher {
|
|||
onAux(type: string, message: string, handler: (event: Event) => void): EventDispatcher {
|
||||
const arrowHandler = event => {
|
||||
if (event) {
|
||||
logger.debug(message, event);
|
||||
logger.info(message, event);
|
||||
} else {
|
||||
logger.debug(message);
|
||||
logger.info(message);
|
||||
}
|
||||
handler(event);
|
||||
};
|
||||
|
@ -91,9 +91,9 @@ export abstract class EventDispatcher {
|
|||
onceAux(type: string, message: string, handler: (event: Event) => void): EventDispatcher {
|
||||
const arrowHandler = event => {
|
||||
if (event) {
|
||||
logger.debug(message, event);
|
||||
logger.info(message, event);
|
||||
} else {
|
||||
logger.debug(message);
|
||||
logger.info(message);
|
||||
}
|
||||
handler(event);
|
||||
// Remove handler from map after first and only execution
|
||||
|
|
|
@ -306,7 +306,7 @@ export class StreamManager extends EventDispatcher {
|
|||
canplayListenerAdded: false
|
||||
});
|
||||
|
||||
logger.debug('New video element associated to ', this);
|
||||
logger.info('New video element associated to ', this);
|
||||
|
||||
return returnNumber;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ export class OpenViduLogger {
|
|||
private JSNLOG_URL: string = "/openvidu/elk/openvidu-browser-logs";
|
||||
private MAX_JSNLOG_BATCH_LOG_MESSAGES: number = 100;
|
||||
private MAX_MSECONDS_BATCH_MESSAGES: number = 5000;
|
||||
private MAX_LENGTH_STRING_JSON: number = 1000;
|
||||
|
||||
private logger: Console = window.console;
|
||||
private LOG_FNS = [this.logger.log, this.logger.debug, this.logger.info, this.logger.warn, this.logger.error];
|
||||
|
@ -27,7 +28,7 @@ export class OpenViduLogger {
|
|||
private constructor() {}
|
||||
|
||||
static configureJSNLog(openVidu: OpenVidu, token: string) {
|
||||
// If instance is created is OpenVidu Pro
|
||||
// If instance is created and it is OpenVidu Pro
|
||||
if (this.instance && openVidu.webrtcStatsInterval > -1
|
||||
// If logs are enabled
|
||||
&& openVidu.sendBrowserLogs === OpenViduLoggerConfiguration.debug
|
||||
|
@ -86,7 +87,13 @@ export class OpenViduLogger {
|
|||
return value;
|
||||
};
|
||||
};
|
||||
return JSON.stringify(obj, getCircularReplacer());
|
||||
|
||||
// Cut long messages
|
||||
const stringifyJson = JSON.stringify(obj, getCircularReplacer());
|
||||
if (stringifyJson.length > this.instance.MAX_LENGTH_STRING_JSON) {
|
||||
return `${stringifyJson.substring(0, this.instance.MAX_LENGTH_STRING_JSON)}...`;
|
||||
}
|
||||
return stringifyJson;
|
||||
};
|
||||
|
||||
// Initialize JL to send logs
|
||||
|
@ -120,6 +127,15 @@ export class OpenViduLogger {
|
|||
return OpenViduLogger.instance;
|
||||
}
|
||||
|
||||
private isDebugLogEnabled() {
|
||||
return this.isJSNLogSetup;
|
||||
}
|
||||
|
||||
private canConfigureJSNLog(openVidu: OpenVidu, logger: OpenViduLogger): boolean {
|
||||
return openVidu.session.sessionId != logger.loggingSessionId &&
|
||||
openVidu.finalUserId != logger.loggingFinalUserId
|
||||
}
|
||||
|
||||
log(...args: any[]){
|
||||
if (!this.isProdMode) {
|
||||
this.LOG_FNS[0].apply(this.logger, arguments);
|
||||
|
@ -170,12 +186,4 @@ export class OpenViduLogger {
|
|||
this.isProdMode = true;
|
||||
}
|
||||
|
||||
private isDebugLogEnabled() {
|
||||
return this.isJSNLogSetup;
|
||||
}
|
||||
|
||||
private canConfigureJSNLog(openVidu: OpenVidu, logger: OpenViduLogger): boolean {
|
||||
return openVidu.session.sessionId != logger.loggingSessionId || openVidu.finalUserId != logger.loggingFinalUserId
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue