xgplayer-streaming-shared
Advanced tools
Comparing version 3.0.0-next.21 to 3.0.0-next.22
@@ -1,20 +0,8 @@ | ||
export namespace LogLevel { | ||
const DEBUG: number; | ||
const INFO: number; | ||
const WARN: number; | ||
const ERROR: number; | ||
} | ||
export class Logger { | ||
static getLogCache(): string; | ||
static logTextArray: any[]; | ||
static disabled: boolean; | ||
static logSize: number; | ||
static enable(): void; | ||
static disable(): void; | ||
static setLogLevel(val: any): void; | ||
constructor(name: any, config: any); | ||
constructor(name: any); | ||
name: any; | ||
_prefix: string; | ||
logLevel: any; | ||
logMaxSize: any; | ||
debug(...args: any[]): void; | ||
@@ -24,4 +12,3 @@ log(...args: any[]): void; | ||
error(...args: any[]): void; | ||
logCache(logLevel: any, ...logText: any[]): void; | ||
table(...args: any[]): void; | ||
} |
import { defineProperty as _defineProperty, createClass as _createClass, classCallCheck as _classCallCheck } from "./_virtual/_rollupPluginBabelHelpers.js"; | ||
import "core-js/modules/es.function.name.js"; | ||
import "core-js/modules/es.array.concat.js"; | ||
import "core-js/modules/es.json.stringify.js"; | ||
import "core-js/modules/es.array.join.js"; | ||
var LogLevel = { | ||
"DEBUG": 1, | ||
"INFO": 2, | ||
"WARN": 3, | ||
"ERROR": 4 | ||
}; | ||
var LOG_MAX_SIZE = 5 * 1024; | ||
import { nowTime } from "./utils.js"; | ||
var Logger = /* @__PURE__ */ function() { | ||
function Logger2(name, config) { | ||
function Logger2(name) { | ||
_classCallCheck(this, Logger2); | ||
this.name = name || ""; | ||
this._prefix = "[".concat(this.name, "]"); | ||
Logger2.disabled = (config === null || config === void 0 ? void 0 : config.disabled) || true; | ||
this.logLevel = (config === null || config === void 0 ? void 0 : config.logLevel) || LogLevel.ERROR; | ||
this.logMaxSize = (config === null || config === void 0 ? void 0 : config.logMaxSize) || LOG_MAX_SIZE; | ||
} | ||
@@ -26,8 +15,7 @@ _createClass(Logger2, [{ | ||
var _console; | ||
if (Logger2.disabled) | ||
return; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
this.logCache.apply(this, [LogLevel.DEBUG].concat(args)); | ||
if (Logger2.disabled) | ||
return; | ||
(_console = console).debug.apply(_console, [this._prefix, nowTime()].concat(args)); | ||
@@ -39,8 +27,7 @@ } | ||
var _console2; | ||
if (Logger2.disabled) | ||
return; | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
this.logCache.apply(this, [LogLevel.INFO].concat(args)); | ||
if (Logger2.disabled) | ||
return; | ||
(_console2 = console).log.apply(_console2, [this._prefix, nowTime()].concat(args)); | ||
@@ -52,8 +39,7 @@ } | ||
var _console3; | ||
if (Logger2.disabled) | ||
return; | ||
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
} | ||
this.logCache.apply(this, [LogLevel.WARN].concat(args)); | ||
if (Logger2.disabled) | ||
return; | ||
(_console3 = console).warn.apply(_console3, [this._prefix, nowTime()].concat(args)); | ||
@@ -65,26 +51,10 @@ } | ||
var _console4; | ||
if (Logger2.disabled) | ||
return; | ||
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { | ||
args[_key4] = arguments[_key4]; | ||
} | ||
this.logCache.apply(this, [LogLevel.ERROR].concat(args)); | ||
if (Logger2.disabled) | ||
return; | ||
(_console4 = console).error.apply(_console4, [this._prefix, nowTime()].concat(args)); | ||
} | ||
}, { | ||
key: "logCache", | ||
value: function logCache(logLevel) { | ||
for (var _len5 = arguments.length, logText = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) { | ||
logText[_key5 - 1] = arguments[_key5]; | ||
} | ||
var text = this._prefix + nowTime() + JSON.stringify(logText); | ||
if (logLevel >= this.logLevel) { | ||
Logger2.logSize += text.length; | ||
Logger2.logTextArray.push(text); | ||
} | ||
if (Logger2.logSize > this.logMaxSize) { | ||
Logger2.logTextArray.shift(); | ||
} | ||
} | ||
}, { | ||
key: "table", | ||
@@ -100,9 +70,2 @@ value: function table() { | ||
}], [{ | ||
key: "getLogCache", | ||
value: function getLogCache() { | ||
var logText = this.logTextArray.join("\n"); | ||
this.logTextArray = []; | ||
return logText; | ||
} | ||
}, { | ||
key: "enable", | ||
@@ -117,7 +80,2 @@ value: function enable() { | ||
} | ||
}, { | ||
key: "setLogLevel", | ||
value: function setLogLevel(val) { | ||
Logger2.logLevel = val; | ||
} | ||
}]); | ||
@@ -127,7 +85,2 @@ return Logger2; | ||
_defineProperty(Logger, "disabled", true); | ||
_defineProperty(Logger, "logSize", 0); | ||
_defineProperty(Logger, "logTextArray", []); | ||
function nowTime() { | ||
return new Date().toLocaleString(); | ||
} | ||
export { LogLevel, Logger }; | ||
export { Logger }; |
{ | ||
"name": "xgplayer-streaming-shared", | ||
"version": "3.0.0-next.21", | ||
"version": "3.0.0-next.22", | ||
"main": "dist/index.min.js", | ||
@@ -5,0 +5,0 @@ "module": "es/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
810144
4563