mozilla / uniffi-rs

a multi-language bindings generator for rust
https://mozilla.github.io/uniffi-rs/
Mozilla Public License 2.0
2.84k stars 231 forks source link

Use trace level logging in generated code #1702

Open praveenperera opened 1 year ago

praveenperera commented 1 year ago

Is it possible to not have one function log every time its called?

I have a very simple function

#[uniffi::export]
pub fn pod_restart_count(pod: Pod) -> i32 {
    pod.total_restart_count()
}

Its called a lot of times and drowns out all the other logs, would it be possible to opt out of logging on a per function basis?

Screenshot 2023-08-10 at 6 45 24 PM
badboy commented 1 year ago

We unconditionally log at debug level (though maybe this really should be trace level), however depending on what log implementation you use you can raise the minimal log level for a particular module. In my project we use a submodule for the generated code:

mod ffi {
    use super::*;
    uniffi::include_scaffolding!("glean");
}

and then filter this in the different log configurations: https://github.com/mozilla/glean/blob/main/glean-core/src/lib.rs#L710-L743

praveenperera commented 1 year ago

@badboy that's a good idea, I'll move the noisy functions to a different module and set the log level there. Thanks

But I agree I think trace might be a better level for these logs.

ilikepi63 commented 11 months ago

Is this issue still open? Could I submit a PR?

mhammond commented 11 months ago

Yep, a PR would be welcome!