@voltagent/core 1.1.35 → 1.1.36

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.d.mts CHANGED
@@ -1307,6 +1307,10 @@ declare class LoggerProxy implements Logger {
1307
1307
  * Get the actual logger instance with bindings applied
1308
1308
  */
1309
1309
  private getActualLogger;
1310
+ /**
1311
+ * Check if a log level should be logged based on the configured level
1312
+ */
1313
+ private shouldLog;
1310
1314
  /**
1311
1315
  * Emit log via OpenTelemetry Logs API if available
1312
1316
  */
package/dist/index.d.ts CHANGED
@@ -1307,6 +1307,10 @@ declare class LoggerProxy implements Logger {
1307
1307
  * Get the actual logger instance with bindings applied
1308
1308
  */
1309
1309
  private getActualLogger;
1310
+ /**
1311
+ * Check if a log level should be logged based on the configured level
1312
+ */
1313
+ private shouldLog;
1310
1314
  /**
1311
1315
  * Emit log via OpenTelemetry Logs API if available
1312
1316
  */
package/dist/index.js CHANGED
@@ -1190,10 +1190,10 @@ var ConsoleLogger = class _ConsoleLogger {
1190
1190
  msg = args[0] || "";
1191
1191
  obj = msgOrObj;
1192
1192
  }
1193
+ this.emitOtelLog(level, msg, obj);
1193
1194
  if (this.shouldLog(level)) {
1194
1195
  consoleFn(this.formatMessage(level, msg, obj));
1195
1196
  }
1196
- this.emitOtelLog(level, msg, obj);
1197
1197
  };
1198
1198
  }
1199
1199
  trace = this.createLogFn("trace", console.debug);
@@ -1377,6 +1377,28 @@ var LoggerProxy = class _LoggerProxy {
1377
1377
  const baseLogger = this.externalLogger || getGlobalLogger();
1378
1378
  return Object.keys(this.bindings).length > 0 ? baseLogger.child(this.bindings) : baseLogger;
1379
1379
  }
1380
+ /**
1381
+ * Check if a log level should be logged based on the configured level
1382
+ */
1383
+ shouldLog(messageLevel) {
1384
+ const logger = this.getActualLogger();
1385
+ let configuredLevel;
1386
+ if (logger._pinoInstance?.level) {
1387
+ configuredLevel = logger._pinoInstance.level;
1388
+ } else if (logger.level !== void 0) {
1389
+ configuredLevel = logger.level;
1390
+ }
1391
+ if (!configuredLevel) {
1392
+ return true;
1393
+ }
1394
+ const levels = ["trace", "debug", "info", "warn", "error", "fatal"];
1395
+ const configuredLevelIndex = levels.indexOf(configuredLevel.toLowerCase());
1396
+ const messageLevelIndex = levels.indexOf(messageLevel.toLowerCase());
1397
+ if (configuredLevelIndex === -1 || messageLevelIndex === -1) {
1398
+ return true;
1399
+ }
1400
+ return messageLevelIndex >= configuredLevelIndex;
1401
+ }
1380
1402
  /**
1381
1403
  * Emit log via OpenTelemetry Logs API if available
1382
1404
  */
@@ -1414,34 +1436,40 @@ var LoggerProxy = class _LoggerProxy {
1414
1436
  }
1415
1437
  }
1416
1438
  trace = /* @__PURE__ */ __name((msg, context8) => {
1439
+ this.emitOtelLog("trace", msg, context8);
1440
+ if (!this.shouldLog("trace")) return;
1417
1441
  const logger = this.getActualLogger();
1418
1442
  logger.trace(msg, context8);
1419
- this.emitOtelLog("trace", msg, context8);
1420
1443
  }, "trace");
1421
1444
  debug = /* @__PURE__ */ __name((msg, context8) => {
1445
+ this.emitOtelLog("debug", msg, context8);
1446
+ if (!this.shouldLog("debug")) return;
1422
1447
  const logger = this.getActualLogger();
1423
1448
  logger.debug(msg, context8);
1424
- this.emitOtelLog("debug", msg, context8);
1425
1449
  }, "debug");
1426
1450
  info = /* @__PURE__ */ __name((msg, context8) => {
1451
+ this.emitOtelLog("info", msg, context8);
1452
+ if (!this.shouldLog("info")) return;
1427
1453
  const logger = this.getActualLogger();
1428
1454
  logger.info(msg, context8);
1429
- this.emitOtelLog("info", msg, context8);
1430
1455
  }, "info");
1431
1456
  warn = /* @__PURE__ */ __name((msg, context8) => {
1457
+ this.emitOtelLog("warn", msg, context8);
1458
+ if (!this.shouldLog("warn")) return;
1432
1459
  const logger = this.getActualLogger();
1433
1460
  logger.warn(msg, context8);
1434
- this.emitOtelLog("warn", msg, context8);
1435
1461
  }, "warn");
1436
1462
  error = /* @__PURE__ */ __name((msg, context8) => {
1463
+ this.emitOtelLog("error", msg, context8);
1464
+ if (!this.shouldLog("error")) return;
1437
1465
  const logger = this.getActualLogger();
1438
1466
  logger.error(msg, context8);
1439
- this.emitOtelLog("error", msg, context8);
1440
1467
  }, "error");
1441
1468
  fatal = /* @__PURE__ */ __name((msg, context8) => {
1469
+ this.emitOtelLog("fatal", msg, context8);
1470
+ if (!this.shouldLog("fatal")) return;
1442
1471
  const logger = this.getActualLogger();
1443
1472
  logger.fatal(msg, context8);
1444
- this.emitOtelLog("fatal", msg, context8);
1445
1473
  }, "fatal");
1446
1474
  /**
1447
1475
  * Create a child logger with additional bindings