Skip to content

Commit e94c33d

Browse files
mls-aziwellcarlescufi
authored andcommitted
logging: add support for 64 bit timestamps with Linux format
Combining CONFIG_LOG_OUTPUT_FORMAT_LINUX_TIMESTAMP and CONFIG_LOG_TIMESTAMP_64BIT results in a wrong timestamp, as the Linux timestamp format print call assumes a 32 bit variable for the seconds. Fix it by using a different print format for 64 bit timestamps. Fixes: #55372 Signed-off-by: Martin Sollie <[email protected]>
1 parent 70c6bef commit e94c33d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

subsys/logging/log_output.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,11 @@ static int timestamp_print(const struct log_output *output,
276276
} else {
277277
if (IS_ENABLED(CONFIG_LOG_OUTPUT_FORMAT_LINUX_TIMESTAMP)) {
278278
length = print_formatted(output,
279-
"[%5ld.%06d] ",
279+
#if defined(CONFIG_LOG_TIMESTAMP_64BIT)
280+
"[%5llu.%06d] ",
281+
#else
282+
"[%5lu.%06d] ",
283+
#endif
280284
total_seconds, ms * 1000U + us);
281285
} else {
282286
length = print_formatted(output,

0 commit comments

Comments
 (0)