Skip to content

Commit

Permalink
Trace: Improve trace format for CONFIG_LIBRARY and fix level handling
Browse files Browse the repository at this point in the history
The test for trace level was wrong way, higher priority traces
like errors have a lower number value. It caused non-controllable
flood of debug traces.

These changes help scripts to extract trace from stderr output
with string "trace:" printed to begin of each line. The time and
level information is made similar to normal trace output in devices.

Example of printed trace:
trace: [1728921012.720684] <inf> (eq_iir.c:55) eq_iir_init()

Signed-off-by: Seppo Ingalsuo <[email protected]>
  • Loading branch information
singalsu committed Oct 15, 2024
1 parent cbcd51f commit e565ad9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/include/sof/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,12 @@ do { \
(void)id_1; \
(void)id_2; \
struct timeval tv; \
char slevel[5][4] = {"dis", "err", "wrn", "inf", "dbg"}; \
char *msg = "(%s:%d) " format; \
if (level >= host_trace_level) { \
if (level <= host_trace_level) { \
gettimeofday(&tv, NULL); \
fprintf(stderr, "%ld.%6.6ld:", tv.tv_sec, tv.tv_usec); \
fprintf(stderr, "trace: [%ld.%6.6ld] <%s> ", tv.tv_sec, tv.tv_usec, \
slevel[level]); \
fprintf(stderr, msg, strrchr(__FILE__, '/') + 1, \
__LINE__, ##__VA_ARGS__); \
fprintf(stderr, "\n"); \
Expand Down

0 comments on commit e565ad9

Please sign in to comment.