MCPcopy Create free account
hub / github.com/git/git / prepare_trace_line

Function prepare_trace_line

trace.c:98–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98static int prepare_trace_line(const char *file, int line,
99 struct trace_key *key, struct strbuf *buf)
100{
101 static struct trace_key trace_bare = TRACE_KEY_INIT(BARE);
102 struct timeval tv;
103 struct tm tm;
104 time_t secs;
105
106 if (!trace_want(key))
107 return 0;
108
109 /* unit tests may want to disable additional trace output */
110 if (trace_want(&trace_bare))
111 return 1;
112
113 /* print current timestamp */
114 gettimeofday(&tv, NULL);
115 secs = tv.tv_sec;
116 localtime_r(&secs, &tm);
117 strbuf_addf(buf, "%02d:%02d:%02d.%06ld %s:%d", tm.tm_hour, tm.tm_min,
118 tm.tm_sec, (long) tv.tv_usec, file, line);
119 /* align trace output (column 40 catches most files names in git) */
120 while (buf->len < 40)
121 strbuf_addch(buf, ' ');
122
123 return 1;
124}
125
126static void trace_write(struct trace_key *key, const void *buf, unsigned len)
127{

Callers 4

trace_vprintf_flFunction · 0.85
trace_argv_vprintf_flFunction · 0.85
trace_strbuf_flFunction · 0.85

Calls 5

trace_wantFunction · 0.85
gettimeofdayFunction · 0.85
localtime_rFunction · 0.85
strbuf_addfFunction · 0.85
strbuf_addchFunction · 0.85

Tested by

no test coverage detected