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