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

Logging feature is broken for env_logger v0.5.0+ #140

Closed
aldanor opened this issue Nov 24, 2018 · 2 comments · Fixed by #172
Closed

Logging feature is broken for env_logger v0.5.0+ #140

aldanor opened this issue Nov 24, 2018 · 2 comments · Fixed by #172

Comments

@aldanor
Copy link

aldanor commented Nov 24, 2018

error[E0599]: no method named `unwrap` found for type `()` in the current scope
   --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/derive_builder-0.7.0/src/lib.rs:561:28
    |
561 |         env_logger::init().unwrap();
    |                            ^^^^^^

Looks like env_logger::init() just panics and doesn't need to be unwrapped manually anymore, starting from v0.5.0: https://github.com/sebasmagri/env_logger/releases/tag/v0.5.0

@TedDriggs
Copy link
Collaborator

I think I'm going to remove logging altogether. It made sense when derive_builder was doing its own attribute parsing: It was delicate, and logging was needed to make sense of what happened. However, now the value of the logging is greatly diminished, and it being broken makes it seem wise to pull out.

@jgraef
Copy link
Contributor

jgraef commented Nov 1, 2019

I was just looking into logging and found it weird that I need to set the environment variable, since logging should be initialized by the application using your crate. Then I looked into the code and you really use env_logger thus kind of forcing it onto your users.

All a library crate should do is to use the log dependency and then just let the application decide which logger it wants to use. At least that's how I understand how log should be used. Please let me know, if I misunderstood something there though.

In my case we already have all the logging setup, so when I want logging for your crate I will just enable it (we only enable logging for our crates by default).

If you want to give your users the option of using your crate without any logging capabilities compiled in, you can still have it behind a logging feature. IMHO having log is really almost no overhead (I think it's a deref of an AtomicBool or similar for every logging call - when no logger is registered).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants