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

Support reparsing filters at runtime #113

Open
KodrAus opened this issue Nov 5, 2018 · 2 comments
Open

Support reparsing filters at runtime #113

KodrAus opened this issue Nov 5, 2018 · 2 comments

Comments

@KodrAus
Copy link
Collaborator

KodrAus commented Nov 5, 2018

Originally raised in #103

Currently, I don't see a nice way to change logging levels dynamically. (Or is there?). It is not very friendly with log::set_max_level_filter either to able to make even small changes.

Would be nice to be able to make small changes if not full reparse during runtime. It becomes extremely helpful in server environments to be able to to that.

@jose-acevedoflores
Copy link

I took a jab at adding support for this and have come up with two prototypes:

  • Non breaking change: Added an RwLock around the filter field of the Logger struct. This approach is simple but there is a read penalty when accessing the filter field anytime something is logged. Code for this approach here
  • Breaking change: Used generics to create a logger that can change filters at runtime or forgo the ability to change at runtime to avoid the read penalty and remain static (basically how it is now). Code for this approach here

For both prototypes, when the logger is built you can get an instance of a new struct called DynamicLogLevel. It has a check_filter_config method that when called, checks a config file and updates the filter if the levels have changed.
The contents of this config file should follow the same syntax used for the RUST_LOG env var.

My goal is to start the conversation and possibly see if there are better ways to add support for this.

@steveklabnik
Copy link

+1 to "this would be nice"

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

No branches or pull requests

3 participants