-
Notifications
You must be signed in to change notification settings - Fork 71
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
Failure case for TermLogger::new is unclear #40
Comments
Yes, you are right, this should be an actual error instead of an Thanks for your PR, but I would rather see an implementation using a |
Hey @Drakulix , Glad to read that you're open to a breaking change to improve things 🙂 I'll submit a PR in the upcoming days to change the retun of |
Thanks, that sounds absolutely OK. 😄
|
i just discovered this too, in a systemd unit |
Allowing |
I think the concern is more about the failure case not being documented. I see a few possible ways to deal with this
Certainly the "surprise" failure in CI/docker/systemd would catch people out who want a logger to stdout, so advertising the best practice to handle this situation would be really helpful. Thanks! |
yeah that's p much it ^_^
the dx here is that you setup a
so, documenting this failure and how to mitigate it in the API docs / example, and improving the error would improve the situation, but as an alternative could |
Upon discovering, that Instead, I have decided to merge @Horgix original PR #41 and expand it with some further examples in 70b09e2. |
Context
The examples (both in the documentation and in the README) for
TermLogger
initialization withTermLogger::new
suggest to.unwrap()
the result directly :Issue
I recently had the surprise to see it failing. In short, it was in a CI environment where the
TERM
environment variable was not set, resulting inTermInfo::new
failing, and thusterm::stdout()
andterm::stderr()
too. It took a while to debug mainly becauseTermLogger::new()
was failing without any hint on why it was failing, may it be in the documentation or in the returned information.Note: I don't use
TermLogger::init()
but I guess it is impacted by the same issue.Fix
What would be the best fix there? Would it make sense to have
TermLogger::new
return aResult
instead of anOption
so it could convey more information in the returnedErr
?If this would be too much of a breaking change, I'll submit a PR on the documentation explaining why
TermLogger::new()
could returnNone
.The text was updated successfully, but these errors were encountered: