@deephaven/log
Advanced tools
Comparing version 0.5.2-beta.0 to 0.6.0
@@ -1,18 +0,3 @@ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
import Logger from './Logger'; | ||
import LoggerLevel, { DEBUG2, INFO, SILENT } from './LoggerLevel'; | ||
import Logger from "./Logger.js"; | ||
import LoggerLevel, { DEBUG2, INFO, SILENT } from "./LoggerLevel.js"; | ||
/** | ||
@@ -26,46 +11,59 @@ * Get the default log level to use. | ||
*/ | ||
function getDefaultLevel() { | ||
var envValue = process.env.DEEPHAVEN_LOG_LEVEL; | ||
if (envValue && LoggerLevel[envValue]) { | ||
return LoggerLevel[envValue]; | ||
var envValue = process.env.DEEPHAVEN_LOG_LEVEL; | ||
if (envValue && LoggerLevel[envValue]) { | ||
return LoggerLevel[envValue]; | ||
} | ||
var envLevel = parseInt(envValue !== null && envValue !== void 0 ? envValue : '', 10); | ||
if (!Number.isNaN(envLevel)) { | ||
return envLevel; | ||
} | ||
if (process.env.NODE_ENV === 'test') { | ||
return SILENT; | ||
} | ||
if (process.env.NODE_ENV === 'development') { | ||
return DEBUG2; | ||
} | ||
return INFO; | ||
} | ||
class DefaultLogger extends Logger { | ||
constructor() { | ||
var level = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getDefaultLevel(); | ||
super(null, level); | ||
this.modules = {}; | ||
} | ||
module(name) { | ||
if (!this.modules[name]) { | ||
this.modules[name] = new Logger(name, this.level); | ||
} | ||
var envLevel = parseInt(envValue !== null && envValue !== void 0 ? envValue : '', 10); | ||
if (!Number.isNaN(envLevel)) { | ||
return envLevel; | ||
return this.modules[name]; | ||
} | ||
setLogLevel(level) { | ||
super.setLogLevel(level); | ||
if (!this.modules) { | ||
return; | ||
} | ||
if (process.env.NODE_ENV === 'test') { | ||
return SILENT; | ||
var keys = Object.keys(this.modules); | ||
for (var i = 0; i < keys.length; i += 1) { | ||
this.modules[keys[i]].setLogLevel(level); | ||
} | ||
if (process.env.NODE_ENV === 'development') { | ||
return DEBUG2; | ||
} | ||
return INFO; | ||
} | ||
} | ||
var DefaultLogger = /** @class */ (function (_super) { | ||
__extends(DefaultLogger, _super); | ||
function DefaultLogger(level) { | ||
if (level === void 0) { level = getDefaultLevel(); } | ||
var _this = _super.call(this, null, level) || this; | ||
_this.modules = {}; | ||
return _this; | ||
} | ||
DefaultLogger.prototype.module = function (name) { | ||
if (!this.modules[name]) { | ||
this.modules[name] = new Logger(name, this.level); | ||
} | ||
return this.modules[name]; | ||
}; | ||
DefaultLogger.prototype.setLogLevel = function (level) { | ||
_super.prototype.setLogLevel.call(this, level); | ||
if (!this.modules) { | ||
return; | ||
} | ||
var keys = Object.keys(this.modules); | ||
for (var i = 0; i < keys.length; i += 1) { | ||
this.modules[keys[i]].setLogLevel(level); | ||
} | ||
}; | ||
return DefaultLogger; | ||
}(Logger)); | ||
export default DefaultLogger; | ||
//# sourceMappingURL=DefaultLogger.js.map |
@@ -1,7 +0,7 @@ | ||
export { default as Logger } from './Logger'; | ||
export { default as Log } from './Log'; | ||
export { default as LogHistory } from './LogHistory'; | ||
export { default as LogProxy } from './LogProxy'; | ||
export { default as LoggerLevel } from './LoggerLevel'; | ||
export { default } from './Log'; | ||
export { default as Logger } from "./Logger.js"; | ||
export { default as Log } from "./Log.js"; | ||
export { default as LogHistory } from "./LogHistory.js"; | ||
export { default as LogProxy } from "./LogProxy.js"; | ||
export { default as LoggerLevel } from "./LoggerLevel.js"; | ||
export { default } from "./Log.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,4 @@ | ||
import DefaultLogger from './DefaultLogger'; | ||
import DefaultLogger from "./DefaultLogger.js"; | ||
var Log = new DefaultLogger(); | ||
export default Log; | ||
//# sourceMappingURL=Log.js.map |
/* eslint no-console: "off" */ | ||
import { ERROR, WARN, INFO, DEBUG, DEBUG2 } from './LoggerLevel'; | ||
var silent = function () { }; | ||
var Logger = /** @class */ (function () { | ||
function Logger(name, level) { | ||
this.name = name; | ||
this.prefix = name ? "[" + name + "]" : ""; | ||
this.setLogLevel(level); | ||
} | ||
Logger.prototype.setLogLevel = function (level) { | ||
this.level = level; | ||
this.error = | ||
ERROR <= level ? console.error.bind(console, this.prefix) : silent; | ||
this.warn = | ||
WARN <= level ? console.warn.bind(console, this.prefix) : silent; | ||
this.log = INFO <= level ? console.log.bind(console, this.prefix) : silent; | ||
this.info = this.log; | ||
this.debug = | ||
DEBUG <= level ? console.debug.bind(console, this.prefix) : silent; | ||
this.debug2 = | ||
DEBUG2 <= level ? console.debug.bind(console, this.prefix) : silent; | ||
}; | ||
return Logger; | ||
}()); | ||
import { ERROR, WARN, INFO, DEBUG, DEBUG2 } from "./LoggerLevel.js"; | ||
var silent = () => {}; | ||
class Logger { | ||
constructor(name, level) { | ||
this.name = name; | ||
this.prefix = name ? "[".concat(name, "]") : ""; | ||
this.setLogLevel(level); | ||
} | ||
setLogLevel(level) { | ||
this.level = level; | ||
this.error = ERROR <= level ? console.error.bind(console, this.prefix) : silent; | ||
this.warn = WARN <= level ? console.warn.bind(console, this.prefix) : silent; | ||
this.log = INFO <= level ? console.log.bind(console, this.prefix) : silent; | ||
this.info = this.log; | ||
this.debug = DEBUG <= level ? console.debug.bind(console, this.prefix) : silent; | ||
this.debug2 = DEBUG2 <= level ? console.debug.bind(console, this.prefix) : silent; | ||
} | ||
} | ||
export default Logger; | ||
//# sourceMappingURL=Logger.js.map |
@@ -8,9 +8,9 @@ export var SILENT = -1; | ||
export default Object.freeze({ | ||
SILENT: SILENT, | ||
ERROR: ERROR, | ||
WARN: WARN, | ||
INFO: INFO, | ||
DEBUG: DEBUG, | ||
DEBUG2: DEBUG2, | ||
SILENT, | ||
ERROR, | ||
WARN, | ||
INFO, | ||
DEBUG, | ||
DEBUG2 | ||
}); | ||
//# sourceMappingURL=LoggerLevel.js.map |
@@ -1,140 +0,175 @@ | ||
import { LOG_PROXY_TYPE } from './LogProxy'; | ||
var LogHistory = /** @class */ (function () { | ||
function LogHistory(proxy) { | ||
this.history = []; | ||
this.offset = 0; | ||
this.limit = 10000; | ||
this.isEnabled = false; | ||
this.proxy = proxy; | ||
this.addHistory = this.addHistory.bind(this); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import { LOG_PROXY_TYPE } from "./LogProxy.js"; | ||
class LogHistory { | ||
/** | ||
* Formats log arguments on separate lines | ||
* Attempts to stringify objects | ||
* @param messages - The messages/params sent to the log call | ||
*/ | ||
static formatMessages(messages) { | ||
var formatted = messages.map(m => { | ||
if (typeof m === 'string') { | ||
return m; | ||
} // Some objects don't stringify nicely, so give some info about the object | ||
var jsonString = ''; | ||
try { | ||
jsonString = JSON.stringify(m); | ||
} catch (e) { | ||
jsonString = m.toString(); | ||
} | ||
return jsonString === '{}' ? m.toString() : jsonString; | ||
}); | ||
return formatted.join('\t'); | ||
} | ||
/** | ||
* Formats stack traces to a string with each frame on its own line and indented 1 level | ||
* @param stack - Stack trace generated in the console | ||
* @param type - Log type (e.g. log, warn, error) | ||
*/ | ||
static formatStack() { | ||
var stack = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
var type = arguments.length > 1 ? arguments[1] : undefined; | ||
if (stack === '') { | ||
return ''; | ||
} // Some browsers will add a top frame which is just 'Error', some won't | ||
// We will always add at least 2 frames. 1 creating the error and 1 calling addHistory | ||
// On error (logger.error) we add a 3rd frame which is overriding console.error | ||
// For uncaught errors the 3rd frame is not added | ||
var stringStack = stack.split('\n').map(line => line.trim()); | ||
switch (type) { | ||
case LOG_PROXY_TYPE.ERROR: | ||
stringStack = stringStack.splice(stack[0] === 'Error' ? 4 : 3); | ||
break; | ||
case LOG_PROXY_TYPE.UNCAUGHT_ERROR: | ||
stringStack = stringStack.splice(stack[0] === 'Error' ? 3 : 2); | ||
break; | ||
default: | ||
break; | ||
} | ||
/** | ||
* Formats log arguments on separate lines | ||
* Attempts to stringify objects | ||
* @param messages - The messages/params sent to the log call | ||
*/ | ||
LogHistory.formatMessages = function (messages) { | ||
var formatted = messages.map(function (m) { | ||
if (typeof m === 'string') { | ||
return m; | ||
} | ||
// Some objects don't stringify nicely, so give some info about the object | ||
var jsonString = ''; | ||
try { | ||
jsonString = JSON.stringify(m); | ||
} | ||
catch (e) { | ||
jsonString = m.toString(); | ||
} | ||
return jsonString === '{}' | ||
? m.toString() | ||
: jsonString; | ||
}); | ||
return formatted.join('\t'); | ||
return stringStack ? "\t".concat(stringStack.join('\n\t')) : ''; | ||
} | ||
constructor(proxy) { | ||
_defineProperty(this, "history", void 0); | ||
_defineProperty(this, "offset", void 0); | ||
_defineProperty(this, "limit", void 0); | ||
_defineProperty(this, "isEnabled", void 0); | ||
_defineProperty(this, "proxy", void 0); | ||
this.history = []; | ||
this.offset = 0; | ||
this.limit = 10000; | ||
this.isEnabled = false; | ||
this.proxy = proxy; | ||
this.addHistory = this.addHistory.bind(this); | ||
} | ||
enable() { | ||
if (this.isEnabled) { | ||
return; | ||
} | ||
this.proxy.addEventListener(LOG_PROXY_TYPE.DEBUG, this.addHistory); | ||
this.proxy.addEventListener(LOG_PROXY_TYPE.LOG, this.addHistory); | ||
this.proxy.addEventListener(LOG_PROXY_TYPE.WARN, this.addHistory); | ||
this.proxy.addEventListener(LOG_PROXY_TYPE.ERROR, this.addHistory); | ||
this.proxy.addEventListener(LOG_PROXY_TYPE.UNCAUGHT_ERROR, this.addHistory); | ||
this.isEnabled = true; | ||
} | ||
disable() { | ||
if (!this.isEnabled) { | ||
return; | ||
} | ||
this.proxy.removeEventListener(LOG_PROXY_TYPE.DEBUG, this.addHistory); | ||
this.proxy.removeEventListener(LOG_PROXY_TYPE.LOG, this.addHistory); | ||
this.proxy.removeEventListener(LOG_PROXY_TYPE.WARN, this.addHistory); | ||
this.proxy.removeEventListener(LOG_PROXY_TYPE.ERROR, this.addHistory); | ||
this.proxy.removeEventListener(LOG_PROXY_TYPE.UNCAUGHT_ERROR, this.addHistory); | ||
this.isEnabled = false; | ||
} | ||
/** | ||
* Adds a call to a console method to the history. | ||
* @param type - The level of the message to add | ||
* @param messages - The parameters passed to the console method | ||
*/ | ||
addHistory(_ref) { | ||
var { | ||
type, | ||
detail | ||
} = _ref; | ||
var logItem = { | ||
type: type, | ||
messages: detail, | ||
time: new Date() | ||
}; | ||
/** | ||
* Formats stack traces to a string with each frame on its own line and indented 1 level | ||
* @param stack - Stack trace generated in the console | ||
* @param type - Log type (e.g. log, warn, error) | ||
*/ | ||
LogHistory.formatStack = function (stack, type) { | ||
if (stack === void 0) { stack = ''; } | ||
if (stack === '') { | ||
return ''; | ||
} | ||
// Some browsers will add a top frame which is just 'Error', some won't | ||
// We will always add at least 2 frames. 1 creating the error and 1 calling addHistory | ||
// On error (logger.error) we add a 3rd frame which is overriding console.error | ||
// For uncaught errors the 3rd frame is not added | ||
var stringStack = stack.split('\n').map(function (line) { return line.trim(); }); | ||
switch (type) { | ||
case LOG_PROXY_TYPE.ERROR: | ||
stringStack = stringStack.splice(stack[0] === 'Error' ? 4 : 3); | ||
break; | ||
case LOG_PROXY_TYPE.UNCAUGHT_ERROR: | ||
stringStack = stringStack.splice(stack[0] === 'Error' ? 3 : 2); | ||
break; | ||
default: | ||
break; | ||
} | ||
return stringStack ? "\t" + stringStack.join('\n\t') : ''; | ||
}; | ||
LogHistory.prototype.enable = function () { | ||
if (this.isEnabled) { | ||
return; | ||
} | ||
this.proxy.addEventListener(LOG_PROXY_TYPE.DEBUG, this.addHistory); | ||
this.proxy.addEventListener(LOG_PROXY_TYPE.LOG, this.addHistory); | ||
this.proxy.addEventListener(LOG_PROXY_TYPE.WARN, this.addHistory); | ||
this.proxy.addEventListener(LOG_PROXY_TYPE.ERROR, this.addHistory); | ||
this.proxy.addEventListener(LOG_PROXY_TYPE.UNCAUGHT_ERROR, this.addHistory); | ||
this.isEnabled = true; | ||
}; | ||
LogHistory.prototype.disable = function () { | ||
if (!this.isEnabled) { | ||
return; | ||
} | ||
this.proxy.removeEventListener(LOG_PROXY_TYPE.DEBUG, this.addHistory); | ||
this.proxy.removeEventListener(LOG_PROXY_TYPE.LOG, this.addHistory); | ||
this.proxy.removeEventListener(LOG_PROXY_TYPE.WARN, this.addHistory); | ||
this.proxy.removeEventListener(LOG_PROXY_TYPE.ERROR, this.addHistory); | ||
this.proxy.removeEventListener(LOG_PROXY_TYPE.UNCAUGHT_ERROR, this.addHistory); | ||
this.isEnabled = false; | ||
}; | ||
/** | ||
* Adds a call to a console method to the history. | ||
* @param type - The level of the message to add | ||
* @param messages - The parameters passed to the console method | ||
*/ | ||
LogHistory.prototype.addHistory = function (_a) { | ||
var type = _a.type, detail = _a.detail; | ||
var logItem = { | ||
type: type, | ||
messages: detail, | ||
time: new Date(), | ||
}; | ||
switch (type) { | ||
// Some browsers will add a top frame which is just 'Error', some won't | ||
// We will always add at least 2 frames. 1 creating the error and 1 calling addHistory | ||
// On error (logger.error) we add a 3rd frame which is overriding console.error | ||
// For uncaught errors the 3rd frame is not added | ||
case LOG_PROXY_TYPE.ERROR: | ||
case LOG_PROXY_TYPE.UNCAUGHT_ERROR: | ||
logItem.stack = Error().stack; | ||
break; | ||
default: | ||
break; | ||
} | ||
this.history[this.offset % this.limit] = logItem; | ||
this.offset += 1; | ||
}; | ||
/** | ||
* Gets LogHistory object | ||
*/ | ||
LogHistory.prototype.getHistory = function () { | ||
if (this.offset > this.limit) { | ||
// Wrapped past the limit, get oldest -> end and concat start -> newest | ||
var startIdx = this.offset % this.limit; | ||
this.history = this.history | ||
.slice(startIdx) | ||
.concat(this.history.slice(0, startIdx)); | ||
this.offset = this.limit; | ||
} | ||
return this.history; | ||
}; | ||
/** | ||
* Gets the history formatted as a string so it can easily be exported to a txt file | ||
*/ | ||
LogHistory.prototype.getFormattedHistory = function () { | ||
var historyString = this.getHistory().map(function (item) { | ||
// eslint-disable-next-line prefer-template | ||
return item.time.toISOString() + " " + item.type + "\t" + | ||
("" + LogHistory.formatMessages(item.messages)) + | ||
(item.stack ? "\n" + LogHistory.formatStack(item.stack, item.type) : ''); | ||
}); | ||
return historyString.join('\n'); | ||
}; | ||
return LogHistory; | ||
}()); | ||
switch (type) { | ||
// Some browsers will add a top frame which is just 'Error', some won't | ||
// We will always add at least 2 frames. 1 creating the error and 1 calling addHistory | ||
// On error (logger.error) we add a 3rd frame which is overriding console.error | ||
// For uncaught errors the 3rd frame is not added | ||
case LOG_PROXY_TYPE.ERROR: | ||
case LOG_PROXY_TYPE.UNCAUGHT_ERROR: | ||
logItem.stack = Error().stack; | ||
break; | ||
default: | ||
break; | ||
} | ||
this.history[this.offset % this.limit] = logItem; | ||
this.offset += 1; | ||
} | ||
/** | ||
* Gets LogHistory object | ||
*/ | ||
getHistory() { | ||
if (this.offset > this.limit) { | ||
// Wrapped past the limit, get oldest -> end and concat start -> newest | ||
var startIdx = this.offset % this.limit; | ||
this.history = this.history.slice(startIdx).concat(this.history.slice(0, startIdx)); | ||
this.offset = this.limit; | ||
} | ||
return this.history; | ||
} | ||
/** | ||
* Gets the history formatted as a string so it can easily be exported to a txt file | ||
*/ | ||
getFormattedHistory() { | ||
var historyString = this.getHistory().map(item => // eslint-disable-next-line prefer-template | ||
"".concat(item.time.toISOString(), " ").concat(item.type, "\t") + "".concat(LogHistory.formatMessages(item.messages)) + (item.stack ? "\n".concat(LogHistory.formatStack(item.stack, item.type)) : '')); | ||
return historyString.join('\n'); | ||
} | ||
} | ||
export default LogHistory; | ||
//# sourceMappingURL=LogHistory.js.map |
@@ -1,2 +0,1 @@ | ||
import 'custom-event-polyfill'; | ||
export declare enum LOG_PROXY_TYPE { | ||
@@ -3,0 +2,0 @@ DEBUG = "D", |
@@ -0,104 +1,135 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
/* eslint-disable no-console */ | ||
// eslint-disable-next-line max-classes-per-file | ||
import { EventTarget } from 'event-target-shim'; | ||
import 'custom-event-polyfill'; | ||
import Log from './Log'; | ||
export var LOG_PROXY_TYPE; | ||
import Log from "./Log.js"; | ||
export var LOG_PROXY_TYPE; // We need to cast our CustomEvent so it's happy with event-target-shim | ||
(function (LOG_PROXY_TYPE) { | ||
LOG_PROXY_TYPE["DEBUG"] = "D"; | ||
LOG_PROXY_TYPE["LOG"] = "L"; | ||
LOG_PROXY_TYPE["WARN"] = "W"; | ||
LOG_PROXY_TYPE["ERROR"] = "E"; | ||
LOG_PROXY_TYPE["UNCAUGHT_ERROR"] = "U"; | ||
LOG_PROXY_TYPE["DEBUG"] = "D"; | ||
LOG_PROXY_TYPE["LOG"] = "L"; | ||
LOG_PROXY_TYPE["WARN"] = "W"; | ||
LOG_PROXY_TYPE["ERROR"] = "E"; | ||
LOG_PROXY_TYPE["UNCAUGHT_ERROR"] = "U"; | ||
})(LOG_PROXY_TYPE || (LOG_PROXY_TYPE = {})); | ||
function makeEvent(type, detail) { | ||
return new CustomEvent(type, { | ||
detail: detail, | ||
return new CustomEvent(type, { | ||
detail | ||
}); | ||
} | ||
export class LogProxy { | ||
constructor() { | ||
_defineProperty(this, "isEnabled", false); | ||
_defineProperty(this, "debug", void 0); | ||
_defineProperty(this, "log", void 0); | ||
_defineProperty(this, "warn", void 0); | ||
_defineProperty(this, "error", void 0); | ||
_defineProperty(this, "eventTarget", void 0); | ||
_defineProperty(this, "handleUncaughtError", event => { | ||
var messages = []; | ||
if (event.error) { | ||
messages.push(event.error); | ||
} | ||
if (event.message) { | ||
messages.push(event.message); | ||
} | ||
this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.UNCAUGHT_ERROR, messages)); | ||
}); | ||
} | ||
var LogProxy = /** @class */ (function () { | ||
function LogProxy() { | ||
var _this = this; | ||
this.isEnabled = false; | ||
this.handleUncaughtError = function (event) { | ||
var messages = []; | ||
if (event.error) { | ||
messages.push(event.error); | ||
} | ||
if (event.message) { | ||
messages.push(event.message); | ||
} | ||
_this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.UNCAUGHT_ERROR, messages)); | ||
}; | ||
this.debug = console.debug; | ||
this.log = console.log; | ||
this.warn = console.warn; | ||
this.error = console.error; | ||
this.eventTarget = new EventTarget(); | ||
this.debug = console.debug; | ||
this.log = console.log; | ||
this.warn = console.warn; | ||
this.error = console.error; | ||
this.eventTarget = new EventTarget(); | ||
} | ||
enable() { | ||
var _this = this; | ||
if (this.isEnabled) { | ||
return; | ||
} | ||
LogProxy.prototype.enable = function () { | ||
var _this = this; | ||
if (this.isEnabled) { | ||
return; | ||
} | ||
console.debug = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
_this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.DEBUG, args)); | ||
_this.debug.apply(console, args); | ||
}; | ||
console.log = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
_this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.LOG, args)); | ||
_this.log.apply(console, args); | ||
}; | ||
console.warn = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
_this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.WARN, args)); | ||
_this.warn.apply(console, args); | ||
}; | ||
console.error = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
_this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.ERROR, args)); | ||
_this.error.apply(console, args); | ||
}; | ||
window.addEventListener('error', this.handleUncaughtError); | ||
// This forces logger to update its reference to the overriding functions instead of the original | ||
Log.setLogLevel(Log.level); | ||
this.isEnabled = true; | ||
console.debug = function () { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.DEBUG, args)); | ||
_this.debug.apply(console, args); | ||
}; | ||
LogProxy.prototype.disable = function () { | ||
if (!this.isEnabled) { | ||
return; | ||
} | ||
console.debug = this.debug; | ||
console.log = this.log; | ||
console.warn = this.warn; | ||
console.error = this.error; | ||
window.removeEventListener('error', this.handleUncaughtError); | ||
Log.setLogLevel(Log.level); | ||
this.isEnabled = false; | ||
console.log = function () { | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
_this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.LOG, args)); | ||
_this.log.apply(console, args); | ||
}; | ||
LogProxy.prototype.addEventListener = function (type, listener) { | ||
// The cast as EventListener is a dumb TypeScript issue | ||
this.eventTarget.addEventListener(type, listener); | ||
console.warn = function () { | ||
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
} | ||
_this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.WARN, args)); | ||
_this.warn.apply(console, args); | ||
}; | ||
LogProxy.prototype.removeEventListener = function (type, listener) { | ||
this.eventTarget.removeEventListener(type, listener); | ||
console.error = function () { | ||
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { | ||
args[_key4] = arguments[_key4]; | ||
} | ||
_this.eventTarget.dispatchEvent(makeEvent(LOG_PROXY_TYPE.ERROR, args)); | ||
_this.error.apply(console, args); | ||
}; | ||
return LogProxy; | ||
}()); | ||
export { LogProxy }; | ||
window.addEventListener('error', this.handleUncaughtError); // This forces logger to update its reference to the overriding functions instead of the original | ||
Log.setLogLevel(Log.level); | ||
this.isEnabled = true; | ||
} | ||
disable() { | ||
if (!this.isEnabled) { | ||
return; | ||
} | ||
console.debug = this.debug; | ||
console.log = this.log; | ||
console.warn = this.warn; | ||
console.error = this.error; | ||
window.removeEventListener('error', this.handleUncaughtError); | ||
Log.setLogLevel(Log.level); | ||
this.isEnabled = false; | ||
} | ||
addEventListener(type, listener) { | ||
// The cast as EventListener is a dumb TypeScript issue | ||
this.eventTarget.addEventListener(type, listener); | ||
} | ||
removeEventListener(type, listener) { | ||
this.eventTarget.removeEventListener(type, listener); | ||
} | ||
} | ||
export default LogProxy; | ||
//# sourceMappingURL=LogProxy.js.map |
{ | ||
"name": "@deephaven/log", | ||
"version": "0.5.2-beta.0+0936be9", | ||
"version": "0.6.0", | ||
"description": "Deephaven Logger", | ||
"author": "Deephaven Data Labs LLC", | ||
"license": "Apache-2.0", | ||
"type": "module", | ||
"repository": { | ||
@@ -36,2 +37,3 @@ "type": "git", | ||
"@babel/cli": "^7.14.8", | ||
"@deephaven/tsconfig": "^0.4.0", | ||
"@types/lodash.clamp": "^4.0.6", | ||
@@ -55,6 +57,5 @@ "@types/prop-types": "^15.7.3", | ||
"dependencies": { | ||
"custom-event-polyfill": "^1.0.7", | ||
"event-target-shim": "^6.0.2" | ||
}, | ||
"gitHead": "0936be95c2308353398af459d9e661a733f1ffde" | ||
"gitHead": "126e214ebbfe40b45113349c66913c65fc2236fd" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
92357
1
0
Yes
12
441
- Removedcustom-event-polyfill@^1.0.7
- Removedcustom-event-polyfill@1.0.7(transitive)