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

env_logger::init_or_default("mylib=warn") #113

Closed

Conversation

Projects
None yet
3 participants
@stepancheg
Copy link

stepancheg commented May 13, 2017

Function parameter is used as logging spec when RUST_LOG variable
is not available.

env_logger::init_or_default("mylib=warn")
Function parameter is used as logging spec when RUST_LOG variable
is not available.
@dtolnay
Copy link
Member

dtolnay left a comment

Thanks! How would you feel about accomplishing this with LogBuilder instead?

let mut lb = env_logger::LogBuilder::new();
lb.parse(&env::var("RUST_LOG").unwrap_or("mylib=warn".to_owned()));
lb.init()?;

I am concerned that init_or_default does not compose well with other functionality we may want to expose here, for example try_init from #146.

@stepancheg

This comment has been minimized.

Copy link
Author

stepancheg commented May 24, 2017

It is inconvenient to repeat this fragment in each unit test, in each bench, in each of several main functions. Or create a library with just this function.

init_or_default does not solve any otherwize unsolvable problems, it's just convenient to have.

@dtolnay

This comment has been minimized.

Copy link
Member

dtolnay commented May 24, 2017

Seems reasonable. Could you come up with some approaches for making this compose better with other functionality, especially #146?

Here is one idea to get you started:

LogBuilder::new().parse("mylib=warn").parse_env().init();

@sebasmagri sebasmagri referenced this pull request Aug 4, 2017

Closed

Remove env_logger from this repository #145

2 of 2 tasks complete
@KodrAus

This comment has been minimized.

Copy link
Contributor

KodrAus commented Sep 17, 2017

Thanks @stepancheg! Do you mind rebasing this over at https://github.com/sebasmagri/env_logger, which is the new home for env_logger?

It would be good for this to be composable within the builder.

@KodrAus

This comment has been minimized.

Copy link
Contributor

KodrAus commented Sep 22, 2017

I'll go ahead and close this now, please feel free to file against the new env_logger repo.

@KodrAus KodrAus closed this Sep 22, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.