Beta 7 with some repo names changed.
This commit is contained in:
1 parent
0f7b40cca7
commit
963c19493a
3408 files changed
+462217
-15516
No files matched your search
+2
@@ -0,0 +1,2 @@
|
||||
export const version = "logger/5.0.6";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
+294
@@ -0,0 +1,294 @@
|
||||
"use strict";
|
||||
let _permanentCensorErrors = false;
|
||||
let _censorErrors = false;
|
||||
const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
|
||||
let _logLevel = LogLevels["default"];
|
||||
import { version } from "./_version";
|
||||
let _globalLogger = null;
|
||||
function _checkNormalize() {
|
||||
try {
|
||||
const missing = [];
|
||||
// Make sure all forms of normalization are supported
|
||||
["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => {
|
||||
try {
|
||||
if ("test".normalize(form) !== "test") {
|
||||
throw new Error("bad normalize");
|
||||
}
|
||||
;
|
||||
}
|
||||
catch (error) {
|
||||
missing.push(form);
|
||||
}
|
||||
});
|
||||
if (missing.length) {
|
||||
throw new Error("missing " + missing.join(", "));
|
||||
}
|
||||
if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
|
||||
throw new Error("broken implementation");
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
return error.message;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
const _normalizeError = _checkNormalize();
|
||||
export var LogLevel;
|
||||
(function (LogLevel) {
|
||||
LogLevel["DEBUG"] = "DEBUG";
|
||||
LogLevel["INFO"] = "INFO";
|
||||
LogLevel["WARNING"] = "WARNING";
|
||||
LogLevel["ERROR"] = "ERROR";
|
||||
LogLevel["OFF"] = "OFF";
|
||||
})(LogLevel || (LogLevel = {}));
|
||||
export var ErrorCode;
|
||||
(function (ErrorCode) {
|
||||
///////////////////
|
||||
// Generic Errors
|
||||
// Unknown Error
|
||||
ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
||||
// Not Implemented
|
||||
ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
|
||||
// Unsupported Operation
|
||||
// - operation
|
||||
ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
|
||||
// Network Error (i.e. Ethereum Network, such as an invalid chain ID)
|
||||
// - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
|
||||
ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
|
||||
// Some sort of bad response from the server
|
||||
ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
|
||||
// Timeout
|
||||
ErrorCode["TIMEOUT"] = "TIMEOUT";
|
||||
///////////////////
|
||||
// Operational Errors
|
||||
// Buffer Overrun
|
||||
ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
|
||||
// Numeric Fault
|
||||
// - operation: the operation being executed
|
||||
// - fault: the reason this faulted
|
||||
ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
|
||||
///////////////////
|
||||
// Argument Errors
|
||||
// Missing new operator to an object
|
||||
// - name: The name of the class
|
||||
ErrorCode["MISSING_NEW"] = "MISSING_NEW";
|
||||
// Invalid argument (e.g. value is incompatible with type) to a function:
|
||||
// - argument: The argument name that was invalid
|
||||
// - value: The value of the argument
|
||||
ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
|
||||
// Missing argument to a function:
|
||||
// - count: The number of arguments received
|
||||
// - expectedCount: The number of arguments expected
|
||||
ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
|
||||
// Too many arguments
|
||||
// - count: The number of arguments received
|
||||
// - expectedCount: The number of arguments expected
|
||||
ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
|
||||
///////////////////
|
||||
// Blockchain Errors
|
||||
// Call exception
|
||||
// - transaction: the transaction
|
||||
// - address?: the contract address
|
||||
// - args?: The arguments passed into the function
|
||||
// - method?: The Solidity method signature
|
||||
// - errorSignature?: The EIP848 error signature
|
||||
// - errorArgs?: The EIP848 error parameters
|
||||
// - reason: The reason (only for EIP848 "Error(string)")
|
||||
ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
|
||||
// Insufficien funds (< value + gasLimit * gasPrice)
|
||||
// - transaction: the transaction attempted
|
||||
ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
|
||||
// Nonce has already been used
|
||||
// - transaction: the transaction attempted
|
||||
ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
|
||||
// The replacement fee for the transaction is too low
|
||||
// - transaction: the transaction attempted
|
||||
ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
|
||||
// The gas limit could not be estimated
|
||||
// - transaction: the transaction passed to estimateGas
|
||||
ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
|
||||
})(ErrorCode || (ErrorCode = {}));
|
||||
;
|
||||
export class Logger {
|
||||
constructor(version) {
|
||||
Object.defineProperty(this, "version", {
|
||||
enumerable: true,
|
||||
value: version,
|
||||
writable: false
|
||||
});
|
||||
}
|
||||
_log(logLevel, args) {
|
||||
const level = logLevel.toLowerCase();
|
||||
if (LogLevels[level] == null) {
|
||||
this.throwArgumentError("invalid log level name", "logLevel", logLevel);
|
||||
}
|
||||
if (_logLevel > LogLevels[level]) {
|
||||
return;
|
||||
}
|
||||
console.log.apply(console, args);
|
||||
}
|
||||
debug(...args) {
|
||||
this._log(Logger.levels.DEBUG, args);
|
||||
}
|
||||
info(...args) {
|
||||
this._log(Logger.levels.INFO, args);
|
||||
}
|
||||
warn(...args) {
|
||||
this._log(Logger.levels.WARNING, args);
|
||||
}
|
||||
makeError(message, code, params) {
|
||||
// Errors are being censored
|
||||
if (_censorErrors) {
|
||||
return this.makeError("censored error", code, {});
|
||||
}
|
||||
if (!code) {
|
||||
code = Logger.errors.UNKNOWN_ERROR;
|
||||
}
|
||||
if (!params) {
|
||||
params = {};
|
||||
}
|
||||
const messageDetails = [];
|
||||
Object.keys(params).forEach((key) => {
|
||||
try {
|
||||
messageDetails.push(key + "=" + JSON.stringify(params[key]));
|
||||
}
|
||||
catch (error) {
|
||||
messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
|
||||
}
|
||||
});
|
||||
messageDetails.push(`code=${code}`);
|
||||
messageDetails.push(`version=${this.version}`);
|
||||
const reason = message;
|
||||
if (messageDetails.length) {
|
||||
message += " (" + messageDetails.join(", ") + ")";
|
||||
}
|
||||
// @TODO: Any??
|
||||
const error = new Error(message);
|
||||
error.reason = reason;
|
||||
error.code = code;
|
||||
Object.keys(params).forEach(function (key) {
|
||||
error[key] = params[key];
|
||||
});
|
||||
return error;
|
||||
}
|
||||
throwError(message, code, params) {
|
||||
throw this.makeError(message, code, params);
|
||||
}
|
||||
throwArgumentError(message, name, value) {
|
||||
return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
|
||||
argument: name,
|
||||
value: value
|
||||
});
|
||||
}
|
||||
assert(condition, message, code, params) {
|
||||
if (!!condition) {
|
||||
return;
|
||||
}
|
||||
this.throwError(message, code, params);
|
||||
}
|
||||
assertArgument(condition, message, name, value) {
|
||||
if (!!condition) {
|
||||
return;
|
||||
}
|
||||
this.throwArgumentError(message, name, value);
|
||||
}
|
||||
checkNormalize(message) {
|
||||
if (message == null) {
|
||||
message = "platform missing String.prototype.normalize";
|
||||
}
|
||||
if (_normalizeError) {
|
||||
this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "String.prototype.normalize", form: _normalizeError
|
||||
});
|
||||
}
|
||||
}
|
||||
checkSafeUint53(value, message) {
|
||||
if (typeof (value) !== "number") {
|
||||
return;
|
||||
}
|
||||
if (message == null) {
|
||||
message = "value not safe";
|
||||
}
|
||||
if (value < 0 || value >= 0x1fffffffffffff) {
|
||||
this.throwError(message, Logger.errors.NUMERIC_FAULT, {
|
||||
operation: "checkSafeInteger",
|
||||
fault: "out-of-safe-range",
|
||||
value: value
|
||||
});
|
||||
}
|
||||
if (value % 1) {
|
||||
this.throwError(message, Logger.errors.NUMERIC_FAULT, {
|
||||
operation: "checkSafeInteger",
|
||||
fault: "non-integer",
|
||||
value: value
|
||||
});
|
||||
}
|
||||
}
|
||||
checkArgumentCount(count, expectedCount, message) {
|
||||
if (message) {
|
||||
message = ": " + message;
|
||||
}
|
||||
else {
|
||||
message = "";
|
||||
}
|
||||
if (count < expectedCount) {
|
||||
this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
|
||||
count: count,
|
||||
expectedCount: expectedCount
|
||||
});
|
||||
}
|
||||
if (count > expectedCount) {
|
||||
this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
|
||||
count: count,
|
||||
expectedCount: expectedCount
|
||||
});
|
||||
}
|
||||
}
|
||||
checkNew(target, kind) {
|
||||
if (target === Object || target == null) {
|
||||
this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
|
||||
}
|
||||
}
|
||||
checkAbstract(target, kind) {
|
||||
if (target === kind) {
|
||||
this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
|
||||
}
|
||||
else if (target === Object || target == null) {
|
||||
this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
|
||||
}
|
||||
}
|
||||
static globalLogger() {
|
||||
if (!_globalLogger) {
|
||||
_globalLogger = new Logger(version);
|
||||
}
|
||||
return _globalLogger;
|
||||
}
|
||||
static setCensorship(censorship, permanent) {
|
||||
if (!censorship && permanent) {
|
||||
this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "setCensorship"
|
||||
});
|
||||
}
|
||||
if (_permanentCensorErrors) {
|
||||
if (!censorship) {
|
||||
return;
|
||||
}
|
||||
this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "setCensorship"
|
||||
});
|
||||
}
|
||||
_censorErrors = !!censorship;
|
||||
_permanentCensorErrors = !!permanent;
|
||||
}
|
||||
static setLogLevel(logLevel) {
|
||||
const level = LogLevels[logLevel.toLowerCase()];
|
||||
if (level == null) {
|
||||
Logger.globalLogger().warn("invalid log level - " + logLevel);
|
||||
return;
|
||||
}
|
||||
_logLevel = level;
|
||||
}
|
||||
}
|
||||
Logger.errors = ErrorCode;
|
||||
Logger.levels = LogLevel;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = "logger/5.0.6";
|
||||
//# sourceMappingURL=_version.js.map
|
||||
+309
@@ -0,0 +1,309 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var _permanentCensorErrors = false;
|
||||
var _censorErrors = false;
|
||||
var LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
|
||||
var _logLevel = LogLevels["default"];
|
||||
var _version_1 = require("./_version");
|
||||
var _globalLogger = null;
|
||||
function _checkNormalize() {
|
||||
try {
|
||||
var missing_1 = [];
|
||||
// Make sure all forms of normalization are supported
|
||||
["NFD", "NFC", "NFKD", "NFKC"].forEach(function (form) {
|
||||
try {
|
||||
if ("test".normalize(form) !== "test") {
|
||||
throw new Error("bad normalize");
|
||||
}
|
||||
;
|
||||
}
|
||||
catch (error) {
|
||||
missing_1.push(form);
|
||||
}
|
||||
});
|
||||
if (missing_1.length) {
|
||||
throw new Error("missing " + missing_1.join(", "));
|
||||
}
|
||||
if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) {
|
||||
throw new Error("broken implementation");
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
return error.message;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var _normalizeError = _checkNormalize();
|
||||
var LogLevel;
|
||||
(function (LogLevel) {
|
||||
LogLevel["DEBUG"] = "DEBUG";
|
||||
LogLevel["INFO"] = "INFO";
|
||||
LogLevel["WARNING"] = "WARNING";
|
||||
LogLevel["ERROR"] = "ERROR";
|
||||
LogLevel["OFF"] = "OFF";
|
||||
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
|
||||
var ErrorCode;
|
||||
(function (ErrorCode) {
|
||||
///////////////////
|
||||
// Generic Errors
|
||||
// Unknown Error
|
||||
ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
||||
// Not Implemented
|
||||
ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
|
||||
// Unsupported Operation
|
||||
// - operation
|
||||
ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION";
|
||||
// Network Error (i.e. Ethereum Network, such as an invalid chain ID)
|
||||
// - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown)
|
||||
ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
|
||||
// Some sort of bad response from the server
|
||||
ErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
|
||||
// Timeout
|
||||
ErrorCode["TIMEOUT"] = "TIMEOUT";
|
||||
///////////////////
|
||||
// Operational Errors
|
||||
// Buffer Overrun
|
||||
ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN";
|
||||
// Numeric Fault
|
||||
// - operation: the operation being executed
|
||||
// - fault: the reason this faulted
|
||||
ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT";
|
||||
///////////////////
|
||||
// Argument Errors
|
||||
// Missing new operator to an object
|
||||
// - name: The name of the class
|
||||
ErrorCode["MISSING_NEW"] = "MISSING_NEW";
|
||||
// Invalid argument (e.g. value is incompatible with type) to a function:
|
||||
// - argument: The argument name that was invalid
|
||||
// - value: The value of the argument
|
||||
ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT";
|
||||
// Missing argument to a function:
|
||||
// - count: The number of arguments received
|
||||
// - expectedCount: The number of arguments expected
|
||||
ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT";
|
||||
// Too many arguments
|
||||
// - count: The number of arguments received
|
||||
// - expectedCount: The number of arguments expected
|
||||
ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT";
|
||||
///////////////////
|
||||
// Blockchain Errors
|
||||
// Call exception
|
||||
// - transaction: the transaction
|
||||
// - address?: the contract address
|
||||
// - args?: The arguments passed into the function
|
||||
// - method?: The Solidity method signature
|
||||
// - errorSignature?: The EIP848 error signature
|
||||
// - errorArgs?: The EIP848 error parameters
|
||||
// - reason: The reason (only for EIP848 "Error(string)")
|
||||
ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION";
|
||||
// Insufficien funds (< value + gasLimit * gasPrice)
|
||||
// - transaction: the transaction attempted
|
||||
ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
|
||||
// Nonce has already been used
|
||||
// - transaction: the transaction attempted
|
||||
ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED";
|
||||
// The replacement fee for the transaction is too low
|
||||
// - transaction: the transaction attempted
|
||||
ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED";
|
||||
// The gas limit could not be estimated
|
||||
// - transaction: the transaction passed to estimateGas
|
||||
ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
|
||||
})(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
|
||||
;
|
||||
var Logger = /** @class */ (function () {
|
||||
function Logger(version) {
|
||||
Object.defineProperty(this, "version", {
|
||||
enumerable: true,
|
||||
value: version,
|
||||
writable: false
|
||||
});
|
||||
}
|
||||
Logger.prototype._log = function (logLevel, args) {
|
||||
var level = logLevel.toLowerCase();
|
||||
if (LogLevels[level] == null) {
|
||||
this.throwArgumentError("invalid log level name", "logLevel", logLevel);
|
||||
}
|
||||
if (_logLevel > LogLevels[level]) {
|
||||
return;
|
||||
}
|
||||
console.log.apply(console, args);
|
||||
};
|
||||
Logger.prototype.debug = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
this._log(Logger.levels.DEBUG, args);
|
||||
};
|
||||
Logger.prototype.info = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
this._log(Logger.levels.INFO, args);
|
||||
};
|
||||
Logger.prototype.warn = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
this._log(Logger.levels.WARNING, args);
|
||||
};
|
||||
Logger.prototype.makeError = function (message, code, params) {
|
||||
// Errors are being censored
|
||||
if (_censorErrors) {
|
||||
return this.makeError("censored error", code, {});
|
||||
}
|
||||
if (!code) {
|
||||
code = Logger.errors.UNKNOWN_ERROR;
|
||||
}
|
||||
if (!params) {
|
||||
params = {};
|
||||
}
|
||||
var messageDetails = [];
|
||||
Object.keys(params).forEach(function (key) {
|
||||
try {
|
||||
messageDetails.push(key + "=" + JSON.stringify(params[key]));
|
||||
}
|
||||
catch (error) {
|
||||
messageDetails.push(key + "=" + JSON.stringify(params[key].toString()));
|
||||
}
|
||||
});
|
||||
messageDetails.push("code=" + code);
|
||||
messageDetails.push("version=" + this.version);
|
||||
var reason = message;
|
||||
if (messageDetails.length) {
|
||||
message += " (" + messageDetails.join(", ") + ")";
|
||||
}
|
||||
// @TODO: Any??
|
||||
var error = new Error(message);
|
||||
error.reason = reason;
|
||||
error.code = code;
|
||||
Object.keys(params).forEach(function (key) {
|
||||
error[key] = params[key];
|
||||
});
|
||||
return error;
|
||||
};
|
||||
Logger.prototype.throwError = function (message, code, params) {
|
||||
throw this.makeError(message, code, params);
|
||||
};
|
||||
Logger.prototype.throwArgumentError = function (message, name, value) {
|
||||
return this.throwError(message, Logger.errors.INVALID_ARGUMENT, {
|
||||
argument: name,
|
||||
value: value
|
||||
});
|
||||
};
|
||||
Logger.prototype.assert = function (condition, message, code, params) {
|
||||
if (!!condition) {
|
||||
return;
|
||||
}
|
||||
this.throwError(message, code, params);
|
||||
};
|
||||
Logger.prototype.assertArgument = function (condition, message, name, value) {
|
||||
if (!!condition) {
|
||||
return;
|
||||
}
|
||||
this.throwArgumentError(message, name, value);
|
||||
};
|
||||
Logger.prototype.checkNormalize = function (message) {
|
||||
if (message == null) {
|
||||
message = "platform missing String.prototype.normalize";
|
||||
}
|
||||
if (_normalizeError) {
|
||||
this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "String.prototype.normalize", form: _normalizeError
|
||||
});
|
||||
}
|
||||
};
|
||||
Logger.prototype.checkSafeUint53 = function (value, message) {
|
||||
if (typeof (value) !== "number") {
|
||||
return;
|
||||
}
|
||||
if (message == null) {
|
||||
message = "value not safe";
|
||||
}
|
||||
if (value < 0 || value >= 0x1fffffffffffff) {
|
||||
this.throwError(message, Logger.errors.NUMERIC_FAULT, {
|
||||
operation: "checkSafeInteger",
|
||||
fault: "out-of-safe-range",
|
||||
value: value
|
||||
});
|
||||
}
|
||||
if (value % 1) {
|
||||
this.throwError(message, Logger.errors.NUMERIC_FAULT, {
|
||||
operation: "checkSafeInteger",
|
||||
fault: "non-integer",
|
||||
value: value
|
||||
});
|
||||
}
|
||||
};
|
||||
Logger.prototype.checkArgumentCount = function (count, expectedCount, message) {
|
||||
if (message) {
|
||||
message = ": " + message;
|
||||
}
|
||||
else {
|
||||
message = "";
|
||||
}
|
||||
if (count < expectedCount) {
|
||||
this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, {
|
||||
count: count,
|
||||
expectedCount: expectedCount
|
||||
});
|
||||
}
|
||||
if (count > expectedCount) {
|
||||
this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, {
|
||||
count: count,
|
||||
expectedCount: expectedCount
|
||||
});
|
||||
}
|
||||
};
|
||||
Logger.prototype.checkNew = function (target, kind) {
|
||||
if (target === Object || target == null) {
|
||||
this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
|
||||
}
|
||||
};
|
||||
Logger.prototype.checkAbstract = function (target, kind) {
|
||||
if (target === kind) {
|
||||
this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" });
|
||||
}
|
||||
else if (target === Object || target == null) {
|
||||
this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name });
|
||||
}
|
||||
};
|
||||
Logger.globalLogger = function () {
|
||||
if (!_globalLogger) {
|
||||
_globalLogger = new Logger(_version_1.version);
|
||||
}
|
||||
return _globalLogger;
|
||||
};
|
||||
Logger.setCensorship = function (censorship, permanent) {
|
||||
if (!censorship && permanent) {
|
||||
this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "setCensorship"
|
||||
});
|
||||
}
|
||||
if (_permanentCensorErrors) {
|
||||
if (!censorship) {
|
||||
return;
|
||||
}
|
||||
this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, {
|
||||
operation: "setCensorship"
|
||||
});
|
||||
}
|
||||
_censorErrors = !!censorship;
|
||||
_permanentCensorErrors = !!permanent;
|
||||
};
|
||||
Logger.setLogLevel = function (logLevel) {
|
||||
var level = LogLevels[logLevel.toLowerCase()];
|
||||
if (level == null) {
|
||||
Logger.globalLogger().warn("invalid log level - " + logLevel);
|
||||
return;
|
||||
}
|
||||
_logLevel = level;
|
||||
};
|
||||
Logger.errors = ErrorCode;
|
||||
Logger.levels = LogLevel;
|
||||
return Logger;
|
||||
}());
|
||||
exports.Logger = Logger;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"_from": "@ethersproject/logger@^5.0.5",
|
||||
"_id": "@ethersproject/logger@5.0.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-FrX0Vnb3JZ1md/7GIZfmJ06XOAA8r3q9Uqt9O5orr4ZiksnbpXKlyDzQtlZ5Yv18RS8CAUbiKH9vwidJg1BPmQ==",
|
||||
"_location": "/@ethersproject/logger",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@ethersproject/logger@^5.0.5",
|
||||
"name": "@ethersproject/logger",
|
||||
"escapedName": "@ethersproject%2flogger",
|
||||
"scope": "@ethersproject",
|
||||
"rawSpec": "^5.0.5",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^5.0.5"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@ethersproject/abi",
|
||||
"/@ethersproject/abstract-provider",
|
||||
"/@ethersproject/abstract-signer",
|
||||
"/@ethersproject/address",
|
||||
"/@ethersproject/bignumber",
|
||||
"/@ethersproject/bytes",
|
||||
"/@ethersproject/hash",
|
||||
"/@ethersproject/networks",
|
||||
"/@ethersproject/properties",
|
||||
"/@ethersproject/rlp",
|
||||
"/@ethersproject/signing-key",
|
||||
"/@ethersproject/strings",
|
||||
"/@ethersproject/transactions",
|
||||
"/@ethersproject/web"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.0.6.tgz",
|
||||
"_shasum": "faa484203e86e08be9e07fef826afeef7183fe88",
|
||||
"_spec": "@ethersproject/logger@^5.0.5",
|
||||
"_where": "C:\\Users\\Luis\\source\\repos\\AAMasters\\BackendServers\\node_modules\\@ethersproject\\transactions",
|
||||
"author": {
|
||||
"name": "Richard Moore",
|
||||
"email": "me@ricmoo.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/ethers-io/ethers.js/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Logger utility functions for ethers.",
|
||||
"ethereum": "donations.ethers.eth",
|
||||
"gitHead": "ffa4a2d0549fe2c606bda3130f4a3f3d788f8dcf",
|
||||
"homepage": "https://github.com/ethers-io/ethers.js#readme",
|
||||
"keywords": [
|
||||
"Ethereum",
|
||||
"ethers"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./lib/index.js",
|
||||
"module": "./lib.esm/index.js",
|
||||
"name": "@ethersproject/logger",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/ethers-io/ethers.js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"tarballHash": "0xf9537798be6f9a5bf14202fe9222696f1340c305b68b14831fdb8d975c53de7d",
|
||||
"types": "./lib/index.d.ts",
|
||||
"version": "5.0.6"
|
||||
}
|
||||
Reference in new issue
Block a user