standard-log 11.4.1 → 11.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/cjs/logger.js +2 -1
- package/cjs/logger.js.map +1 -1
- package/cjs/types.d.ts +1 -1
- package/cjs/types.d.ts.map +1 -1
- package/cjs/types.js.map +1 -1
- package/dist/standard-log.es5.js +169 -238
- package/dist/standard-log.es5.js.gz +0 -0
- package/dist/standard-log.es5.js.map +1 -1
- package/dist/standard-log.es5.js.map.gz +0 -0
- package/dist/standard-log.esm.js +152 -131
- package/dist/standard-log.esm.js.gz +0 -0
- package/dist/standard-log.esm.js.map +1 -1
- package/dist/standard-log.esm.js.map.gz +0 -0
- package/esm/logger.js +2 -1
- package/esm/logger.js.map +1 -1
- package/esm/types.d.ts +1 -1
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js.map +1 -1
- package/package.json +3 -3
- package/ts/logger.ts +1 -1
- package/ts/types.ts +1 -1
|
Binary file
|
package/dist/standard-log.esm.js
CHANGED
|
@@ -267,7 +267,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
267
267
|
/* harmony export */ "InvalidId": function() { return /* binding */ InvalidId; },
|
|
268
268
|
/* harmony export */ "StandardLogError": function() { return /* binding */ StandardLogError; }
|
|
269
269
|
/* harmony export */ });
|
|
270
|
-
/* harmony import */ var iso_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! iso-error */ "../../node_modules/.pnpm/iso-error@
|
|
270
|
+
/* harmony import */ var iso_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! iso-error */ "../../node_modules/.pnpm/iso-error@5.0.0/node_modules/iso-error/esm/index.js");
|
|
271
271
|
|
|
272
272
|
/**
|
|
273
273
|
* @deprecated No longer used since 11.2.0
|
|
@@ -594,11 +594,12 @@ function createLogger(store, id, options) {
|
|
|
594
594
|
on: {
|
|
595
595
|
writable: false,
|
|
596
596
|
value: (level, logFn) => {
|
|
597
|
+
var _a;
|
|
597
598
|
const logLevel = typeof level === 'string' ? store.logLevelStore.getLevel(level) : level;
|
|
598
599
|
if (shouldLog(store, logLevel, logger.level)) {
|
|
599
600
|
const methodName = store.logLevelStore.getName(logLevel);
|
|
600
601
|
const bindedMethod = logger[methodName].bind(logger);
|
|
601
|
-
const result = logFn(bindedMethod);
|
|
602
|
+
const result = logFn(bindedMethod, (_a = logger.level) !== null && _a !== void 0 ? _a : store.logLevel);
|
|
602
603
|
if (result)
|
|
603
604
|
bindedMethod(result);
|
|
604
605
|
}
|
|
@@ -941,9 +942,9 @@ exports.upperCase = upperCase;
|
|
|
941
942
|
|
|
942
943
|
/***/ }),
|
|
943
944
|
|
|
944
|
-
/***/ "../../node_modules/.pnpm/iso-error@
|
|
945
|
+
/***/ "../../node_modules/.pnpm/iso-error@5.0.0/node_modules/iso-error/esm/index.js":
|
|
945
946
|
/*!************************************************************************************!*\
|
|
946
|
-
!*** ../../node_modules/.pnpm/iso-error@
|
|
947
|
+
!*** ../../node_modules/.pnpm/iso-error@5.0.0/node_modules/iso-error/esm/index.js ***!
|
|
947
948
|
\************************************************************************************/
|
|
948
949
|
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
949
950
|
|
|
@@ -952,9 +953,16 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
952
953
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
953
954
|
/* harmony export */ "IsoError": function() { return /* binding */ IsoError; },
|
|
954
955
|
/* harmony export */ "ModuleError": function() { return /* binding */ ModuleError; },
|
|
956
|
+
/* harmony export */ "SerializableConverter": function() { return /* binding */ SerializableConverter; },
|
|
955
957
|
/* harmony export */ "isAggregateError": function() { return /* binding */ isAggregateError; }
|
|
956
958
|
/* harmony export */ });
|
|
957
959
|
/* eslint-disable @typescript-eslint/unbound-method */
|
|
960
|
+
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
961
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
962
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
963
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
964
|
+
};
|
|
965
|
+
var _SerializableConverter_instances, _SerializableConverter_plugins, _SerializableConverter_fromSerializable, _SerializableConverter_deserializeError, _SerializableConverter_toSerializable, _a, _IsoError_hasCause, _IsoError_toIsoError;
|
|
958
966
|
//#region captureStackTrace polyfill
|
|
959
967
|
// istanbul ignore next
|
|
960
968
|
if (!Error.captureStackTrace) {
|
|
@@ -979,116 +987,34 @@ function defineStack(target, value) {
|
|
|
979
987
|
writable: true,
|
|
980
988
|
});
|
|
981
989
|
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
*/
|
|
987
|
-
class IsoError extends Error {
|
|
988
|
-
constructor(message, options) {
|
|
989
|
-
super(message);
|
|
990
|
-
/**
|
|
991
|
-
* Name of the error
|
|
992
|
-
*/
|
|
993
|
-
Object.defineProperty(this, "name", {
|
|
994
|
-
enumerable: true,
|
|
995
|
-
configurable: true,
|
|
996
|
-
writable: true,
|
|
997
|
-
value: void 0
|
|
998
|
-
});
|
|
999
|
-
/**
|
|
1000
|
-
* Error cause
|
|
1001
|
-
*/
|
|
1002
|
-
Object.defineProperty(this, "cause", {
|
|
1003
|
-
enumerable: true,
|
|
1004
|
-
configurable: true,
|
|
1005
|
-
writable: true,
|
|
1006
|
-
value: void 0
|
|
1007
|
-
});
|
|
1008
|
-
//restore prototype chain
|
|
1009
|
-
const actualProto = new.target.prototype;
|
|
1010
|
-
this.name = actualProto.constructor.name;
|
|
1011
|
-
// istanbul ignore next
|
|
1012
|
-
if (Object.setPrototypeOf)
|
|
1013
|
-
Object.setPrototypeOf(this, actualProto);
|
|
1014
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1015
|
-
else
|
|
1016
|
-
this.__proto__ = actualProto;
|
|
1017
|
-
if (options?.cause)
|
|
1018
|
-
this.cause = toIsoError(options.cause);
|
|
1019
|
-
if (options?.ssf)
|
|
1020
|
-
Error.captureStackTrace(this, options.ssf);
|
|
990
|
+
class SerializableConverter {
|
|
991
|
+
constructor() {
|
|
992
|
+
_SerializableConverter_instances.add(this);
|
|
993
|
+
_SerializableConverter_plugins.set(this, []);
|
|
1021
994
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
* @param props properties of the IsoError
|
|
1025
|
-
*/
|
|
1026
|
-
static create(props) {
|
|
1027
|
-
const { message, cause, ...rest } = props;
|
|
1028
|
-
const err = new IsoError(message, { cause, ssf: IsoError.create });
|
|
1029
|
-
return Object.assign(err, rest);
|
|
1030
|
-
}
|
|
1031
|
-
static stringify(err) {
|
|
1032
|
-
return this.serialize(err);
|
|
1033
|
-
}
|
|
1034
|
-
static serialize(err) {
|
|
1035
|
-
return JSON.stringify(this.toSerializable(err));
|
|
1036
|
-
}
|
|
1037
|
-
/**
|
|
1038
|
-
* @type P Additional properties of the IsoError
|
|
1039
|
-
* @param text Json representation of a IsoError
|
|
1040
|
-
*/
|
|
1041
|
-
static parse(text) {
|
|
1042
|
-
return deserialize(IsoError.parse, text);
|
|
995
|
+
addPlugin(plugin) {
|
|
996
|
+
__classPrivateFieldGet(this, _SerializableConverter_plugins, "f").unshift(plugin);
|
|
1043
997
|
}
|
|
1044
998
|
/**
|
|
1045
|
-
*
|
|
1046
|
-
* @param text Json representation of a IsoError
|
|
999
|
+
* Deserialize an `Error` from `Serializable`
|
|
1047
1000
|
*/
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
static toSerializable(err) {
|
|
1052
|
-
return serializers.reduce((p, s) => p || s(err), undefined)
|
|
1053
|
-
|| toSerializableError(err);
|
|
1054
|
-
}
|
|
1055
|
-
static fromSerializable(json) {
|
|
1056
|
-
const err = deserializeError(json);
|
|
1057
|
-
Error.captureStackTrace(err, IsoError.fromSerializable);
|
|
1001
|
+
fromSerializable(json, options) {
|
|
1002
|
+
const err = __classPrivateFieldGet(this, _SerializableConverter_instances, "m", _SerializableConverter_deserializeError).call(this, json);
|
|
1003
|
+
Error.captureStackTrace(err, options?.ssf);
|
|
1058
1004
|
return err;
|
|
1059
1005
|
}
|
|
1060
1006
|
/**
|
|
1061
|
-
*
|
|
1007
|
+
* Serialize `Error` to `Serializable`
|
|
1062
1008
|
*/
|
|
1063
|
-
|
|
1064
|
-
return
|
|
1065
|
-
}
|
|
1066
|
-
static addPlugin({ toSerializable, fromSerializable }) {
|
|
1067
|
-
serializers.unshift(toSerializable);
|
|
1068
|
-
deserializers.unshift(fromSerializable);
|
|
1009
|
+
toSerializable(err) {
|
|
1010
|
+
return __classPrivateFieldGet(this, _SerializableConverter_plugins, "f").reduce((p, s) => p || s.toSerializable(err), undefined) || __classPrivateFieldGet(this, _SerializableConverter_instances, "m", _SerializableConverter_toSerializable).call(this, err);
|
|
1069
1011
|
}
|
|
1070
|
-
toString() { return IsoError.serialize(this); }
|
|
1071
|
-
trace() { return IsoError.trace(this); }
|
|
1072
|
-
}
|
|
1073
|
-
function deserialize(fn, text) {
|
|
1074
|
-
const json = JSON.parse(text);
|
|
1075
|
-
const err = deserializeError(json);
|
|
1076
|
-
Error.captureStackTrace(err, fn);
|
|
1077
|
-
return err;
|
|
1078
1012
|
}
|
|
1079
|
-
function
|
|
1080
|
-
let err = undefined;
|
|
1081
|
-
for (const d of deserializers) {
|
|
1082
|
-
err = d(json);
|
|
1083
|
-
if (err)
|
|
1084
|
-
break;
|
|
1085
|
-
}
|
|
1086
|
-
return err || defaultDeserializeError(json);
|
|
1087
|
-
}
|
|
1088
|
-
function defaultDeserializeError(json) {
|
|
1013
|
+
_SerializableConverter_plugins = new WeakMap(), _SerializableConverter_instances = new WeakSet(), _SerializableConverter_fromSerializable = function _SerializableConverter_fromSerializable(json) {
|
|
1089
1014
|
if (json.name === 'AggregateError') {
|
|
1090
1015
|
const { message, errors, ...rest } = json;
|
|
1091
1016
|
// @ts-ignore
|
|
1017
|
+
// istanbul ignore next
|
|
1092
1018
|
if (global.AggregateError) {
|
|
1093
1019
|
return Object.assign(new AggregateError(errors, message), rest);
|
|
1094
1020
|
}
|
|
@@ -1100,60 +1026,155 @@ function defaultDeserializeError(json) {
|
|
|
1100
1026
|
}
|
|
1101
1027
|
}
|
|
1102
1028
|
const { message, cause, ...rest } = json;
|
|
1103
|
-
const causeError = cause ?
|
|
1029
|
+
const causeError = cause ? __classPrivateFieldGet(this, _SerializableConverter_instances, "m", _SerializableConverter_deserializeError).call(this, cause) : undefined;
|
|
1104
1030
|
if (json.name === 'Error') {
|
|
1105
1031
|
return Object.assign(new Error(message), causeError ? { ...rest, cause: causeError } : rest);
|
|
1106
1032
|
}
|
|
1107
1033
|
// @ts-ignore
|
|
1108
1034
|
return Object.assign(new IsoError(message, causeError ? { cause: causeError } : undefined), rest);
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1035
|
+
}, _SerializableConverter_deserializeError = function _SerializableConverter_deserializeError(json) {
|
|
1036
|
+
let err = undefined;
|
|
1037
|
+
for (const { fromSerializable } of __classPrivateFieldGet(this, _SerializableConverter_plugins, "f")) {
|
|
1038
|
+
err = fromSerializable(json);
|
|
1039
|
+
if (err)
|
|
1040
|
+
break;
|
|
1041
|
+
}
|
|
1042
|
+
return err || __classPrivateFieldGet(this, _SerializableConverter_instances, "m", _SerializableConverter_fromSerializable).call(this, json);
|
|
1043
|
+
}, _SerializableConverter_toSerializable = function _SerializableConverter_toSerializable(err) {
|
|
1111
1044
|
if (isAggregateError(err)) {
|
|
1112
1045
|
return {
|
|
1113
1046
|
...err, name: err.constructor.name, message: err.message,
|
|
1114
|
-
errors: err.errors.map(
|
|
1047
|
+
errors: err.errors.map(__classPrivateFieldGet(this, _SerializableConverter_instances, "m", _SerializableConverter_toSerializable))
|
|
1115
1048
|
};
|
|
1116
1049
|
}
|
|
1117
1050
|
if (err instanceof Error) {
|
|
1118
1051
|
const { message, cause } = err;
|
|
1119
1052
|
return cause
|
|
1120
|
-
? { ...err, name: err.constructor.name, message, cause:
|
|
1053
|
+
? { ...err, name: err.constructor.name, message, cause: __classPrivateFieldGet(this, _SerializableConverter_instances, "m", _SerializableConverter_toSerializable).call(this, cause) }
|
|
1121
1054
|
: { ...err, name: err.constructor.name, message };
|
|
1122
1055
|
}
|
|
1123
1056
|
return err;
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1057
|
+
};
|
|
1058
|
+
/**
|
|
1059
|
+
* Isomorphic Error that works across physical boundary.
|
|
1060
|
+
*/
|
|
1061
|
+
class IsoError extends Error {
|
|
1062
|
+
/**
|
|
1063
|
+
* Create an IsoError with additional properties without the need to create a new class.
|
|
1064
|
+
* @param props properties of the IsoError
|
|
1065
|
+
*/
|
|
1066
|
+
static create(props) {
|
|
1067
|
+
const { message, cause, ...rest } = props;
|
|
1068
|
+
const err = new IsoError(message, { cause, ssf: IsoError.create });
|
|
1069
|
+
return Object.assign(err, rest);
|
|
1137
1070
|
}
|
|
1138
|
-
|
|
1139
|
-
|
|
1071
|
+
static stringify(err) {
|
|
1072
|
+
return this.serialize(err);
|
|
1140
1073
|
}
|
|
1141
|
-
|
|
1142
|
-
|
|
1074
|
+
static serialize(err) {
|
|
1075
|
+
return JSON.stringify(this.toSerializable(err));
|
|
1143
1076
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
messages.push(...trace(err.cause).split('\n').map(s => ' ' + s));
|
|
1077
|
+
static toSerializable(err) {
|
|
1078
|
+
return this.converter.toSerializable(err);
|
|
1147
1079
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1080
|
+
/**
|
|
1081
|
+
* @type P Additional properties of the IsoError
|
|
1082
|
+
* @param text Json representation of a IsoError
|
|
1083
|
+
*/
|
|
1084
|
+
static parse(text) {
|
|
1085
|
+
const json = JSON.parse(text);
|
|
1086
|
+
return this.converter.fromSerializable(json, { ssf: IsoError.parse });
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* @type P Additional properties of the IsoError
|
|
1090
|
+
* @param text Json representation of a IsoError
|
|
1091
|
+
*/
|
|
1092
|
+
static deserialize(text) {
|
|
1093
|
+
const json = JSON.parse(text);
|
|
1094
|
+
return this.converter.fromSerializable(json, { ssf: IsoError.deserialize });
|
|
1095
|
+
}
|
|
1096
|
+
static fromSerializable(json) {
|
|
1097
|
+
return this.converter.fromSerializable(json, { ssf: IsoError.fromSerializable });
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* returns the error message including the error causes.
|
|
1101
|
+
*/
|
|
1102
|
+
static trace(err) {
|
|
1103
|
+
const messages = [];
|
|
1104
|
+
if (err instanceof ModuleError) {
|
|
1105
|
+
messages.push(`${err.name}(${err.module}): ${err.message}`);
|
|
1106
|
+
}
|
|
1107
|
+
else if (err instanceof Error) {
|
|
1108
|
+
messages.push(`${err.name}: ${err.message}`);
|
|
1109
|
+
}
|
|
1110
|
+
if (isAggregateError(err)) {
|
|
1111
|
+
err.errors.forEach(e => messages.push(...this.trace(e).split('\n').map(s => ' ' + s)));
|
|
1112
|
+
}
|
|
1113
|
+
if (err instanceof Error) {
|
|
1114
|
+
if (__classPrivateFieldGet(this, _a, "m", _IsoError_hasCause).call(this, err))
|
|
1115
|
+
messages.push(...this.trace(err.cause).split('\n').map(s => ' ' + s));
|
|
1116
|
+
}
|
|
1117
|
+
else {
|
|
1118
|
+
messages.push(typeof err === 'string' ? err : JSON.stringify(err));
|
|
1119
|
+
}
|
|
1120
|
+
return messages.join('\n');
|
|
1121
|
+
}
|
|
1122
|
+
static addPlugin(plugin) {
|
|
1123
|
+
this.converter.addPlugin(plugin);
|
|
1150
1124
|
}
|
|
1151
|
-
|
|
1125
|
+
constructor(message, options) {
|
|
1126
|
+
super(message);
|
|
1127
|
+
/**
|
|
1128
|
+
* Name of the error
|
|
1129
|
+
*/
|
|
1130
|
+
Object.defineProperty(this, "name", {
|
|
1131
|
+
enumerable: true,
|
|
1132
|
+
configurable: true,
|
|
1133
|
+
writable: true,
|
|
1134
|
+
value: void 0
|
|
1135
|
+
});
|
|
1136
|
+
/**
|
|
1137
|
+
* Error cause
|
|
1138
|
+
*/
|
|
1139
|
+
Object.defineProperty(this, "cause", {
|
|
1140
|
+
enumerable: true,
|
|
1141
|
+
configurable: true,
|
|
1142
|
+
writable: true,
|
|
1143
|
+
value: void 0
|
|
1144
|
+
});
|
|
1145
|
+
// restore prototype chain
|
|
1146
|
+
const actualProto = new.target.prototype;
|
|
1147
|
+
this.name = actualProto.constructor.name;
|
|
1148
|
+
// istanbul ignore next
|
|
1149
|
+
if (Object.setPrototypeOf)
|
|
1150
|
+
Object.setPrototypeOf(this, actualProto);
|
|
1151
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1152
|
+
else
|
|
1153
|
+
this.__proto__ = actualProto;
|
|
1154
|
+
if (options?.cause)
|
|
1155
|
+
this.cause = __classPrivateFieldGet(IsoError, _a, "m", _IsoError_toIsoError).call(IsoError, options.cause);
|
|
1156
|
+
if (options?.ssf)
|
|
1157
|
+
Error.captureStackTrace(this, options.ssf);
|
|
1158
|
+
}
|
|
1159
|
+
toString() { return IsoError.serialize(this); }
|
|
1160
|
+
trace() { return IsoError.trace(this); }
|
|
1152
1161
|
}
|
|
1153
|
-
function
|
|
1162
|
+
_a = IsoError, _IsoError_hasCause = function _IsoError_hasCause(x) {
|
|
1154
1163
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1155
1164
|
return !!x.cause;
|
|
1156
|
-
}
|
|
1165
|
+
}, _IsoError_toIsoError = function _IsoError_toIsoError(err) {
|
|
1166
|
+
if (err instanceof IsoError)
|
|
1167
|
+
return err;
|
|
1168
|
+
// When the error is an internal error from deserialization,
|
|
1169
|
+
// the err.constructor.name is object
|
|
1170
|
+
return Object.assign(err, { name: err.constructor.name !== 'Object' ? err.constructor.name : err.name });
|
|
1171
|
+
};
|
|
1172
|
+
Object.defineProperty(IsoError, "converter", {
|
|
1173
|
+
enumerable: true,
|
|
1174
|
+
configurable: true,
|
|
1175
|
+
writable: true,
|
|
1176
|
+
value: new SerializableConverter()
|
|
1177
|
+
});
|
|
1157
1178
|
/**
|
|
1158
1179
|
* An IsoError with a module property.
|
|
1159
1180
|
*/
|
|
Binary file
|