mattsse / chromiumoxide

Chrome Devtools Protocol rust API
Apache License 2.0
712 stars 69 forks source link

Log raw WS messages to facilitate the debugging #195

Closed MOZGIII closed 4 months ago

MOZGIII commented 6 months ago

I'd like to be able to turn these off though, as it's an extra copy on every message; would you consider keeping a feature but making it on by default? That way I can turn it off when needed.

I'm kind of interested in tuning performance here, as we could have a quite overhead-sensitive setup (proper measurements to confirm this are pending).

ryo33 commented 4 months ago

I'd like to be able to turn these off though, as it's an extra copy on every message; would you consider keeping a feature but making it on by default? That way I can turn it off when needed.

Extra cloning can be avoided by this statement.

let msg_for_debug = if tracing::enabled!(target: "chromiumoxide::conn::raw_ws::parse_errors", tracing::Level::DEBUG) {
    Some(msg.clone)
} else {
    None
};
ryo33 commented 4 months ago

I forked this branch and opened https://github.com/mattsse/chromiumoxide/pull/204. It's zero-copy.