-
Notifications
You must be signed in to change notification settings - Fork 55
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
Allow log filtering with $RUST_LOG #2130
Conversation
Codecov Report
Additional details and impacted files
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, it's better to mention in the documentation, which is a higher priority RUST_LOG
Vs --debug flag.
@@ -19,14 +19,23 @@ pub fn get_log_level( | |||
} | |||
} | |||
|
|||
/// Initialize a `tracing_subscriber` | |||
/// Reports all the log events sent either with the `log` crate or the `tracing` crate. | |||
/// Initializes a tracing subscriber with a given log level if environment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Initializes a tracing subscriber with a given log level if environment | |
/// Initializes a tracing subscriber with a given log level through --debug, if the environment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the caller who chooses whether or not to call this function when --debug
is present or not, and the function doesn't check if --debug
is present or not, so the function doc should not mention it.
I like the idea and proactive nature of the PR, though just a few minor points to make it more inline with existing functionality and some general questions. General points
Do we really need a crate-level granularity for filtering log levels? I think this is a byproduct to the real issue that we are logging in some instances to INFO instead of TRACE. For example, the software list messages result in multiple (very long) messages being logged essentially spamming the log output when there are a large number (>200) debian packages being detected by Though if we did support crate-level log filtering, I don't think it would be that useful for users as they would have to first know what the crate name was, and if that crate name would change due to refactoring, then their log filter would not work anymore (which would also be unexpected for users). |
I see that as useful, knowing that this can be done at the actor level:
Agree, however I vote for I also see as an issue the fact that
Yes, |
70d15b7
to
0d28008
Compare
0d28008
to
55d723d
Compare
Robot Results
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Bravo555 and @reubenmiller We need to discuss the log level used for the messages received by the actors.
c6ee49d
to
8388fe6
Compare
`--debug` flag used to increase log verbosity is very noisy, as it enables `trace` (lowest level) logs from all modules, as well as dependencies. On the contrary, `RUST_LOG` environment variable can be used to set different logging levels on a per-module basis, allowing to e.g. set `trace` for a module one is currently working on and `info` on the rest, or limiting logging only to the current crate. As such, `set_log_level` function was modified to not overide a `$RUST_LOG` filter if it is present. If this variable is not present, it sets log level globally as usual. Signed-off-by: Marcel Guzik <[email protected]>
Signed-off-by: Marcel Guzik <[email protected]>
The principles behind the changes were: - if there is an interaction with the outside (eg. upload/download) - INFO - inter-actor messages and other communication - DEBUG - message payloads (they can be very large and there's no reason to print them multiple times) - TRACE - implementation-level event that should be of no concern to the user, isn't a lot of data, and should be called once or few times - DEBUG Signed-off-by: Marcel Guzik <[email protected]>
8388fe6
to
a5a5ff9
Compare
Doing this would require rewriting more code in each crate that we do config, taking more time and effort that i don't think is worth it. It's just every time I start working on a feature, I need to comment out the
To be honest, I have no idea what options in our tedge config do we have, that would be relevant to this. It's just that crate based-filtering is very useful for developers and it's what you get with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
Proposed changes
--debug
flag used to increase log verbosity is very noisy, as it enablestrace
(lowest level) logs from all modules, as well as dependencies.On the contrary,
RUST_LOG
environment variable can be used to set different logging levels on a per-module basis, allowing to e.g. settrace
for a module one is currently working on andinfo
on the rest, or limiting logging only to the current crate.As such,
set_log_level
function was modified to not overide a$RUST_LOG
filter if it is present. If this variable is not present, it sets log level globally as usual.Types of changes
Paste Link to the issue
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments