Skip to content

Commit

Permalink
trace: refactor first json entry
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Jun 6, 2022
1 parent 651d5e3 commit 0bea0bb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ int re_trace_flush(void)
struct trace_event *e;
char json_arg[256];
char name[128];
static bool first = true;

#ifndef RE_TRACE_ENABLED
return 0;
Expand Down Expand Up @@ -223,10 +224,10 @@ int re_trace_flush(void)
(void)re_fprintf(trace.f,
"%s{\"cat\":\"%s\",\"pid\":%i,\"tid\":%lu,\"ts\":%llu,"
"\"ph\":\"%c\",%s%s}",
trace.init ? "" : ",\n",
first ? "" : ",\n",
e->cat, e->pid, e->tid, e->ts - trace.start_time,
e->ph, name, str_isset(json_arg) ? json_arg : "");
trace.init = false;
first = false;
}

(void)fflush(trace.f);
Expand Down

0 comments on commit 0bea0bb

Please sign in to comment.