From 5bf62eca6edf880aa80fc1dfb9226701386ff8b8 Mon Sep 17 00:00:00 2001 From: "Tom A. Wagner" Date: Tue, 12 Jan 2021 09:48:59 +0100 Subject: [PATCH] Use log, env_logger crates to log warnings instead of using eprintln!() macro --- Cargo.lock | 2 ++ Cargo.toml | 3 +++ src/main.rs | 2 ++ src/pipewire_state.rs | 3 +-- src/view/graph_view.rs | 8 ++++---- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 84fadc7..1b790ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -467,7 +467,9 @@ dependencies = [ name = "graphui-rs" version = "0.0.1" dependencies = [ + "env_logger", "gtk4", + "log", "pipewire", ] diff --git a/Cargo.toml b/Cargo.toml index 970e7bd..b6f4e74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,3 +9,6 @@ edition = "2018" [dependencies] pipewire = { git = "https://gitlab.freedesktop.org/gdesmott/pipewire-rs", branch = "proxies"} gtk = { git = "https://github.com/gtk-rs/gtk4-rs/", package = "gtk4" } + +log = "0.4.11" +env_logger = "0.8.2" diff --git a/src/main.rs b/src/main.rs index 32bb944..7e032c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,9 @@ pub struct PipewireLink { } fn main() -> Result<(), Box> { + env_logger::init(); gtk::init()?; + let graphview = Rc::new(RefCell::new(view::GraphView::new())); // Create the connection to the pipewire server and do an initial roundtrip before showing the view, diff --git a/src/pipewire_state.rs b/src/pipewire_state.rs index 5fc8a62..e88855f 100644 --- a/src/pipewire_state.rs +++ b/src/pipewire_state.rs @@ -145,8 +145,7 @@ impl PipewireState { self.items.remove(&id); } else { - // FIXME: Switch to log macro - eprintln!( + log::warn!( "Attempted to remove item with id {} that is not saved in state", id ); diff --git a/src/view/graph_view.rs b/src/view/graph_view.rs index 1c09935..f4259ad 100644 --- a/src/view/graph_view.rs +++ b/src/view/graph_view.rs @@ -124,8 +124,7 @@ mod imp { cr.curve_to(from_x + 75.0, from_y, to_x - 75.0, to_y, to_x, to_y); cr.stroke(); } else { - eprintln!("Could not get allocation of ports of link: {:?}", link); - // FIXME: Log an info instead. + log::warn!("Could not get allocation of ports of link: {:?}", link); } } @@ -220,9 +219,10 @@ impl GraphView { node.add_port(port_id, port); } else { // FIXME: Log this instead - eprintln!( + log::error!( "Node with id {} not found when trying to add port with id {} to graph", - node_id, port_id + node_id, + port_id ); } }