UNPKG

@jxstjh/jhvideo

Version:

HTML5 jhvideo base on MPEG2-TS Stream Player

172 lines 5.77 kB
/* * Copyright (C) 2016 Bilibili. All Rights Reserved. * * @author zheng qian <xqq@xqq.im> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import EventEmitter from 'events'; import Log from './logger.js'; var LoggingControl = /** @class */ (function () { function LoggingControl() { } Object.defineProperty(LoggingControl, "forceGlobalTag", { get: function () { return Log.FORCE_GLOBAL_TAG; }, set: function (enable) { Log.FORCE_GLOBAL_TAG = enable; LoggingControl._notifyChange(); }, enumerable: false, configurable: true }); Object.defineProperty(LoggingControl, "globalTag", { get: function () { return Log.GLOBAL_TAG; }, set: function (tag) { Log.GLOBAL_TAG = tag; LoggingControl._notifyChange(); }, enumerable: false, configurable: true }); Object.defineProperty(LoggingControl, "enableAll", { get: function () { return Log.ENABLE_VERBOSE && Log.ENABLE_DEBUG && Log.ENABLE_INFO && Log.ENABLE_WARN && Log.ENABLE_ERROR; }, set: function (enable) { Log.ENABLE_VERBOSE = enable; Log.ENABLE_DEBUG = enable; Log.ENABLE_INFO = enable; Log.ENABLE_WARN = enable; Log.ENABLE_ERROR = enable; LoggingControl._notifyChange(); }, enumerable: false, configurable: true }); Object.defineProperty(LoggingControl, "enableDebug", { get: function () { return Log.ENABLE_DEBUG; }, set: function (enable) { Log.ENABLE_DEBUG = enable; LoggingControl._notifyChange(); }, enumerable: false, configurable: true }); Object.defineProperty(LoggingControl, "enableVerbose", { get: function () { return Log.ENABLE_VERBOSE; }, set: function (enable) { Log.ENABLE_VERBOSE = enable; LoggingControl._notifyChange(); }, enumerable: false, configurable: true }); Object.defineProperty(LoggingControl, "enableInfo", { get: function () { return Log.ENABLE_INFO; }, set: function (enable) { Log.ENABLE_INFO = enable; LoggingControl._notifyChange(); }, enumerable: false, configurable: true }); Object.defineProperty(LoggingControl, "enableWarn", { get: function () { return Log.ENABLE_WARN; }, set: function (enable) { Log.ENABLE_WARN = enable; LoggingControl._notifyChange(); }, enumerable: false, configurable: true }); Object.defineProperty(LoggingControl, "enableError", { get: function () { return Log.ENABLE_ERROR; }, set: function (enable) { Log.ENABLE_ERROR = enable; LoggingControl._notifyChange(); }, enumerable: false, configurable: true }); LoggingControl.getConfig = function () { return { globalTag: Log.GLOBAL_TAG, forceGlobalTag: Log.FORCE_GLOBAL_TAG, enableVerbose: Log.ENABLE_VERBOSE, enableDebug: Log.ENABLE_DEBUG, enableInfo: Log.ENABLE_INFO, enableWarn: Log.ENABLE_WARN, enableError: Log.ENABLE_ERROR, enableCallback: Log.ENABLE_CALLBACK }; }; LoggingControl.applyConfig = function (config) { Log.GLOBAL_TAG = config.globalTag; Log.FORCE_GLOBAL_TAG = config.forceGlobalTag; Log.ENABLE_VERBOSE = config.enableVerbose; Log.ENABLE_DEBUG = config.enableDebug; Log.ENABLE_INFO = config.enableInfo; Log.ENABLE_WARN = config.enableWarn; Log.ENABLE_ERROR = config.enableError; Log.ENABLE_CALLBACK = config.enableCallback; }; LoggingControl._notifyChange = function () { var emitter = LoggingControl.emitter; if (emitter.listenerCount('change') > 0) { var config = LoggingControl.getConfig(); emitter.emit('change', config); } }; LoggingControl.registerListener = function (listener) { LoggingControl.emitter.addListener('change', listener); }; LoggingControl.removeListener = function (listener) { LoggingControl.emitter.removeListener('change', listener); }; LoggingControl.addLogListener = function (listener) { Log.emitter.addListener('log', listener); if (Log.emitter.listenerCount('log') > 0) { Log.ENABLE_CALLBACK = true; LoggingControl._notifyChange(); } }; LoggingControl.removeLogListener = function (listener) { Log.emitter.removeListener('log', listener); if (Log.emitter.listenerCount('log') === 0) { Log.ENABLE_CALLBACK = false; LoggingControl._notifyChange(); } }; return LoggingControl; }()); LoggingControl.emitter = new EventEmitter(); export default LoggingControl; //# sourceMappingURL=logging-control.js.map