mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: Parametrized send openvidu browser logs, disabled by default
parent
29a8b864cb
commit
5287ed631f
|
@ -32,6 +32,7 @@ import { PlatformUtils } from '../OpenViduInternal/Utils/Platform';
|
||||||
|
|
||||||
import * as screenSharingAuto from '../OpenViduInternal/ScreenSharing/Screen-Capturing-Auto';
|
import * as screenSharingAuto from '../OpenViduInternal/ScreenSharing/Screen-Capturing-Auto';
|
||||||
import * as screenSharing from '../OpenViduInternal/ScreenSharing/Screen-Capturing';
|
import * as screenSharing from '../OpenViduInternal/ScreenSharing/Screen-Capturing';
|
||||||
|
import {OpenViduLoggerConfiguration} from "../OpenViduInternal/Logger/OpenViduLoggerConfiguration";
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
|
@ -107,6 +108,12 @@ export class OpenVidu {
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
webrtcStatsInterval: number = -1;
|
webrtcStatsInterval: number = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
sendBrowserLogs: OpenViduLoggerConfiguration = OpenViduLoggerConfiguration.disabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1190,6 +1190,7 @@ export class Session extends EventDispatcher {
|
||||||
} else {
|
} else {
|
||||||
logger.warn('You were not connected to the session ' + this.sessionId);
|
logger.warn('You were not connected to the session ' + this.sessionId);
|
||||||
}
|
}
|
||||||
|
logger.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1452,6 +1453,7 @@ export class Session extends EventDispatcher {
|
||||||
const secret = queryParams['secret'];
|
const secret = queryParams['secret'];
|
||||||
const recorder = queryParams['recorder'];
|
const recorder = queryParams['recorder'];
|
||||||
const webrtcStatsInterval = queryParams['webrtcStatsInterval'];
|
const webrtcStatsInterval = queryParams['webrtcStatsInterval'];
|
||||||
|
const sendBrowserLogs = queryParams['sendBrowserLogs'];
|
||||||
|
|
||||||
if (!!secret) {
|
if (!!secret) {
|
||||||
this.openvidu.secret = secret;
|
this.openvidu.secret = secret;
|
||||||
|
@ -1462,6 +1464,9 @@ export class Session extends EventDispatcher {
|
||||||
if (!!webrtcStatsInterval) {
|
if (!!webrtcStatsInterval) {
|
||||||
this.openvidu.webrtcStatsInterval = +webrtcStatsInterval;
|
this.openvidu.webrtcStatsInterval = +webrtcStatsInterval;
|
||||||
}
|
}
|
||||||
|
if(!!sendBrowserLogs) {
|
||||||
|
this.openvidu.sendBrowserLogs = sendBrowserLogs;
|
||||||
|
}
|
||||||
|
|
||||||
this.openvidu.wsUri = 'wss://' + url.host + '/openvidu';
|
this.openvidu.wsUri = 'wss://' + url.host + '/openvidu';
|
||||||
this.openvidu.httpUri = 'https://' + url.host;
|
this.openvidu.httpUri = 'https://' + url.host;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import {JL} from 'jsnlog'
|
import {JL} from 'jsnlog'
|
||||||
import {OpenVidu} from "../../OpenVidu/OpenVidu";
|
import {OpenVidu} from "../../OpenVidu/OpenVidu";
|
||||||
|
import {OpenViduLoggerConfiguration} from "./OpenViduLoggerConfiguration";
|
||||||
|
|
||||||
export class OpenViduLogger {
|
export class OpenViduLogger {
|
||||||
|
|
||||||
|
@ -7,7 +8,6 @@ export class OpenViduLogger {
|
||||||
|
|
||||||
private JSNLOG_URL: string = "/openvidu/elk/openvidu-browser-logs";
|
private JSNLOG_URL: string = "/openvidu/elk/openvidu-browser-logs";
|
||||||
private MAX_JSNLOG_BATCH_LOG_MESSAGES: number = 50;
|
private MAX_JSNLOG_BATCH_LOG_MESSAGES: number = 50;
|
||||||
private MAX_JSNLOG_MAX_BACTH_MESSAGES: number = 1000;
|
|
||||||
private MAX_MSECONDS_BATCH_MESSAGES: number = 5000;
|
private MAX_MSECONDS_BATCH_MESSAGES: number = 5000;
|
||||||
|
|
||||||
private openvidu: OpenVidu;
|
private openvidu: OpenVidu;
|
||||||
|
@ -16,6 +16,7 @@ export class OpenViduLogger {
|
||||||
private isProdMode = false;
|
private isProdMode = false;
|
||||||
private isJSNLogEnabled = true;
|
private isJSNLogEnabled = true;
|
||||||
private isJSNLogSetup = false;
|
private isJSNLogSetup = false;
|
||||||
|
private customAppenders: JL.JSNLogAjaxAppender[] = [];
|
||||||
|
|
||||||
|
|
||||||
private constructor() {}
|
private constructor() {}
|
||||||
|
@ -25,27 +26,29 @@ export class OpenViduLogger {
|
||||||
*/
|
*/
|
||||||
static configureJSNLog(openVidu: OpenVidu, sessionId: string, connectionId: string, token: string) {
|
static configureJSNLog(openVidu: OpenVidu, sessionId: string, connectionId: string, token: string) {
|
||||||
// If instance is not null, JSNLog is enabled and is OpenVidu Pro
|
// If instance is not null, JSNLog is enabled and is OpenVidu Pro
|
||||||
if (this.instance && this.instance.isJSNLogEnabled && openVidu.webrtcStatsInterval > -1) {
|
if (this.instance && this.instance.isJSNLogEnabled && openVidu.webrtcStatsInterval > -1 && openVidu.sendBrowserLogs === OpenViduLoggerConfiguration.debug) {
|
||||||
this.instance.info("Configuring JSNLogs.");
|
this.instance.info("Configuring JSNLogs.");
|
||||||
try {
|
try {
|
||||||
this.instance.openvidu = openVidu;
|
this.instance.openvidu = openVidu;
|
||||||
|
|
||||||
// Use connection id as user and token as password
|
// Use connection id as user and token as password
|
||||||
const openViduJSNLogHeaders = (xhr) => {
|
const openViduJSNLogHeaders = (xhr) => {
|
||||||
xhr.setRequestHeader('Authorization', "Basic " + btoa(connectionId + ":" + token));
|
xhr.setRequestHeader('Authorization', "Basic " + btoa(`${connectionId}%/%${sessionId}` + ":" + token));
|
||||||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
|
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
|
||||||
// Additional headers for OpenVidu
|
// Additional headers for OpenVidu
|
||||||
xhr.setRequestHeader('OV-Connection-Id', connectionId);
|
xhr.setRequestHeader('OV-Connection-Id', btoa(connectionId));
|
||||||
xhr.setRequestHeader('OV-Session-Id', sessionId);
|
xhr.setRequestHeader('OV-Session-Id', btoa(sessionId));
|
||||||
|
xhr.setRequestHeader('OV-Token', btoa(token));
|
||||||
}
|
}
|
||||||
|
|
||||||
const customAppender: any = JL.createAjaxAppender("openvidu-browser-logs-appender-" + connectionId);
|
const customAppender: any = JL.createAjaxAppender("openvidu-browser-logs-appender-" + connectionId);
|
||||||
customAppender.setOptions({
|
customAppender.setOptions({
|
||||||
beforeSend: openViduJSNLogHeaders,
|
beforeSend: openViduJSNLogHeaders,
|
||||||
batchSize: this.instance.MAX_JSNLOG_BATCH_LOG_MESSAGES,
|
|
||||||
maxBatchSize: 1000,
|
maxBatchSize: 1000,
|
||||||
|
batchSize: this.instance.MAX_JSNLOG_BATCH_LOG_MESSAGES,
|
||||||
batchTimeout: this.instance.MAX_MSECONDS_BATCH_MESSAGES
|
batchTimeout: this.instance.MAX_MSECONDS_BATCH_MESSAGES
|
||||||
});
|
});
|
||||||
|
this.instance.customAppenders.push(customAppender);
|
||||||
|
|
||||||
// Avoid circular dependencies
|
// Avoid circular dependencies
|
||||||
const logSerializer = (obj): string => {
|
const logSerializer = (obj): string => {
|
||||||
|
@ -94,7 +97,7 @@ export class OpenViduLogger {
|
||||||
if (!this.isProdMode) {
|
if (!this.isProdMode) {
|
||||||
this.LOG_FNS[0].apply(this.logger, arguments);
|
this.LOG_FNS[0].apply(this.logger, arguments);
|
||||||
}
|
}
|
||||||
if (this.isMonitoringLogEnabled()) {
|
if (this.isDebugLogEnabled()) {
|
||||||
JL().info(arguments);
|
JL().info(arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +106,7 @@ export class OpenViduLogger {
|
||||||
if (!this.isProdMode) {
|
if (!this.isProdMode) {
|
||||||
this.LOG_FNS[1].apply(this.logger, arguments);
|
this.LOG_FNS[1].apply(this.logger, arguments);
|
||||||
}
|
}
|
||||||
if (this.isMonitoringLogEnabled()) {
|
if (this.isDebugLogEnabled()) {
|
||||||
JL().debug(arguments);
|
JL().debug(arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +115,7 @@ export class OpenViduLogger {
|
||||||
if (!this.isProdMode) {
|
if (!this.isProdMode) {
|
||||||
this.LOG_FNS[2].apply(this.logger, arguments);
|
this.LOG_FNS[2].apply(this.logger, arguments);
|
||||||
}
|
}
|
||||||
if (this.isMonitoringLogEnabled()) {
|
if (this.isDebugLogEnabled()) {
|
||||||
JL().info(arguments);
|
JL().info(arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,18 +124,26 @@ export class OpenViduLogger {
|
||||||
if (!this.isProdMode) {
|
if (!this.isProdMode) {
|
||||||
this.LOG_FNS[3].apply(this.logger, arguments);
|
this.LOG_FNS[3].apply(this.logger, arguments);
|
||||||
}
|
}
|
||||||
if (this.isMonitoringLogEnabled()) {
|
if (this.isDebugLogEnabled()) {
|
||||||
JL().warn(arguments);
|
JL().warn(arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error(...args: any[]) {
|
error(...args: any[]) {
|
||||||
this.LOG_FNS[4].apply(this.logger, arguments);
|
this.LOG_FNS[4].apply(this.logger, arguments);
|
||||||
if (this.isMonitoringLogEnabled()) {
|
if (this.isDebugLogEnabled()) {
|
||||||
JL().error(arguments);
|
JL().error(arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flush() {
|
||||||
|
if(this.isDebugLogEnabled()) {
|
||||||
|
for(const appender of this.customAppenders) {
|
||||||
|
if (appender.sendBatch) appender.sendBatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enableProdMode(){
|
enableProdMode(){
|
||||||
this.isProdMode = true;
|
this.isProdMode = true;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +152,7 @@ export class OpenViduLogger {
|
||||||
this.isJSNLogEnabled = false;
|
this.isJSNLogEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private isMonitoringLogEnabled() {
|
private isDebugLogEnabled() {
|
||||||
return this.isJSNLogEnabled && this.isJSNLogSetup;
|
return this.isJSNLogEnabled && this.isJSNLogSetup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
export enum OpenViduLoggerConfiguration {
|
||||||
|
disabled = 'disabled',
|
||||||
|
debug = 'debug'
|
||||||
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
{
|
{
|
||||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||||
|
"cli": {
|
||||||
|
"analytics": false
|
||||||
|
},
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"newProjectRoot": "projects",
|
"newProjectRoot": "projects",
|
||||||
"projects": {
|
"projects": {
|
||||||
|
|
|
@ -13892,13 +13892,15 @@
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.1.tgz",
|
||||||
"integrity": "sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==",
|
"integrity": "sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"requires": {}
|
||||||
},
|
},
|
||||||
"ajv-keywords": {
|
"ajv-keywords": {
|
||||||
"version": "3.5.2",
|
"version": "3.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz",
|
"resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz",
|
||||||
"integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==",
|
"integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"requires": {}
|
||||||
},
|
},
|
||||||
"amdefine": {
|
"amdefine": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
|
@ -14927,7 +14929,8 @@
|
||||||
"version": "5.2.0",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/circular-dependency-plugin/-/circular-dependency-plugin-5.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/circular-dependency-plugin/-/circular-dependency-plugin-5.2.0.tgz",
|
||||||
"integrity": "sha512-7p4Kn/gffhQaavNfyDFg7LS5S/UT1JAjyGd4UqR2+jzoYF02eDkj0Ec3+48TsIa4zghjLY87nQHIh/ecK9qLdw==",
|
"integrity": "sha512-7p4Kn/gffhQaavNfyDFg7LS5S/UT1JAjyGd4UqR2+jzoYF02eDkj0Ec3+48TsIa4zghjLY87nQHIh/ecK9qLdw==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"requires": {}
|
||||||
},
|
},
|
||||||
"class-utils": {
|
"class-utils": {
|
||||||
"version": "0.3.6",
|
"version": "0.3.6",
|
||||||
|
|
Loading…
Reference in New Issue