Skip to content

Commit

Permalink
feat: Switch log with tracing and parallel image alterations (#68)
Browse files Browse the repository at this point in the history
* Replace log with tracing and env_logger with tracing-subscriber.

* Don't make --debug conflict with --stdout, use stderr for tracing.

* Parallel processing achieved through scoped threads and rayon.

Co-authored-by: Shinyzenith <aakashsensharma@gmail.com>
Signed-off-by: Shinyzenith <aakashsensharma@gmail.com>
  • Loading branch information
AndreasBackx and Shinyzenith authored Oct 12, 2023
1 parent d7467df commit 6d3da9a
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 193 deletions.
147 changes: 98 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libwayshot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ edition = "2021"

[dependencies]
image = { version = "0.24", default-features = false }
log = "0.4.20"
memmap2 = "0.9.0"
nix = { version = "0.27.1", features = ["fs", "mman"] }
thiserror = "1"
tracing = "0.1.37"
wayland-client = "0.31.1"
wayland-protocols = { version = "0.31.0", features = ["client", "unstable"] }
wayland-protocols-wlr = { version = "0.2.0", features = ["client"] }
22 changes: 11 additions & 11 deletions libwayshot/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl Dispatch<WlRegistry, ()> for OutputCaptureState {
},
});
} else {
log::error!("Ignoring a wl_output with version < 4.");
tracing::error!("Ignoring a wl_output with version < 4.");
}
}
}
Expand Down Expand Up @@ -128,12 +128,12 @@ impl Dispatch<ZxdgOutputV1, usize> for OutputCaptureState {
zxdg_output_v1::Event::LogicalPosition { x, y } => {
output_info.dimensions.x = x;
output_info.dimensions.y = y;
log::debug!("Logical position event fired!");
tracing::debug!("Logical position event fired!");
}
zxdg_output_v1::Event::LogicalSize { width, height } => {
output_info.dimensions.width = width;
output_info.dimensions.height = height;
log::debug!("Logical size event fired!");
tracing::debug!("Logical size event fired!");
}
_ => {}
};
Expand Down Expand Up @@ -171,7 +171,7 @@ impl Dispatch<ZwlrScreencopyFrameV1, ()> for CaptureFrameState {
height,
stride,
} => {
log::debug!("Received Buffer event");
tracing::debug!("Received Buffer event");
if let Value(f) = format {
frame.formats.push(FrameFormat {
format: f,
Expand All @@ -180,31 +180,31 @@ impl Dispatch<ZwlrScreencopyFrameV1, ()> for CaptureFrameState {
stride,
})
} else {
log::debug!("Received Buffer event with unidentified format");
tracing::debug!("Received Buffer event with unidentified format");
exit(1);
}
}
zwlr_screencopy_frame_v1::Event::Flags { .. } => {
log::debug!("Received Flags event");
tracing::debug!("Received Flags event");
}
zwlr_screencopy_frame_v1::Event::Ready { .. } => {
// If the frame is successfully copied, a “flags” and a “ready” events are sent. Otherwise, a “failed” event is sent.
// This is useful when we call .copy on the frame object.
log::debug!("Received Ready event");
tracing::debug!("Received Ready event");
frame.state.replace(FrameState::Finished);
}
zwlr_screencopy_frame_v1::Event::Failed => {
log::debug!("Received Failed event");
tracing::debug!("Received Failed event");
frame.state.replace(FrameState::Failed);
}
zwlr_screencopy_frame_v1::Event::Damage { .. } => {
log::debug!("Received Damage event");
tracing::debug!("Received Damage event");
}
zwlr_screencopy_frame_v1::Event::LinuxDmabuf { .. } => {
log::debug!("Received LinuxDmaBuf event");
tracing::debug!("Received LinuxDmaBuf event");
}
zwlr_screencopy_frame_v1::Event::BufferDone => {
log::debug!("Received bufferdone event");
tracing::debug!("Received bufferdone event");
frame.buffer_done.store(true, Ordering::SeqCst);
}
_ => unreachable!(),
Expand Down
Loading

0 comments on commit 6d3da9a

Please sign in to comment.