@adaptic/utils 0.0.955 → 0.0.957

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/index.cjs CHANGED
@@ -5275,7 +5275,12 @@ const API_RETRY_CONFIGS = {
5275
5275
  // Utility function for debug logging
5276
5276
  /**
5277
5277
  * Debug logging utility that respects environment debug flags.
5278
- * Logs messages to the console based on the specified log level.
5278
+ * Logs messages through the configured structured logger when LUMIC_DEBUG
5279
+ * is enabled. The level is preserved by routing through the corresponding
5280
+ * logger method — the structured logger already encodes the level, so we
5281
+ * do NOT prefix the message text with `[DEBUG][LEVEL]` (that produced
5282
+ * malformed `[INFO] [DEBUG][INFO] ...` lines in downstream consumers
5283
+ * that wrap this logger with Pino).
5279
5284
  *
5280
5285
  * @param message - The message to log.
5281
5286
  * @param data - Optional data to log alongside the message. This can be any type of data.
@@ -5292,31 +5297,29 @@ const logIfDebug = (message, data, type = "info") => {
5292
5297
  false;
5293
5298
  if (!debugMode)
5294
5299
  return;
5295
- const prefix = `[DEBUG][${type.toUpperCase()}]`;
5296
5300
  const logger = getLogger();
5297
5301
  const context = data !== undefined
5298
5302
  ? typeof data === "object" && data !== null
5299
5303
  ? data
5300
5304
  : { data }
5301
5305
  : undefined;
5302
- const fullMessage = prefix + " " + message;
5303
5306
  switch (type) {
5304
5307
  case "error":
5305
- logger.error(fullMessage, context);
5308
+ logger.error(message, context);
5306
5309
  break;
5307
5310
  case "warn":
5308
- logger.warn(fullMessage, context);
5311
+ logger.warn(message, context);
5309
5312
  break;
5310
5313
  case "debug":
5311
- logger.debug(fullMessage, context);
5314
+ logger.debug(message, context);
5312
5315
  break;
5313
5316
  case "trace":
5314
5317
  // trace maps to debug in our logger interface
5315
- logger.debug(fullMessage, context);
5318
+ logger.debug(message, context);
5316
5319
  break;
5317
5320
  case "info":
5318
5321
  default:
5319
- logger.info(fullMessage, context);
5322
+ logger.info(message, context);
5320
5323
  }
5321
5324
  };
5322
5325
  /**
@@ -8341,7 +8344,7 @@ const fetchTrades = async (symbol, options) => {
8341
8344
  return massiveLimit(async () => {
8342
8345
  const url = `${baseUrl}?${params.toString()}`;
8343
8346
  try {
8344
- getLogger().info(`[DEBUG] Fetching trades for ${symbol} from ${url}`);
8347
+ logIfDebug(`Fetching trades for ${symbol} from ${url}`);
8345
8348
  const response = await fetchWithRetry(url, {}, 3, 1000);
8346
8349
  const data = (await response.json());
8347
8350
  if ("message" in data) {