| 1310 | static void agent_trace_time(FILE *fp) { |
| 1311 | struct timespec ts; |
| 1312 | clock_gettime(CLOCK_REALTIME, &ts); |
| 1313 | struct tm tm; |
| 1314 | localtime_r(&ts.tv_sec, &tm); |
| 1315 | fprintf(fp, "%04d-%02d-%02d %02d:%02d:%02d.%03ld", |
| 1316 | tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, |
| 1317 | tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec / 1000000); |
| 1318 | } |
| 1319 | |
| 1320 | static void agent_trace(agent_worker *w, const char *fmt, ...) { |
| 1321 | if (!w || !w->trace) return; |
| 1322 | pthread_mutex_lock(&w->mu); |
| 1323 | agent_trace_time(w->trace); |
| 1324 | fputs(" ", w->trace); |
| 1325 | va_list ap; |
| 1326 | va_start(ap, fmt); |
no test coverage detected