Commit 76fb1eed authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Change the output format of varnishtest.

Instead of a timestamp per line, which makes diff(1) really hard
to use, emit millisecond timestamps on separate "dT" lines, whenever
time has changed since last timestamp.
parent c4860b99
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "config.h" #include "config.h"
#include <math.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -48,7 +49,6 @@ struct vtclog { ...@@ -48,7 +49,6 @@ struct vtclog {
struct vsb *vsb; struct vsb *vsb;
pthread_mutex_t mtx; pthread_mutex_t mtx;
int act; int act;
double tx;
}; };
static pthread_key_t log_key; static pthread_key_t log_key;
...@@ -59,7 +59,6 @@ static double t0; ...@@ -59,7 +59,6 @@ static double t0;
#define GET_VL(vl) \ #define GET_VL(vl) \
do { \ do { \
CHECK_OBJ_NOTNULL(vl, VTCLOG_MAGIC); \ CHECK_OBJ_NOTNULL(vl, VTCLOG_MAGIC); \
vl->tx = VTIM_mono() - t0; \
AZ(pthread_mutex_lock(&vl->mtx)); \ AZ(pthread_mutex_lock(&vl->mtx)); \
vl->act = 1; \ vl->act = 1; \
VSB_clear(vl->vsb); \ VSB_clear(vl->vsb); \
...@@ -129,8 +128,8 @@ vtc_leadinv(const struct vtclog *vl, int lvl, const char *fmt, va_list ap) ...@@ -129,8 +128,8 @@ vtc_leadinv(const struct vtclog *vl, int lvl, const char *fmt, va_list ap)
assert(lvl < (int)NLEAD); assert(lvl < (int)NLEAD);
assert(lvl >= 0); assert(lvl >= 0);
VSB_printf(vl->vsb, "%s %-4s %4.1f ", VSB_printf(vl->vsb, "%s %-4s ",
lead[lvl < 0 ? 1: lvl], vl->id, vl->tx); lead[lvl < 0 ? 1: lvl], vl->id);
if (fmt != NULL) if (fmt != NULL)
(void)VSB_vprintf(vl->vsb, fmt, ap); (void)VSB_vprintf(vl->vsb, fmt, ap);
} }
...@@ -149,11 +148,23 @@ static void ...@@ -149,11 +148,23 @@ static void
vtc_log_emit(const struct vtclog *vl) vtc_log_emit(const struct vtclog *vl)
{ {
unsigned l; unsigned l;
int i;
int t_this;
static int t_last = -1;
l = VSB_len(vl->vsb); l = VSB_len(vl->vsb);
if (l == 0) if (l == 0)
return; return;
t_this = (int)round((VTIM_mono() - t0) * 1000);
AZ(pthread_mutex_lock(&vtclog_mtx)); AZ(pthread_mutex_lock(&vtclog_mtx));
if (t_last != t_this) {
assert(vtclog_left > 25);
i = snprintf(vtclog_buf, vtclog_left,
"**** dT %d.%03d\n", t_this / 1000, t_this % 1000);
t_last = t_this;
vtclog_buf += i;
vtclog_left -= i;
}
assert(vtclog_left > l); assert(vtclog_left > l);
memcpy(vtclog_buf, VSB_data(vl->vsb), l); memcpy(vtclog_buf, VSB_data(vl->vsb), l);
vtclog_buf += l; vtclog_buf += l;
...@@ -211,8 +222,8 @@ vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len) ...@@ -211,8 +222,8 @@ vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len)
if (str == NULL) if (str == NULL)
vtc_leadin(vl, lvl, "%s(null)\n", pfx); vtc_leadin(vl, lvl, "%s(null)\n", pfx);
else { else {
bprintf(buf, "%s %-4s %4.1f %s|", bprintf(buf, "%s %-4s %s|",
lead[lvl < 0 ? 1: lvl], vl->id, vl->tx, pfx); lead[lvl < 0 ? 1: lvl], vl->id, pfx);
if (len < 0) if (len < 0)
len = strlen(str); len = strlen(str);
VSB_quote_pfx(vl->vsb, buf, str, VSB_quote_pfx(vl->vsb, buf, str,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment