-
Notifications
You must be signed in to change notification settings - Fork 130
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
Option to conditionally log to stderr only above a given level #219
Comments
I was also thinking as a more flexible option: enum Target {
// ...
Threshold {
// `Box` needed to keep the size finite
default_target: Box<Target>,
threshold_target: Box<Target>,
threshold: log::Level,
}
} The mildly annoying part is the It could be a separate method on impl Builder {
// Log a record to the given target if it is at or above the given threshold, otherwise log to the regular target.
pub fn threshold_target(&mut self, threshold: log::Level, target: Target) -> &mut Builder { ... }
} |
Hey @abonander we are also running into this issue, what did you end up doing? |
I think we just changed the default sink to stdout so it stopped logging everything as errors. |
I had a helpful discussion with people on the rust irc, will likely go with this: https://cloud.google.com/logging/docs/structured-logging and make it so that it picks up the correct severity! Thanks for the input though! :) |
Any update on this? IMO, it would be interesting to redirect the |
No, this crate is not actively maintained. I did a release not long ago to fix the most glaring issues, but don't intend to spend more time on it and doesn't seem like any of the other people with access rights want to, either. See #159 |
WG-CLI is picking up passive maintenance of this script. I'm not familiar with that technology stack but this overall feels like a problem with how output is interacting with the technology stack. |
I am having the same problem. Please do the following. changing the default behaviour should be good enough to make happy to all parts. Thanks in advance. |
When using
env_logger
in a binary running in Google Kubernetes Engine, everything it logs gets recorded as an error log because it logs tostderr
by default:This is just the actix-web logger middleware logging requests from the Gcloud healthcheck service at
INFO
(plus an easter egg of a web crawler looking for an admin login form?), but Gcloud thinks they're error logs because they were printed tostderr
.Of course, we could just set
Target::Stdout
and call it a day, but I would like to retain the ability to print actual error logs tostderr
as we want to set this up to page someone if our API service is throwing actual errors.I'm thinking another variant to
Target
that looks something like:I'm also considering, as a workaround, using the
Builder::format()
method to conditionally print to stderr but I'm not sure if this would break things. It's suboptimal either way:The text was updated successfully, but these errors were encountered: