Skip to content

Commit

Permalink
logging: log_output: move partly unused code
Browse files Browse the repository at this point in the history
move code, that is only needed for one case
to that case.

Signed-off-by: Fin Maaß <[email protected]>
  • Loading branch information
maass-hamburg authored and kartben committed Dec 10, 2024
1 parent a9a475e commit 5d2068f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions subsys/logging/log_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,11 @@ static int timestamp_print(const struct log_output *output,
uint64_t total_seconds;
#endif
uint32_t remainder;
uint32_t seconds;
uint32_t hours;
uint32_t mins;
uint32_t ms;
uint32_t us;

timestamp /= timestamp_div;
total_seconds = timestamp / freq;
seconds = total_seconds;
hours = seconds / 3600U;
seconds -= hours * 3600U;
mins = seconds / 60U;
seconds -= mins * 60U;

remainder = timestamp % freq;
ms = (remainder * 1000U) / freq;
Expand Down Expand Up @@ -258,6 +250,15 @@ static int timestamp_print(const struct log_output *output,
#endif /* CONFIG_REQUIRES_FULL_LIBC */
#endif /* CONFIG_POSIX_C_LANG_SUPPORT_R */
} else {
uint32_t seconds;
uint32_t hours;
uint32_t mins;

seconds = total_seconds;
hours = seconds / 3600U;
seconds -= hours * 3600U;
mins = seconds / 60U;
seconds -= mins * 60U;
length = print_formatted(output,
"[%02u:%02u:%02u.%03u,%03u] ",
hours, mins, seconds, ms, us);
Expand Down

0 comments on commit 5d2068f

Please sign in to comment.