Re: [PATCH] rust: log: implement io::Write

2025-06-25 Thread Manos Pitsidianakis
On Tue, Jun 24, 2025 at 10:00 AM Zhao Liu wrote: > > > /// A macro to log messages conditionally based on a provided mask. > > @@ -24,6 +96,8 @@ pub enum Log { > > /// log level and, if so, formats and logs the message. It is the Rust > > /// counterpart of the `qemu_log_mask()` macro in the C

Re: [PATCH] rust: log: implement io::Write

2025-06-24 Thread Zhao Liu
> > @@ -136,8 +137,7 @@ macro_rules! log_mask_ln { > > if unsafe { > > (::qemu_api::bindings::qemu_loglevel & ($mask as > > std::os::raw::c_int)) != 0 > > } { > > -#[allow(unused_must_use)] > > -::qemu_api::log::LogGuard::log_fmt( > > +

Re: [PATCH] rust: log: implement io::Write

2025-06-24 Thread Zhao Liu
> +/// A RAII guard for QEMU's logging infrastructure. Creating the guard > +/// locks the log file, and dropping it (letting it go out of scope) unlocks > +/// the file. > +/// > +/// As long as the guard lives, it can be written to using > [`std::io::Write`]. > +/// > +/// The locking is recurs

Re: [PATCH] rust: log: implement io::Write

2025-06-24 Thread Zhao Liu
> /// A macro to log messages conditionally based on a provided mask. > @@ -24,6 +96,8 @@ pub enum Log { > /// log level and, if so, formats and logs the message. It is the Rust > /// counterpart of the `qemu_log_mask()` macro in the C implementation. > /// > +/// Errors from writing to the log

[PATCH] rust: log: implement io::Write

2025-06-17 Thread Paolo Bonzini
This makes it possible to lock the log file; it also makes log_mask_ln! not allocate memory when logging a constant string. Signed-off-by: Paolo Bonzini --- include/qemu/log.h | 2 + util/log.c | 12 ++ rust/qemu-api/src/log.rs | 87 --