@bymax-one/nest-logger 1.4.14 → 1.4.16
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/CHANGELOG.md +39 -1
- package/README.md +246 -807
- package/dist/server/index.cjs +44 -29
- package/dist/server/index.mjs +44 -29
- package/package.json +3 -2
package/dist/server/index.cjs
CHANGED
|
@@ -2038,6 +2038,32 @@ function destinationToStream(destination, health) {
|
|
|
2038
2038
|
});
|
|
2039
2039
|
}
|
|
2040
2040
|
|
|
2041
|
+
// src/server/utils/redact-error-clone.util.ts
|
|
2042
|
+
function shadowHook(target) {
|
|
2043
|
+
Reflect.defineProperty(target, "toJSON", { value: void 0, configurable: true });
|
|
2044
|
+
}
|
|
2045
|
+
function withoutEnumerableKeys(clone) {
|
|
2046
|
+
for (const key of Object.keys(clone)) Reflect.deleteProperty(clone, key);
|
|
2047
|
+
}
|
|
2048
|
+
function discardWrite() {
|
|
2049
|
+
}
|
|
2050
|
+
function cloneError(error) {
|
|
2051
|
+
const descriptors = Object.getOwnPropertyDescriptors(error);
|
|
2052
|
+
for (const descriptor of Object.values(descriptors)) {
|
|
2053
|
+
descriptor.configurable = true;
|
|
2054
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
2055
|
+
else descriptor.set ??= discardWrite;
|
|
2056
|
+
}
|
|
2057
|
+
const clone = Object.create(Object.getPrototypeOf(error), descriptors);
|
|
2058
|
+
const { stack } = error;
|
|
2059
|
+
if (typeof stack === "string") {
|
|
2060
|
+
Reflect.defineProperty(clone, "stack", { value: stack, enumerable: false, writable: true });
|
|
2061
|
+
}
|
|
2062
|
+
withoutEnumerableKeys(clone);
|
|
2063
|
+
shadowHook(clone);
|
|
2064
|
+
return clone;
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2041
2067
|
// src/server/utils/redact-error-parts.util.ts
|
|
2042
2068
|
function defineOwn(target, key, value) {
|
|
2043
2069
|
Reflect.defineProperty(target, key, { value, enumerable: true, writable: true });
|
|
@@ -2154,30 +2180,6 @@ function resolveToJson(value, viaGet = false) {
|
|
|
2154
2180
|
volatile: accessor || proxied
|
|
2155
2181
|
};
|
|
2156
2182
|
}
|
|
2157
|
-
function shadowHook(target) {
|
|
2158
|
-
Reflect.defineProperty(target, "toJSON", { value: void 0, configurable: true });
|
|
2159
|
-
}
|
|
2160
|
-
function withoutEnumerableKeys(clone) {
|
|
2161
|
-
for (const key of Object.keys(clone)) Reflect.deleteProperty(clone, key);
|
|
2162
|
-
}
|
|
2163
|
-
function discardWrite() {
|
|
2164
|
-
}
|
|
2165
|
-
function cloneError(error) {
|
|
2166
|
-
const descriptors = Object.getOwnPropertyDescriptors(error);
|
|
2167
|
-
for (const descriptor of Object.values(descriptors)) {
|
|
2168
|
-
descriptor.configurable = true;
|
|
2169
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
2170
|
-
else descriptor.set ??= discardWrite;
|
|
2171
|
-
}
|
|
2172
|
-
const clone = Object.create(Object.getPrototypeOf(error), descriptors);
|
|
2173
|
-
const { stack } = error;
|
|
2174
|
-
if (typeof stack === "string") {
|
|
2175
|
-
Reflect.defineProperty(clone, "stack", { value: stack, enumerable: false, writable: true });
|
|
2176
|
-
}
|
|
2177
|
-
withoutEnumerableKeys(clone);
|
|
2178
|
-
shadowHook(clone);
|
|
2179
|
-
return clone;
|
|
2180
|
-
}
|
|
2181
2183
|
function walkArray(value, rules, depth2, ancestors, inSerialized) {
|
|
2182
2184
|
const length = value.length;
|
|
2183
2185
|
const copy = [];
|
|
@@ -2190,6 +2192,9 @@ function walkArray(value, rules, depth2, ancestors, inSerialized) {
|
|
|
2190
2192
|
}
|
|
2191
2193
|
return copy;
|
|
2192
2194
|
}
|
|
2195
|
+
function errorRules(rules) {
|
|
2196
|
+
return rules.insideErrors ?? rules;
|
|
2197
|
+
}
|
|
2193
2198
|
function walk(value, rules, depth2, ancestors, honorToJson, inSerialized = false) {
|
|
2194
2199
|
if (value === null) {
|
|
2195
2200
|
return value;
|
|
@@ -2207,7 +2212,7 @@ function walk(value, rules, depth2, ancestors, honorToJson, inSerialized = false
|
|
|
2207
2212
|
return REDACT_CIRCULAR;
|
|
2208
2213
|
}
|
|
2209
2214
|
if (isError(value)) {
|
|
2210
|
-
return walkError(value, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
2215
|
+
return walkError(value, errorRules(rules), depth2, ancestors, honorToJson, inSerialized);
|
|
2211
2216
|
}
|
|
2212
2217
|
return walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
2213
2218
|
}
|
|
@@ -2314,7 +2319,7 @@ function errorPartsHost(rules, ancestors, inSerialized) {
|
|
|
2314
2319
|
hasToJson: (value) => !rules.ownFields.safe && resolveToJson(value).method !== void 0
|
|
2315
2320
|
};
|
|
2316
2321
|
}
|
|
2317
|
-
function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDACT_MAX_VISITS, ownFields = ALL_OWN_FIELDS) {
|
|
2322
|
+
function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDACT_MAX_VISITS, ownFields = ALL_OWN_FIELDS, errorOnlyNames) {
|
|
2318
2323
|
const rules = {
|
|
2319
2324
|
sensitive: new Set(Array.from(fieldNames, (name) => name.toLowerCase())),
|
|
2320
2325
|
censor,
|
|
@@ -2323,9 +2328,15 @@ function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDA
|
|
|
2323
2328
|
maxVisits,
|
|
2324
2329
|
ownFields
|
|
2325
2330
|
};
|
|
2331
|
+
const insideNames = errorOnlyNames === void 0 ? void 0 : new Set(Array.from(errorOnlyNames, (name) => name.toLowerCase()));
|
|
2326
2332
|
return (value, isRecordRoot = false) => {
|
|
2327
2333
|
try {
|
|
2328
|
-
const
|
|
2334
|
+
const visits = { count: 0 };
|
|
2335
|
+
const call = {
|
|
2336
|
+
...rules,
|
|
2337
|
+
visits,
|
|
2338
|
+
insideErrors: insideNames === void 0 ? void 0 : { ...rules, sensitive: insideNames, visits, insideErrors: void 0 }
|
|
2339
|
+
};
|
|
2329
2340
|
return walk(value, call, 0, /* @__PURE__ */ new Set(), !isRecordRoot);
|
|
2330
2341
|
} catch {
|
|
2331
2342
|
return {
|
|
@@ -2566,6 +2577,9 @@ function resolveNameRedactor(options) {
|
|
|
2566
2577
|
function ownFieldPolicyOf(options) {
|
|
2567
2578
|
return createOwnFieldPolicy(options.errorOwnFields, options.errorOwnFieldNames);
|
|
2568
2579
|
}
|
|
2580
|
+
function namesInsideErrors(options) {
|
|
2581
|
+
return options.shouldDisableDefaultRedact ? void 0 : REDACT_COMMON_FIELDS;
|
|
2582
|
+
}
|
|
2569
2583
|
function buildNameRedactor(options, nestedErrorsAsData = false, coversNames = true) {
|
|
2570
2584
|
const names = coversNames ? [
|
|
2571
2585
|
...options.shouldDisableDefaultRedact ? [] : REDACT_COMMON_FIELDS,
|
|
@@ -2576,12 +2590,13 @@ function buildNameRedactor(options, nestedErrorsAsData = false, coversNames = tr
|
|
|
2576
2590
|
if (!walks && resolveRedactOption(options) === void 0) {
|
|
2577
2591
|
return PASS_THROUGH;
|
|
2578
2592
|
}
|
|
2579
|
-
return nestedErrorsAsData && walks ? createNameRedactor(
|
|
2593
|
+
return nestedErrorsAsData && (walks || !coversNames) ? createNameRedactor(
|
|
2580
2594
|
names,
|
|
2581
2595
|
options.redactCensor,
|
|
2582
2596
|
["err", ...Object.keys(options.serializers)],
|
|
2583
2597
|
void 0,
|
|
2584
|
-
ownFields
|
|
2598
|
+
ownFields,
|
|
2599
|
+
coversNames ? void 0 : namesInsideErrors(options)
|
|
2585
2600
|
) : createNameRedactor(names, options.redactCensor, void 0, void 0, ownFields);
|
|
2586
2601
|
}
|
|
2587
2602
|
function resolveRedactOption(options) {
|
package/dist/server/index.mjs
CHANGED
|
@@ -2035,6 +2035,32 @@ function destinationToStream(destination, health) {
|
|
|
2035
2035
|
});
|
|
2036
2036
|
}
|
|
2037
2037
|
|
|
2038
|
+
// src/server/utils/redact-error-clone.util.ts
|
|
2039
|
+
function shadowHook(target) {
|
|
2040
|
+
Reflect.defineProperty(target, "toJSON", { value: void 0, configurable: true });
|
|
2041
|
+
}
|
|
2042
|
+
function withoutEnumerableKeys(clone) {
|
|
2043
|
+
for (const key of Object.keys(clone)) Reflect.deleteProperty(clone, key);
|
|
2044
|
+
}
|
|
2045
|
+
function discardWrite() {
|
|
2046
|
+
}
|
|
2047
|
+
function cloneError(error) {
|
|
2048
|
+
const descriptors = Object.getOwnPropertyDescriptors(error);
|
|
2049
|
+
for (const descriptor of Object.values(descriptors)) {
|
|
2050
|
+
descriptor.configurable = true;
|
|
2051
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
2052
|
+
else descriptor.set ??= discardWrite;
|
|
2053
|
+
}
|
|
2054
|
+
const clone = Object.create(Object.getPrototypeOf(error), descriptors);
|
|
2055
|
+
const { stack } = error;
|
|
2056
|
+
if (typeof stack === "string") {
|
|
2057
|
+
Reflect.defineProperty(clone, "stack", { value: stack, enumerable: false, writable: true });
|
|
2058
|
+
}
|
|
2059
|
+
withoutEnumerableKeys(clone);
|
|
2060
|
+
shadowHook(clone);
|
|
2061
|
+
return clone;
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2038
2064
|
// src/server/utils/redact-error-parts.util.ts
|
|
2039
2065
|
function defineOwn(target, key, value) {
|
|
2040
2066
|
Reflect.defineProperty(target, key, { value, enumerable: true, writable: true });
|
|
@@ -2151,30 +2177,6 @@ function resolveToJson(value, viaGet = false) {
|
|
|
2151
2177
|
volatile: accessor || proxied
|
|
2152
2178
|
};
|
|
2153
2179
|
}
|
|
2154
|
-
function shadowHook(target) {
|
|
2155
|
-
Reflect.defineProperty(target, "toJSON", { value: void 0, configurable: true });
|
|
2156
|
-
}
|
|
2157
|
-
function withoutEnumerableKeys(clone) {
|
|
2158
|
-
for (const key of Object.keys(clone)) Reflect.deleteProperty(clone, key);
|
|
2159
|
-
}
|
|
2160
|
-
function discardWrite() {
|
|
2161
|
-
}
|
|
2162
|
-
function cloneError(error) {
|
|
2163
|
-
const descriptors = Object.getOwnPropertyDescriptors(error);
|
|
2164
|
-
for (const descriptor of Object.values(descriptors)) {
|
|
2165
|
-
descriptor.configurable = true;
|
|
2166
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
2167
|
-
else descriptor.set ??= discardWrite;
|
|
2168
|
-
}
|
|
2169
|
-
const clone = Object.create(Object.getPrototypeOf(error), descriptors);
|
|
2170
|
-
const { stack } = error;
|
|
2171
|
-
if (typeof stack === "string") {
|
|
2172
|
-
Reflect.defineProperty(clone, "stack", { value: stack, enumerable: false, writable: true });
|
|
2173
|
-
}
|
|
2174
|
-
withoutEnumerableKeys(clone);
|
|
2175
|
-
shadowHook(clone);
|
|
2176
|
-
return clone;
|
|
2177
|
-
}
|
|
2178
2180
|
function walkArray(value, rules, depth2, ancestors, inSerialized) {
|
|
2179
2181
|
const length = value.length;
|
|
2180
2182
|
const copy = [];
|
|
@@ -2187,6 +2189,9 @@ function walkArray(value, rules, depth2, ancestors, inSerialized) {
|
|
|
2187
2189
|
}
|
|
2188
2190
|
return copy;
|
|
2189
2191
|
}
|
|
2192
|
+
function errorRules(rules) {
|
|
2193
|
+
return rules.insideErrors ?? rules;
|
|
2194
|
+
}
|
|
2190
2195
|
function walk(value, rules, depth2, ancestors, honorToJson, inSerialized = false) {
|
|
2191
2196
|
if (value === null) {
|
|
2192
2197
|
return value;
|
|
@@ -2204,7 +2209,7 @@ function walk(value, rules, depth2, ancestors, honorToJson, inSerialized = false
|
|
|
2204
2209
|
return REDACT_CIRCULAR;
|
|
2205
2210
|
}
|
|
2206
2211
|
if (isError(value)) {
|
|
2207
|
-
return walkError(value, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
2212
|
+
return walkError(value, errorRules(rules), depth2, ancestors, honorToJson, inSerialized);
|
|
2208
2213
|
}
|
|
2209
2214
|
return walkObject(value, rules, depth2, ancestors, honorToJson, inSerialized);
|
|
2210
2215
|
}
|
|
@@ -2311,7 +2316,7 @@ function errorPartsHost(rules, ancestors, inSerialized) {
|
|
|
2311
2316
|
hasToJson: (value) => !rules.ownFields.safe && resolveToJson(value).method !== void 0
|
|
2312
2317
|
};
|
|
2313
2318
|
}
|
|
2314
|
-
function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDACT_MAX_VISITS, ownFields = ALL_OWN_FIELDS) {
|
|
2319
|
+
function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDACT_MAX_VISITS, ownFields = ALL_OWN_FIELDS, errorOnlyNames) {
|
|
2315
2320
|
const rules = {
|
|
2316
2321
|
sensitive: new Set(Array.from(fieldNames, (name) => name.toLowerCase())),
|
|
2317
2322
|
censor,
|
|
@@ -2320,9 +2325,15 @@ function createNameRedactor(fieldNames, censor, serializedKeys, maxVisits = REDA
|
|
|
2320
2325
|
maxVisits,
|
|
2321
2326
|
ownFields
|
|
2322
2327
|
};
|
|
2328
|
+
const insideNames = errorOnlyNames === void 0 ? void 0 : new Set(Array.from(errorOnlyNames, (name) => name.toLowerCase()));
|
|
2323
2329
|
return (value, isRecordRoot = false) => {
|
|
2324
2330
|
try {
|
|
2325
|
-
const
|
|
2331
|
+
const visits = { count: 0 };
|
|
2332
|
+
const call = {
|
|
2333
|
+
...rules,
|
|
2334
|
+
visits,
|
|
2335
|
+
insideErrors: insideNames === void 0 ? void 0 : { ...rules, sensitive: insideNames, visits, insideErrors: void 0 }
|
|
2336
|
+
};
|
|
2326
2337
|
return walk(value, call, 0, /* @__PURE__ */ new Set(), !isRecordRoot);
|
|
2327
2338
|
} catch {
|
|
2328
2339
|
return {
|
|
@@ -2563,6 +2574,9 @@ function resolveNameRedactor(options) {
|
|
|
2563
2574
|
function ownFieldPolicyOf(options) {
|
|
2564
2575
|
return createOwnFieldPolicy(options.errorOwnFields, options.errorOwnFieldNames);
|
|
2565
2576
|
}
|
|
2577
|
+
function namesInsideErrors(options) {
|
|
2578
|
+
return options.shouldDisableDefaultRedact ? void 0 : REDACT_COMMON_FIELDS;
|
|
2579
|
+
}
|
|
2566
2580
|
function buildNameRedactor(options, nestedErrorsAsData = false, coversNames = true) {
|
|
2567
2581
|
const names = coversNames ? [
|
|
2568
2582
|
...options.shouldDisableDefaultRedact ? [] : REDACT_COMMON_FIELDS,
|
|
@@ -2573,12 +2587,13 @@ function buildNameRedactor(options, nestedErrorsAsData = false, coversNames = tr
|
|
|
2573
2587
|
if (!walks && resolveRedactOption(options) === void 0) {
|
|
2574
2588
|
return PASS_THROUGH;
|
|
2575
2589
|
}
|
|
2576
|
-
return nestedErrorsAsData && walks ? createNameRedactor(
|
|
2590
|
+
return nestedErrorsAsData && (walks || !coversNames) ? createNameRedactor(
|
|
2577
2591
|
names,
|
|
2578
2592
|
options.redactCensor,
|
|
2579
2593
|
["err", ...Object.keys(options.serializers)],
|
|
2580
2594
|
void 0,
|
|
2581
|
-
ownFields
|
|
2595
|
+
ownFields,
|
|
2596
|
+
coversNames ? void 0 : namesInsideErrors(options)
|
|
2582
2597
|
) : createNameRedactor(names, options.redactCensor, void 0, void 0, ownFields);
|
|
2583
2598
|
}
|
|
2584
2599
|
function resolveRedactOption(options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bymax-one/nest-logger",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.16",
|
|
4
4
|
"description": "Structured JSON logging for NestJS based on Pino 10, with optional OpenTelemetry correlation.",
|
|
5
5
|
"author": "Bymax One <support@bymax.one>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,7 +63,8 @@
|
|
|
63
63
|
"check:published": "node scripts/check-published-surface.mjs",
|
|
64
64
|
"check:file-length": "node scripts/check-file-length.mjs",
|
|
65
65
|
"clean": "rm -rf dist coverage",
|
|
66
|
-
"
|
|
66
|
+
"check:socket-gate": "node scripts/check-socket-gate.mjs",
|
|
67
|
+
"lint": "eslint src scripts test bench '*.config.ts' '*.config.mjs' '*.config.cjs' && pnpm check:socket-gate",
|
|
67
68
|
"lint:fix": "eslint src scripts test bench '*.config.ts' '*.config.mjs' '*.config.cjs' --fix",
|
|
68
69
|
"mutation": "stryker run",
|
|
69
70
|
"mutation:full": "node -e \"require('node:fs').rmSync('reports/stryker-incremental.json',{force:true,recursive:true})\" && stryker run",
|