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

Closed
stepancheg wants to merge 1 commit from init-or-default into master
stepancheg commented 2017-05-13 15:52:47 -05:00 (Migrated from github.com)

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

Function parameter is used as logging spec when RUST_LOG variable is not available.
dtolnay (Migrated from github.com) reviewed 2017-05-23 18:38:44 -05:00
dtolnay (Migrated from github.com) 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.

Thanks! How would you feel about accomplishing this with LogBuilder instead? ```rust 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 commented 2017-05-23 19:05:48 -05:00 (Migrated from github.com)

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.

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 commented 2017-05-23 19:13:03 -05:00 (Migrated from github.com)

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();
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: ```rust LogBuilder::new().parse("mylib=warn").parse_env().init(); ```
KodrAus commented 2017-09-17 16:18:33 -05:00 (Migrated from github.com)

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.

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 commented 2017-09-22 06:41:10 -05:00 (Migrated from github.com)

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

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

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-rust-lang/log!113
No description provided.