Krolyxon
Commit feb7482

Branches

Refs →

budctlfeb7482

The worker reports the idle close once

With debug on, the Android app showed "session closed after 10 s"
twice: the worker sent it as a debug note and as a log line, and on
Android both go to the same log. The worker now only logs it.

The desktop app keeps the line on stderr with --debug: its Report
echoes the worker's lines there when debug is on, so the commands,
connects and failures also show between the frames, as on the phone.
Author
krolyxon
Date
2026-11-01 22:37 +0530
Parent
744d2be
Commit
feb7482d2a98014981417a6c84d202477f3879c2

+7 −4

2 files changed

  1. M crates/budctl-core/src/worker.rs +2 −3
  2. M crates/budctl-gui/src/worker.rs +5 −1
M crates/budctl-core/src/worker.rs View
@@ -10,7 +10,6 @@ use std::sync::mpsc::{self, Receiver, RecvTimeoutError, Sender};
1010 use std::thread;
1111 use std::time::{Duration, Instant};
1212
13−use crate::debug;
1413 use crate::devices::Session;
1514 use crate::error::{Error, Kind, Result};
1615 use crate::status::{
@@ -108,7 +107,8 @@ pub trait Report: Send {
108107 /// An answer to a command, or [`Event::Found`] or [`Event::Lost`].
109108 fn event(&self, event: Event);
110109
111− /// A line for the front end's log: each command, sessions opening and closing, failures.
110+ /// A line for the front end's log: each command, sessions opening and closing, failures. A
111+ /// front end that prints debug output elsewhere shows these there too, as context.
112112 fn log(&self, line: &str);
113113 }
114114
@@ -176,7 +176,6 @@ impl Worker {
176176 if self.last_command.elapsed() >= self.idle {
177177 self.session = None;
178178 let message = format!("session closed after {} s without a command", self.idle.as_secs());
179− debug::note(|| message.clone());
180179 self.report.log(&message);
181180 } else if let Err(error) = session.serve() {
182181 self.session = None;
M crates/budctl-gui/src/worker.rs View
@@ -36,7 +36,8 @@ pub fn run(&(device, idle): &(Option<BdAddr>, Duration)) -> impl Stream<Item = M
3636 })
3737 }
3838
39−/// The window's side of the worker: events go to the subscription, lines to the GUI's log.
39+/// The window's side of the worker: events go to the subscription, lines to the GUI's log and,
40+/// with `--debug`, between the frames on stderr.
4041 struct Window(channel::UnboundedSender<Event>);
4142
4243 impl Report for Window {
@@ -46,6 +47,9 @@ impl Report for Window {
4647 }
4748
4849 fn log(&self, line: &str) {
50+ if budctl_core::debug::enabled() {
51+ eprintln!("# {line}");
52+ }
4953 log::line(line);
5054 }
5155 }