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

chore: Update from _rust template #334

Merged
merged 9 commits into from
Sep 27, 2024
2 changes: 2 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- uses: pre-commit/[email protected]
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ We ask that commits are atomic, meaning they are complete and have a single resp
PRs should tell a cohesive story, with test and refactor commits that keep the
fix or feature commits simple and clear.

Specifically, we would encouage
Specifically, we would encourage
- File renames be isolated into their own commit
- Add tests in a commit before their feature or fix, showing the current behavior.
The diff for the feature/fix commit will then show how the behavior changed,
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ string_lit_as_bytes = "warn"
string_to_string = "warn"
todo = "warn"
trait_duplication_in_bounds = "warn"
uninlined_format_args = "warn"
verbose_file_reads = "warn"
wildcard_imports = "warn"
zero_sized_map_values = "warn"
Expand Down
8 changes: 4 additions & 4 deletions crates/env_filter/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub(crate) fn parse_spec(spec: &str) -> ParseResult {
let mods = parts.next();
let filter = parts.next();
if parts.next().is_some() {
result.add_error(format!("invalid logging spec '{}' (too many '/'s)", spec));
result.add_error(format!("invalid logging spec '{spec}' (too many '/'s)"));
return result;
}
if let Some(m) = mods {
Expand All @@ -86,12 +86,12 @@ pub(crate) fn parse_spec(spec: &str) -> ParseResult {
if let Ok(num) = part1.parse() {
(num, Some(part0))
} else {
result.add_error(format!("invalid logging spec '{}'", part1));
result.add_error(format!("invalid logging spec '{part1}'"));
continue;
}
}
_ => {
result.add_error(format!("invalid logging spec '{}'", s));
result.add_error(format!("invalid logging spec '{s}'"));
continue;
}
};
Expand All @@ -106,7 +106,7 @@ pub(crate) fn parse_spec(spec: &str) -> ParseResult {
if let Some(filter) = filter {
match FilterOp::new(filter) {
Ok(filter_op) => result.set_filter(filter_op),
Err(err) => result.add_error(format!("invalid regex filter - {}", err)),
Err(err) => result.add_error(format!("invalid regex filter - {err}")),
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ impl<'a> DefaultFormat<'a> {
self.written_header_value = true;

let open_brace = self.subtle_style("[");
write!(self.buf, "{}{}", open_brace, value)
write!(self.buf, "{open_brace}{value}")
} else {
write!(self.buf, " {}", value)
write!(self.buf, " {value}")
}
}

Expand All @@ -383,7 +383,7 @@ impl<'a> DefaultFormat<'a> {
}
};

self.write_header_value(format_args!("{:<5}", level))
self.write_header_value(format_args!("{level:<5}"))
}

fn write_timestamp(&mut self) -> io::Result<()> {
Expand Down Expand Up @@ -435,7 +435,7 @@ impl<'a> DefaultFormat<'a> {
fn finish_header(&mut self) -> io::Result<()> {
if self.written_header_value {
let close_brace = self.subtle_style("]");
write!(self.buf, "{} ", close_brace)
write!(self.buf, "{close_brace} ")
} else {
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions src/fmt/writer/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl BufferWriter {
#[cfg(feature = "color")]
let buf = &buf;
let buf = String::from_utf8_lossy(buf);
print!("{}", buf);
print!("{buf}");
}
WritableTarget::WriteStderr => {
let stream = io::stderr();
Expand All @@ -87,7 +87,7 @@ impl BufferWriter {
#[cfg(feature = "color")]
let buf = &buf;
let buf = String::from_utf8_lossy(buf);
eprint!("{}", buf);
eprint!("{buf}");
}
WritableTarget::Pipe(pipe) => {
#[cfg(feature = "color")]
Expand Down
2 changes: 1 addition & 1 deletion tests/init-twice-retains-filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn main() {
.env("YOU_ARE_TESTING_NOW", "1")
.env("RUST_LOG", "debug")
.output()
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
.unwrap_or_else(|e| panic!("Unable to start child process: {e}"));
if out.status.success() {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/log-in-log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn main() {
.env("YOU_ARE_TESTING_NOW", "1")
.env("RUST_LOG", "debug")
.output()
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
.unwrap_or_else(|e| panic!("Unable to start child process: {e}"));
if out.status.success() {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/log_tls_dtors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn main() {
.env("YOU_ARE_TESTING_NOW", "1")
.env("RUST_LOG", "debug")
.output()
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
.unwrap_or_else(|e| panic!("Unable to start child process: {e}"));
if !out.status.success() {
println!("test failed: {}", out.status);
println!("--- stdout\n{}", str::from_utf8(&out.stdout).unwrap());
Expand Down
9 changes: 3 additions & 6 deletions tests/regexp_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,21 @@ fn run_child(rust_log: String) -> bool {
.env("LOG_REGEXP_TEST", "1")
.env("RUST_LOG", rust_log)
.output()
.unwrap_or_else(|e| panic!("Unable to start child process: {}", e));
.unwrap_or_else(|e| panic!("Unable to start child process: {e}"));
str::from_utf8(out.stderr.as_ref())
.unwrap()
.contains("XYZ Message")
}

fn assert_message_printed(rust_log: &str) {
if !run_child(rust_log.to_owned()) {
panic!("RUST_LOG={} should allow the test log message", rust_log)
panic!("RUST_LOG={rust_log} should allow the test log message")
}
}

fn assert_message_not_printed(rust_log: &str) {
if run_child(rust_log.to_owned()) {
panic!(
"RUST_LOG={} should not allow the test log message",
rust_log
)
panic!("RUST_LOG={rust_log} should not allow the test log message")
}
}

Expand Down
Loading