fix(mlx): filter MLX runtime debug and info logs by SDK log level (#984)
Summary
MLXRuntimeLog in bindings/swift/Sources/MLXRuntime/MLX.swift previously wrote all log messages unconditionally to stderr regardless of the configured SDK minimum log level. In applications like wally, every run or serve printed debug lines (such as MLX memory reports) even without -v or when rac_logger_set_min_level(RAC_LOG_ERROR) was set.
This PR dynamically checks the commons log level via rac_logger_get_min_level() (with a safe fallback to RAC_LOG_INFO if unresolved) and filters out messages whose severity is below the minimum log level before writing to stderr.
Fixes #984
Changes
- Defined dynamic symbol resolution for
rac_logger_get_min_levelmatching commons log levels (DEBUG = 1,INFO = 2,WARNING = 3,ERROR = 4). - Updated
MLXRuntimeLog.writeto inspectSelf.currentMinLeveland early-return if message severity is below the threshold. - Warnings and errors continue to print as expected unless explicitly suppressed by higher log thresholds.
Validation
swiftc -parse bindings/swift/Sources/MLXRuntime/MLX.swiftpasses cleanly.- Verified dynamic lookup with
dlsym(UnsafeMutableRawPointer(bitPattern: -2), "rac_logger_get_min_level")adheres to Darwin conventions used throughoutRunAnywherebridge modules.
Summary by cubic
Fixes #984 by filtering MLX runtime debug and info logs through the SDK's configured minimum log level, so noisy messages no longer print to stderr in apps without verbose logging enabled.
- Dynamically resolves
rac_logger_get_min_level, falling back toRAC_LOG_INFOwhen unavailable. - Drops messages below the current minimum log severity; warnings and errors still print as before.
Summary by CodeRabbit
- Bug Fixes
- Log messages now follow the configured minimum severity: lower-severity messages are suppressed, while debug, informational, warning, and error messages are classified consistently. If a minimum severity setting is unavailable, informational messages and higher are displayed.