@putkoff/abstract-logger 0.0.38 → 0.0.40

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 CHANGED
@@ -14759,9 +14759,21 @@ function shouldShowDetails(logType) {
14759
14759
  }
14760
14760
  return cfg.showDetails;
14761
14761
  }
14762
- function serializeDetails(value, condensed, maxLength, pretty // 👈 new
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 // 👈 HERE
14778
- );
14789
+ }, pretty && !condensed ? 2 : 0);
14779
14790
  if (condensed && json.length > maxLength) {
14780
14791
  return json.slice(0, maxLength) + "â€Ļ";
14781
14792
  }
@@ -14881,7 +14892,7 @@ 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[opts.activity ?? ""] ??
14895
+ const emoji = activityEmojiMap[resolvedLogType ?? ""] ??
14885
14896
  "â„šī¸";
14886
14897
  const LOG_CONFIG = getLogConfig();
14887
14898
  const condense = shouldCondense(finalLogType);