Skip to content

linux-rust: log device status in headless mode#641

Open
cristianrubioa wants to merge 1 commit into
kavishdevar:linux/rustfrom
cristianrubioa:linux-rust-headless-console-output
Open

linux-rust: log device status in headless mode#641
cristianrubioa wants to merge 1 commit into
kavishdevar:linux/rustfrom
cristianrubioa:linux-rust-headless-console-output

Conversation

@cristianrubioa

Copy link
Copy Markdown

Summary

  • In --no-tray (headless) mode, the BluetoothUIMessage channel (connection, battery, noise control mode) was produced but never consumed — headless users had no visibility into device state.
  • Adds linux-rust/src/headless.rs: a small console consumer that logs each field (connection, battery per component, noise control mode) only when it changes since the last observation, reusing the existing AirPodsNoiseControlMode decoding already used by the GUI.
  • Cleans up logger initialization in main.rs into an explicit env_logger::Builder call instead of mutating RUST_LOG via an unsafe env::set_var, while still respecting a user-provided RUST_LOG.
  • No new dependencies, no TUI/dashboard, no new IPC surface — output stays plain log-crate lines, consistent with the rest of the app.

Test plan

  • cargo build / cargo check pass cleanly, no new warnings
  • Verified live with real AirPods Pro hardware in --no-tray --debug: connect, battery (incl. disconnected case), and noise control mode changes each logged exactly once, decoded to human-readable names
  • Verified GUI mode (without --no-tray) is unaffected — window/tray opens normally, no headless module output in that path

In --no-tray mode the BluetoothUIMessage channel (connection, battery,
noise control mode) was produced but never consumed, leaving headless
users with no visibility into device state. Add a small console
consumer that logs each field only when it changes. Also moves logger
setup into an explicit env_logger::Builder instead of mutating
RUST_LOG via an unsafe env::set_var call.
Copilot AI review requested due to automatic review settings June 19, 2026 06:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a headless-mode (--no-tray) consumer for BluetoothUIMessage so device state changes (connection, battery, noise control mode) become visible via standard log output, and refactors logger initialization to avoid mutating RUST_LOG.

Changes:

  • Introduce linux-rust/src/headless.rs to log device connection/battery/noise-control changes only when they differ from the last observed values.
  • Wire the headless console consumer into the --no-tray execution path in main.rs.
  • Replace unsafe env::set_var("RUST_LOG", ...) + env_logger::init() with an explicit env_logger::Builder-based initialization.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
linux-rust/src/main.rs Adds headless module wiring and refactors logging initialization/default filter logic.
linux-rust/src/headless.rs Implements the headless console consumer that logs state changes from BluetoothUIMessage.

Comment thread linux-rust/src/main.rs
Comment on lines +52 to +54
/// Default log filter: app modules at `app_level`, known-noisy external crates kept quiet
/// unless the user already set `RUST_LOG` themselves, in which case that takes precedence.
fn default_log_filter(debug: bool, le_debug: bool) -> String {
Comment thread linux-rust/src/main.rs
Comment on lines +62 to +69
fn init_logging(debug: bool, le_debug: bool) {
let mut builder = env_logger::Builder::new();
match env::var("RUST_LOG") {
Ok(filter) => builder.parse_filters(&filter),
Err(_) => builder.parse_filters(&default_log_filter(debug, le_debug)),
};
builder.format_timestamp_secs().init();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants