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

Issue #197: Handle hyphens internally #202

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/filter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ fn parse_spec(spec: &str) -> (Vec<Directive>, Option<inner::Filter>) {
return (dirs, None);
}
if let Some(m) = mods {
let m = m.replace("-", "_");
for s in m.split(',').map(|ss| ss.trim()) {
if s.is_empty() {
continue;
Expand Down Expand Up @@ -697,6 +698,21 @@ mod tests {
assert!(filter.is_none());
}

#[test]
fn parse_spec_replaces_hyphens_in_mods() {
let (dirs, filter) = parse_spec("my-crate1::mod1=error,crate1::mod2,my-crate2=debug");
assert_eq!(dirs.len(), 3);
assert_eq!(dirs[0].name, Some("my_crate1::mod1".to_string()));
assert_eq!(dirs[0].level, LevelFilter::Error);

assert_eq!(dirs[1].name, Some("crate1::mod2".to_string()));
assert_eq!(dirs[1].level, LevelFilter::max());

assert_eq!(dirs[2].name, Some("my_crate2".to_string()));
assert_eq!(dirs[2].level, LevelFilter::Debug);
assert!(filter.is_none());
}

#[test]
fn parse_spec_invalid_crate() {
// test parse_spec with multiple = in specification
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
//! [2017-11-09T02:12:24Z INFO main] the answer was: 12
//! ```
//!
//! If the binary name contains hyphens, you will need to replace
//! them with underscores:
//! If the binary name contains hyphens, they need to be replaced with underscores.
//! The library handles this case automatically, in case you forget:
//!
//! ```{.bash}
//! $ RUST_LOG=my_app ./my-app
Expand Down