Skip to content

Commit 562a4d8

Browse files
committed
trace: add pid to each output line
When there are many git commands running, it can be confusing which process is producing which message. And if one is trying to correlate a specific invocation with a trace-file created using "%p", it's rather impossible. Let's print the pid alongside each line. This does extend the already-wide trace lines. We could make it optional, but it's probably not worth the complexity of extra knobs. Looking at trace output is already an exceptional thing to be doing, and verbose output is not going to bother anyone. Signed-off-by: Jeff King <peff@peff.net>
1 parent b8faa5f commit 562a4d8

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

trace.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ static int prepare_trace_line(const char *file, int line,
129129
localtime_r(&secs, &tm);
130130
strbuf_addf(buf, "%02d:%02d:%02d.%06ld %s:%d", tm.tm_hour, tm.tm_min,
131131
tm.tm_sec, (long) tv.tv_usec, file, line);
132-
/* align trace output (column 40 catches most files names in git) */
133-
while (buf->len < 40)
132+
strbuf_addf(buf, "[pid=%lu] ", (unsigned long)getpid());
133+
/* align trace output (column 50 catches most files names in git) */
134+
while (buf->len < 50)
134135
strbuf_addch(buf, ' ');
135136

136137
return 1;

0 commit comments

Comments
 (0)