pub struct Logger { /* private fields */ }
Expand description
Configuration and state for logging USB device events.
The logger handles output formatting and can write to both console and log files simultaneously.
Implementations§
Source§impl Logger
impl Logger
Sourcepub fn new(
output_json: bool,
log_file_path: Option<&str>,
colorful: bool,
) -> Result<Self, Box<dyn Error>>
pub fn new( output_json: bool, log_file_path: Option<&str>, colorful: bool, ) -> Result<Self, Box<dyn Error>>
Creates a new logger instance.
§Arguments
output_json
- Whether to format output as JSONlog_file_path
- Optional path to a log filecolorful
- Whether to use coloured output (ignored for JSON mode)
§Errors
Returns an error if the log file cannot be created or opened.
§Examples
use usbwatch_rs::logger::Logger;
// Console-only logger with plain text and colours
let logger = Logger::new(false, None, true)?;
// JSON logger with file output
let logger = Logger::new(true, Some("usb-events.json"), true)?;
Sourcepub fn log_device_event(
&mut self,
device_info: &UsbDeviceInfo,
) -> Result<(), Box<dyn Error>>
pub fn log_device_event( &mut self, device_info: &UsbDeviceInfo, ) -> Result<(), Box<dyn Error>>
Auto Trait Implementations§
impl Freeze for Logger
impl RefUnwindSafe for Logger
impl Send for Logger
impl Sync for Logger
impl Unpin for Logger
impl UnwindSafe for Logger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more