@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 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,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[opts.activity ?? ""] ??
14895
+ const emoji = activityEmojiMap[logType ?? ""] ??
14885
14896
  "â„šī¸";
14886
- const timestamp = new Date().toISOString();
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
- const emojiCol = padRight(emoji, 3);
14893
- const ts = padRight(timestamp, COLS.timestamp);
14894
- const fn = resolvedFunctionName;
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
- const LOG_CONFIG = getLogConfig();
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
- line += ` | ${fileName}`;
14907
- return getFinalLine(line, finalLogType, resolvedLoggerInput);
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;