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

Make use of i/o locking being static since rust 1.61. #681

Merged
merged 2 commits into from
Jun 24, 2022
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- [#681]: Make use of i/o locking being static since rust `1.61`.
- [#679]: Add changelog enforcer
- [#678]: Satisfy clippy

[#681]: https://github.com/knurling-rs/defmt/pull/681
[#679]: https://github.com/knurling-rs/defmt/pull/679
[#678]: https://github.com/knurling-rs/defmt/pull/678

Expand Down
10 changes: 3 additions & 7 deletions decoder/src/log/json_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@ impl Log for JsonLogger {

if let Some(record) = DefmtRecord::new(record) {
// defmt goes to stdout, since it's the primary output produced by this tool.
let stdout = io::stdout();
let mut sink = stdout.lock();
let mut sink = io::stdout().lock();

let host_timestamp = Utc::now().timestamp_nanos();
serde_json::to_writer(&mut sink, &create_json_frame(record, host_timestamp)).ok();
writeln!(sink).ok();
} else {
// non-defmt logs go to stderr
let stderr = io::stderr();
let sink = stderr.lock();

let sink = io::stderr().lock();
self.host_logger.print_host_record(record, sink);
}
}
Expand All @@ -50,8 +47,7 @@ impl JsonLogger {
}

pub fn print_schema_version() {
let stdout = io::stdout();
let mut sink = stdout.lock();
let mut sink = io::stdout().lock();
serde_json::to_writer(&mut sink, &SCHEMA_VERSION).ok();
writeln!(sink).ok();
}
Expand Down
7 changes: 2 additions & 5 deletions decoder/src/log/pretty_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ impl Log for PrettyLogger {
match DefmtRecord::new(record) {
Some(record) => {
// defmt goes to stdout, since it's the primary output produced by this tool.
let stdout = io::stdout();
let sink = stdout.lock();
let sink = io::stdout().lock();

match record.level() {
Some(level) => self.print_defmt_record(record, level, sink),
Expand All @@ -41,9 +40,7 @@ impl Log for PrettyLogger {
}
None => {
// non-defmt logs go to stderr
let stderr = io::stderr();
let sink = stderr.lock();

let sink = io::stderr().lock();
self.print_host_record(record, sink);
}
}
Expand Down
3 changes: 1 addition & 2 deletions print/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ fn main() -> anyhow::Result<()> {
let mut stream_decoder = table.new_stream_decoder();

let current_dir = env::current_dir()?;
let stdin = io::stdin();
let mut stdin = stdin.lock();
let mut stdin = io::stdin().lock();

loop {
// read from stdin and push it to the decoder
Expand Down