summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org.ua>2013-10-11 11:04:32 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2013-10-11 11:38:21 (GMT)
commit791cdf412f5fb66a056aa28b27507fdc9af86507 (patch) (side-by-side diff)
tree9e6c4af696424ea72b51d0b8d9c8cf85c8b43856 /src
parentdf83b714395d41b096f7ad8cc3a090c9341f7598 (diff)
downloadvmod-binlog-791cdf412f5fb66a056aa28b27507fdc9af86507.tar.gz
vmod-binlog-791cdf412f5fb66a056aa28b27507fdc9af86507.tar.bz2
Add testsuite.
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/binlog.c2
-rw-r--r--src/binlogcat.c18
2 files changed, 16 insertions, 4 deletions
diff --git a/src/binlog.c b/src/binlog.c
index f896803..be32e10 100644
--- a/src/binlog.c
+++ b/src/binlog.c
@@ -452,7 +452,7 @@ vmod_append(struct sess *sp, struct vmod_priv *priv, int nid, int aid)
return;
ts = time(NULL);
-
+
if (ts >= conf->stoptime) {
AZ(pthread_mutex_lock(&conf->mutex));
closefile(sp, conf);
diff --git a/src/binlogcat.c b/src/binlogcat.c
index c51125b..219f78c 100644
--- a/src/binlogcat.c
+++ b/src/binlogcat.c
@@ -28,6 +28,7 @@ char *progname;
char *timefmt = "%c";
int number_option;
int verbose_option;
+int timediff_option;
void
catlog(const char *fname)
@@ -37,7 +38,8 @@ catlog(const char *fname)
struct binlog_record rec;
char timebuf[128];
size_t i;
-
+ time_t start_ts;
+
if (strcmp(fname, "-") == 0)
fp = stdin;
else {
@@ -83,6 +85,12 @@ catlog(const char *fname)
break;
}
+ if (timediff_option) {
+ if (i == 0)
+ start_ts = rec.ts;
+ rec.ts -= start_ts;
+ }
+
strftime(timebuf, sizeof timebuf, timefmt, localtime(&rec.ts));
if (number_option)
printf("%lu ", (unsigned long) i);
@@ -95,7 +103,7 @@ catlog(const char *fname)
void
help()
{
- printf("usage: %s [-hnv] [t FORMAT] [FILE...]\n");
+ printf("usage: %s [-dhnv] [t FORMAT] [FILE...]\n");
}
int
@@ -104,8 +112,12 @@ main(int argc, char **argv)
progname = argv[0];
int c;
- while ((c = getopt(argc, argv, "ht:nv")) != EOF)
+ while ((c = getopt(argc, argv, "dht:nv")) != EOF)
switch (c) {
+ case 'd':
+ timediff_option = 1;
+ timefmt = "%s";
+ break;
case 'h':
help();
return 0;

Return to:

Send suggestions and report system problems to the System administrator.