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

Move lvl <= $crate::max_level() inside called functions #514

Closed

Conversation

EFanZh
Copy link
Contributor

@EFanZh EFanZh commented May 31, 2022

This change will reduce binary size at the cost of some performance loss.

@EFanZh
Copy link
Contributor Author

EFanZh commented May 31, 2022

I noticed a project I am working on has a decent amount of size increase after upgrading the log dependency, it was cause by #446, which I am not able to workaround, so I was looking for other ways to reduce the binary size impact, and this is what I came up with.

If the performance loss is unacceptable, how about using an optional feature to provide this binary-size-over-performance behavior?

@EFanZh EFanZh force-pushed the check-log-level-inside-functions branch from 85822bf to 06c9ddc Compare May 31, 2022 07:04
@EFanZh EFanZh marked this pull request as draft May 31, 2022 07:14
@EFanZh
Copy link
Contributor Author

EFanZh commented May 31, 2022

Close as this will expand argument too early, causing behavior change.

@EFanZh EFanZh closed this May 31, 2022
@Thomasdezeeuw
Copy link
Collaborator

@EFanZh have you tried the log crate's filter features (https://docs.rs/log/latest/log/#compile-time-filters)? Those will help remove trace, debug (and more if desired) from the binary. It's also (part of) the reason why the if statement if outside of the function.

@EFanZh
Copy link
Contributor Author

EFanZh commented May 31, 2022

@Thomasdezeeuw Most of my logs are required to be printed out, so disabling logs is not an option.

@EFanZh EFanZh deleted the check-log-level-inside-functions branch July 9, 2023 00:36
EFanZh pushed a commit to EFanZh/log that referenced this pull request Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants