Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use trace level logging in generated code #1702

Closed
praveenperera opened this issue Aug 10, 2023 · 5 comments
Closed

Use trace level logging in generated code #1702

praveenperera opened this issue Aug 10, 2023 · 5 comments
Labels
good first issue Good for newcomers to get started with development

Comments

@praveenperera
Copy link
Contributor

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
Copy link
Member

badboy commented Aug 11, 2023

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
Copy link
Contributor Author

praveenperera commented Aug 11, 2023

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

@mhammond mhammond changed the title Opt out of logging for a function Use trace level logging in generated code Sep 28, 2023
@mhammond mhammond added the good first issue Good for newcomers to get started with development label Sep 28, 2023
@ilikepi63
Copy link

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

@mhammond
Copy link
Member

Yep, a PR would be welcome!

@praveenperera
Copy link
Contributor Author

Fixed by: #2275

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers to get started with development
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants