[PATCH 2/3] trace: add pid to each output line
flat view
STALE3773d
From: Jeff King <hidden>
Date: 2016-06-15 23:05:20
Subsystem:
the rest · Maintainer:
Linus Torvalds
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 <redacted> --- I think you can technically get by without this for most cases, as doing GIT_TRACE=base.%p will get you the "built-in: ..." line for index-pack, pack-objects, etc, which you can then correlate with a matching GIT_TRACE_STDIN filename. trace.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/trace.c b/trace.c
index e1d1360..a7ec484 100644
--- a/trace.c
+++ b/trace.c@@ -123,12 +123,13 @@ static int prepare_trace_line(const char *file, int line, localtime_r(&secs, &tm); strbuf_addf(buf, "%02d:%02d:%02d.%06ld ", tm.tm_hour, tm.tm_min, tm.tm_sec, (long) tv.tv_usec); + strbuf_addf(buf, "[pid=%lu] ", (unsigned long)getpid()); #ifdef HAVE_VARIADIC_MACROS /* print file:line */ strbuf_addf(buf, "%s:%d ", file, line); - /* align trace output (column 40 catches most files names in git) */ - while (buf->len < 40) + /* align trace output (column 50 catches most files names in git) */ + while (buf->len < 50) strbuf_addch(buf, ' '); #endif
--
2.4.3.699.g84b4da7