GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
refactor: modernize and systematize workspace logging
Cargo.toml | 2 ++
src/backend/window_runner.rs | 6 +++---
src/color.rs | 2 +-
src/main.rs | 6 +++---
src/widget/display/graph.rs | 26 +++++++++++++-------------
src/widget/input/color_selector.rs | 2 +-
6 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 86d9517..9e659f1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,4 +26,6 @@ resvg = "0.41.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
libc = "0.2"
+log = "0.4"
+
diff --git a/src/backend/window_runner.rs b/src/backend/window_runner.rs
index f957310..b5bc5e1 100644
--- a/src/backend/window_runner.rs
+++ b/src/backend/window_runner.rs
@@ -1287,7 +1287,7 @@ impl<A: Application> EngineState<A> {
}
Err(wgpu::SurfaceError::Timeout) => return,
Err(e) => {
- eprintln!("Surface error: {e:?}");
+ log::error!("Surface error: {e:?}");
return;
}
};
@@ -1433,7 +1433,7 @@ impl<A: Application> EngineState<A> {
}
Err(wgpu::SurfaceError::Timeout) => return,
Err(e) => {
- eprintln!("Popup surface error: {e:?}");
+ log::error!("Popup surface error: {e:?}");
return;
}
};
@@ -2177,7 +2177,7 @@ pub fn run<A: Application>() {
let mut last_tick = std::time::Instant::now();
loop {
if let Err(e) = event_loop.dispatch(std::time::Duration::from_millis(16), &mut engine_state) {
- eprintln!("[window_runner] Event loop error: {:?}", e);
+ log::error!("[window_runner] Event loop error: {:?}", e);
break;
}
if engine_state.exit {
diff --git a/src/color.rs b/src/color.rs
index ce43de7..9c7a35e 100644
--- a/src/color.rs
+++ b/src/color.rs
@@ -93,7 +93,7 @@ fn parse_and_set_colors(content: &str) {
let val: serde_json::Value = match serde_json::from_str(content) {
Ok(v) => v,
Err(e) => {
- eprintln!("JSON parse error: {}", e);
+ log::error!("JSON parse error: {}", e);
return;
}
};
diff --git a/src/main.rs b/src/main.rs
index d0905b3..1783f56 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -855,7 +855,7 @@ impl State {
}
Err(wgpu::SurfaceError::Timeout) => return,
Err(e) => {
- eprintln!("Surface error: {e:?}");
+ log::error!("Surface error: {e:?}");
return;
}
};
@@ -1636,13 +1636,13 @@ fn main() {
json_layout_config = Some(cfg);
}
Err(e) => {
- eprintln!("Failed to parse JSON layout: {}", e);
+ log::error!("Failed to parse JSON layout: {}", e);
std::process::exit(1);
}
}
}
Err(e) => {
- eprintln!("Failed to read JSON layout from stdin: {}", e);
+ log::error!("Failed to read JSON layout from stdin: {}", e);
std::process::exit(1);
}
}
diff --git a/src/widget/display/graph.rs b/src/widget/display/graph.rs
index 0afff61..e2b9b77 100644
--- a/src/widget/display/graph.rs
+++ b/src/widget/display/graph.rs
@@ -386,7 +386,7 @@ impl Element for Graph {
if button != MouseButton::Left { return false; }
match state {
ElementState::Pressed => {
- println!("DEBUG Graph::mouse_input: Pressed px={}, py={}, connecting_from={:?}", px, py, self.connecting_from);
+ log::debug!("Graph::mouse_input: Pressed px={}, py={}, connecting_from={:?}", px, py, self.connecting_from);
// First, check direct port clicks
for i in (0..self.nodes.len()).rev() {
if let Some((nx, ny, nw, nh)) = self.node_rect(i) {
@@ -401,7 +401,7 @@ impl Element for Graph {
let port_y = ny;
let dx = px - port_x;
let dy = py - port_y;
- println!(" Checking input node={} port={} port_x={} port_y={} dist_sq={}", node.name, k, port_x, port_y, dx*dx + dy*dy);
+ log::debug!(" Checking input node={} port={} port_x={} port_y={} dist_sq={}", node.name, k, port_x, port_y, dx*dx + dy*dy);
if dx * dx + dy * dy <= port_click_radius_sq {
if let Some((src_idx, src_port_type, _src_port_idx)) = self.connecting_from {
if src_idx != i && src_port_type == PortType::Output {
@@ -409,17 +409,17 @@ impl Element for Graph {
let input_node = &self.nodes[i];
self.pending_connection = Some((input_node.id.clone(), output_node.name.clone()));
self.connecting_from = None;
- println!(" Port connection created: Input={} from Output={}", input_node.name, output_node.name);
+ log::debug!(" Port connection created: Input={} from Output={}", input_node.name, output_node.name);
return true;
} else {
self.connecting_from = None;
- println!(" Port connection aborted (same node or incompatible ports)");
+ log::debug!(" Port connection aborted (same node or incompatible ports)");
return true;
}
} else {
self.connecting_from = Some((i, PortType::Input, k));
self.current_mouse_pos = (px, py);
- println!(" Start connecting from Input port of node={}", node.name);
+ log::debug!(" Start connecting from Input port of node={}", node.name);
return true;
}
}
@@ -431,7 +431,7 @@ impl Element for Graph {
let port_y = ny + nh;
let dx = px - port_x;
let dy = py - port_y;
- println!(" Checking output node={} port={} port_x={} port_y={} dist_sq={}", node.name, k, port_x, port_y, dx*dx + dy*dy);
+ log::debug!(" Checking output node={} port={} port_x={} port_y={} dist_sq={}", node.name, k, port_x, port_y, dx*dx + dy*dy);
if dx * dx + dy * dy <= port_click_radius_sq {
if let Some((src_idx, src_port_type, _src_port_idx)) = self.connecting_from {
if src_idx != i && src_port_type == PortType::Input {
@@ -439,17 +439,17 @@ impl Element for Graph {
let input_node = &self.nodes[src_idx];
self.pending_connection = Some((input_node.id.clone(), output_node.name.clone()));
self.connecting_from = None;
- println!(" Port connection created: Input={} from Output={}", input_node.name, output_node.name);
+ log::debug!(" Port connection created: Input={} from Output={}", input_node.name, output_node.name);
return true;
} else {
self.connecting_from = None;
- println!(" Port connection aborted (same node or incompatible ports)");
+ log::debug!(" Port connection aborted (same node or incompatible ports)");
return true;
}
} else {
self.connecting_from = Some((i, PortType::Output, k));
self.current_mouse_pos = (px, py);
- println!(" Start connecting from Output port of node={}", node.name);
+ log::debug!(" Start connecting from Output port of node={}", node.name);
return true;
}
}
@@ -462,7 +462,7 @@ impl Element for Graph {
for i in (0..self.nodes.len()).rev() {
if src_idx != i {
if let Some((nx, ny, nw, nh)) = self.node_rect(i) {
- println!(" Checking fallback body node={} nx={} ny={} nw={} nh={}", self.nodes[i].name, nx, ny, nw, nh);
+ log::debug!(" Checking fallback body node={} nx={} ny={} nw={} nh={}", self.nodes[i].name, nx, ny, nw, nh);
if px >= nx && px < nx + nw && py >= ny && py < ny + nh {
let node = &self.nodes[i];
if src_port_type == PortType::Output && node.inputs > 0 {
@@ -470,14 +470,14 @@ impl Element for Graph {
let input_node = &self.nodes[i];
self.pending_connection = Some((input_node.id.clone(), output_node.name.clone()));
self.connecting_from = None;
- println!(" Fallback connection created: Input={} from Output={}", input_node.name, output_node.name);
+ log::debug!(" Fallback connection created: Input={} from Output={}", input_node.name, output_node.name);
return true;
} else if src_port_type == PortType::Input && node.outputs > 0 {
let output_node = &self.nodes[i];
let input_node = &self.nodes[src_idx];
self.pending_connection = Some((input_node.id.clone(), output_node.name.clone()));
self.connecting_from = None;
- println!(" Fallback connection created: Input={} from Output={}", input_node.name, output_node.name);
+ log::debug!(" Fallback connection created: Input={} from Output={}", input_node.name, output_node.name);
return true;
}
}
@@ -487,7 +487,7 @@ impl Element for Graph {
}
if self.connecting_from.is_some() {
- println!(" Clearing connecting_from because it didn't hit any ports or node bodies");
+ log::debug!(" Clearing connecting_from because it didn't hit any ports or node bodies");
self.connecting_from = None;
}
diff --git a/src/widget/input/color_selector.rs b/src/widget/input/color_selector.rs
index d009036..026aa57 100644
--- a/src/widget/input/color_selector.rs
+++ b/src/widget/input/color_selector.rs
@@ -251,7 +251,7 @@ impl Element for ColorSelector {
}
Ok(None) => {}
Err(e) => {
- eprintln!("Error checking color selector child process: {:?}", e);
+ log::error!("Error checking color selector child process: {:?}", e);
*child_opt = None;
}
}