Use log, env_logger crates to log warnings instead of using eprintln!() macro

This commit is contained in:
Tom A. Wagner
2021-01-12 09:48:59 +01:00
parent 181661a2db
commit 5bf62eca6e
5 changed files with 12 additions and 6 deletions

2
Cargo.lock generated
View File

@@ -467,7 +467,9 @@ dependencies = [
name = "graphui-rs"
version = "0.0.1"
dependencies = [
"env_logger",
"gtk4",
"log",
"pipewire",
]

View File

@@ -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"

View File

@@ -15,7 +15,9 @@ pub struct PipewireLink {
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
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,

View File

@@ -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
);

View File

@@ -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
);
}
}