Skip to content

Commit

Permalink
fix(FEC-11138): Remove player logs from console (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Ziv committed Apr 12, 2021
1 parent 04c9a6a commit 3231556
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions src/broadpeak.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
// @flow
import {KalturaPlayer, BasePlugin, core} from 'kaltura-player-js';
import {SmartLib} from '@broadpeak/smartlib-v3';
import {LoggerManager} from '@broadpeak/smartlib-v3';
import {BPEngineDecorator} from './bp-engine-decorator';
import {BPMiddleware} from './bp-middleware';

const {BaseMiddleware, Utils} = core;
const {BaseMiddleware, Utils, LogLevel} = core;
const BroadPeakLogLevel: {[level: string]: number} = {
OFF: -1,
INFO: 0,
DEBUG: 1
};

LoggerManager.getInstance().setLogLevel(BroadPeakLogLevel.OFF);

/**
* The BroadPeak plugin.
* @class BroadPeak
Expand Down Expand Up @@ -88,9 +97,8 @@ class BroadPeak extends BasePlugin {

constructor(name: string, player: KalturaPlayer, config: Object) {
super(name, player, config);
this.eventManager.listen(this.player, this.player.Event.Core.ERROR, () => {
this.reset();
});
this._setLogLevel();
this.eventManager.listen(this.player, this.player.Event.Core.ERROR, () => this.reset());
this._attachSourceChange();
SmartLib.getInstance().init(this.config.analyticsAddress, this.config.nanoCDNHost, this.config.broadpeakDomainNames);
}
Expand Down Expand Up @@ -129,6 +137,25 @@ class BroadPeak extends BasePlugin {
SmartLib.getInstance().release();
}

_setLogLevel(): void {
const playerLogLevel = Utils.Object.getPropertyPath(this.player, 'config.log.level');
switch (playerLogLevel) {
case LogLevel.ERROR.name:
case LogLevel.OFF.name:
LoggerManager.getInstance().setLogLevel(BroadPeakLogLevel.OFF);
break;
case LogLevel.DEBUG.name:
LoggerManager.getInstance().setLogLevel(BroadPeakLogLevel.DEBUG);
break;
case LogLevel.TIME.name:
case LogLevel.WARN.name:
case LogLevel.INFO.name:
default:
LoggerManager.getInstance().setLogLevel(BroadPeakLogLevel.INFO);
break;
}
}

_attachSourceChange() {
this.eventManager.listen(this.player, this.player.Event.Core.SOURCE_SELECTED, event => {
this._srcPromise = Utils.Object.defer();
Expand Down

0 comments on commit 3231556

Please sign in to comment.