uniffi-rs icon indicating copy to clipboard operation
uniffi-rs copied to clipboard

Use trace level logging in generated code

Open praveenperera opened this issue 2 years ago • 4 comments

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

praveenperera avatar Aug 10 '23 22:08 praveenperera

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

badboy avatar Aug 11 '23 08:08 badboy

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

praveenperera avatar Aug 11 '23 16:08 praveenperera

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

ilikepi63 avatar Nov 29 '23 19:11 ilikepi63

Yep, a PR would be welcome!

mhammond avatar Nov 29 '23 21:11 mhammond