knurling-rs / probe-run

Run embedded programs just like native ones
Apache License 2.0
645 stars 75 forks source link

--log-format is inconvenient when only timestamp must be added #421

Closed ia0 closed 1 year ago

ia0 commented 1 year ago

Describe the bug Since #416 the default log format is defined by probe-run instead of defmt-decoder, and that default log format does not contain a timestamp. It is not convenient to define a log format from scratch just to add a timestamp.

To Reproduce Define a timestamp with defmt::timestamp!(), then use probe-run.

Expected and observed behavior I get a warning that the log format doesn't contain a timestamp:

(HOST) WARN  `defmt::timestamp!` implementation was found, but timestamp is not part of the log format; consider adding the timestamp `{t}` argument to the log format

I would expect a timestamp to be automatically used as it was the case before. This dynamic check should be easy based on the presence of defmt::timestamp!() which probe-run is able to do because probe-run unilaterally forces a default for log-format (which means defmt decoder taking an optional log-format is probably dead code).

An alternative solution would be to provide a convenience flag (eg. --log-timestamp) to use the timestamp version of the log-format (i.e. the default log format prefixed by {t}).

Urhengulas commented 1 year ago

Hi @ia0, I was thinking about that yesterday as well. Detecting it automatically should be rather easy with the defmt_decoder::Table::has_timestamp method.