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

defmt::println messages have a leading space when timestamps are disabled #602

Closed
japaric opened this issue Oct 6, 2021 · 1 comment · Fixed by #608
Closed

defmt::println messages have a leading space when timestamps are disabled #602

japaric opened this issue Oct 6, 2021 · 1 comment · Fixed by #608
Assignees
Labels
difficulty: easy Pretty easy to solve good first issue Good for newcomers priority: medium Medium priority for the Knurling team status: needs PR Issue just needs a Pull Request implementing the changes type: bug Something isn't working
Milestone

Comments

@japaric
Copy link
Member

japaric commented Oct 6, 2021

Steps to reproduce:

  • start from app-template (main branch)
  • configure it to use git version of defmt crates
  • remove the defmt::timestamp! item from src/lib.rs
  • modify src/bin/hello.rs to use println!
defmt::println!("Hello, world!");

This outputs:

 Hello, world!
└─ hello::__cortex_m_rt_main @ src/bin/hello.rs:8

Ideally, it should output: (the H is exactly on top of the "corner pipe")

Hello, world!
└─ hello::__cortex_m_rt_main @ src/bin/hello.rs:8

to match the other logging macros, e.g. the levels example produces:

ERROR error
└─ levels::__cortex_m_rt_main @ src/bin/levels.rs:12

cc @justahero

@jonas-schievink
Copy link
Contributor

Problem lies here:

writeln!(&mut sink, "{} {}", timestamp, display).ok();

The fix is to make timestamp an Option<String>in that function and only add the space in that branch when it's Some.

@jonas-schievink jonas-schievink added difficulty: easy Pretty easy to solve priority: medium Medium priority for the Knurling team status: needs PR Issue just needs a Pull Request implementing the changes type: bug Something isn't working labels Oct 6, 2021
@jonas-schievink jonas-schievink added this to the v0.3.0 milestone Oct 6, 2021
@jonas-schievink jonas-schievink added the good first issue Good for newcomers label Oct 6, 2021
@Urhengulas Urhengulas self-assigned this Oct 11, 2021
@bors bors bot closed this as completed in #608 Oct 11, 2021
@bors bors bot closed this as completed in 1806bb1 Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy Pretty easy to solve good first issue Good for newcomers priority: medium Medium priority for the Knurling team status: needs PR Issue just needs a Pull Request implementing the changes type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants