@putkoff/abstract-logger 0.0.37 â 0.0.39
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/dist/cjs/index.js +36 -20
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +36 -20
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -14759,9 +14759,21 @@ function shouldShowDetails(logType) {
|
|
|
14759
14759
|
}
|
|
14760
14760
|
return cfg.showDetails;
|
|
14761
14761
|
}
|
|
14762
|
-
function serializeDetails(value, condensed, maxLength, pretty
|
|
14763
|
-
) {
|
|
14762
|
+
function serializeDetails(value, condensed, maxLength, pretty) {
|
|
14764
14763
|
try {
|
|
14764
|
+
// đ DETECT STRINGIFIED JSON
|
|
14765
|
+
if (typeof value === "string") {
|
|
14766
|
+
const trimmed = value.trim();
|
|
14767
|
+
if ((trimmed.startsWith("{") && trimmed.endsWith("}")) ||
|
|
14768
|
+
(trimmed.startsWith("[") && trimmed.endsWith("]"))) {
|
|
14769
|
+
try {
|
|
14770
|
+
value = JSON.parse(trimmed);
|
|
14771
|
+
}
|
|
14772
|
+
catch {
|
|
14773
|
+
// fall through â leave as string
|
|
14774
|
+
}
|
|
14775
|
+
}
|
|
14776
|
+
}
|
|
14765
14777
|
const seen = new WeakSet();
|
|
14766
14778
|
const json = JSON.stringify(value, (key, val) => {
|
|
14767
14779
|
if (typeof val === "function")
|
|
@@ -14774,8 +14786,7 @@ function serializeDetails(value, condensed, maxLength, pretty // đ new
|
|
|
14774
14786
|
seen.add(val);
|
|
14775
14787
|
}
|
|
14776
14788
|
return val;
|
|
14777
|
-
}, pretty && !condensed ? 2 : 0
|
|
14778
|
-
);
|
|
14789
|
+
}, pretty && !condensed ? 2 : 0);
|
|
14779
14790
|
if (condensed && json.length > maxLength) {
|
|
14780
14791
|
return json.slice(0, maxLength) + "âĻ";
|
|
14781
14792
|
}
|
|
@@ -14881,30 +14892,35 @@ function getLogString(messageOrOptions, logType = null, details = null, function
|
|
|
14881
14892
|
resolvedFunctionName = resolveValue(resolvedFunctionName, caller.functionName);
|
|
14882
14893
|
resolvedFileLocation = resolveValue(resolvedFileLocation, caller.file);
|
|
14883
14894
|
const finalLogType = resolvedLogType ?? "info";
|
|
14884
|
-
const emoji = activityEmojiMap[
|
|
14895
|
+
const emoji = activityEmojiMap[logType ?? ""] ??
|
|
14885
14896
|
"âšī¸";
|
|
14886
|
-
const
|
|
14897
|
+
const LOG_CONFIG = getLogConfig();
|
|
14887
14898
|
const condense = shouldCondense(finalLogType);
|
|
14888
14899
|
const showDetails = shouldShowDetails(finalLogType);
|
|
14900
|
+
// đ ADD THIS
|
|
14901
|
+
const pretty = LOG_CONFIG.prettyDetails &&
|
|
14902
|
+
!condense;
|
|
14903
|
+
const timestamp = new Date().toISOString();
|
|
14889
14904
|
if (condense) {
|
|
14890
14905
|
resolvedFileLocation = resolvedFileLocation.split("/").pop();
|
|
14891
14906
|
}
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
const fileName = padRight(resolvedFileLocation.trim(), COLS.file);
|
|
14896
|
-
let line = `${emojiCol}` +
|
|
14897
|
-
`[${ts}] ` +
|
|
14898
|
-
`[${fn}] ` +
|
|
14899
|
-
`${message}`;
|
|
14907
|
+
padRight(emoji, 3);
|
|
14908
|
+
padRight(timestamp, COLS.timestamp);
|
|
14909
|
+
padRight(resolvedFileLocation.trim(), COLS.file);
|
|
14900
14910
|
if (showDetails && resolvedDetails !== null && resolvedDetails !== undefined) {
|
|
14901
|
-
|
|
14902
|
-
const serialized = serializeDetails(resolvedDetails, condense, LOG_CONFIG.maxDetailsLength, LOG_CONFIG.prettyDetails // đ HERE
|
|
14903
|
-
);
|
|
14904
|
-
line += ` | ${serialized}`;
|
|
14911
|
+
serializeDetails(resolvedDetails, condense, LOG_CONFIG.maxDetailsLength, pretty);
|
|
14905
14912
|
}
|
|
14906
|
-
|
|
14907
|
-
|
|
14913
|
+
return getFinalLine(formatLogLine({
|
|
14914
|
+
emoji,
|
|
14915
|
+
timestamp,
|
|
14916
|
+
functionName: resolvedFunctionName,
|
|
14917
|
+
message,
|
|
14918
|
+
details: showDetails ? resolvedDetails : undefined,
|
|
14919
|
+
file: resolvedFileLocation,
|
|
14920
|
+
condense,
|
|
14921
|
+
maxDetailsLength: LOG_CONFIG.maxDetailsLength,
|
|
14922
|
+
pretty, // đ THIS IS THE MISSING WIRE
|
|
14923
|
+
}), finalLogType, resolvedLoggerInput);
|
|
14908
14924
|
}
|
|
14909
14925
|
|
|
14910
14926
|
exports.COLS = COLS;
|