From b6678bb65fce1f64e82cc049aae3d7ba6f8aa19c Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sat, 12 Oct 2013 12:19:32 +0300 Subject: Rewrite using opaque record data. Records can carry arbitrary data, whose format is defined using teplate strings similar to those of Perl's pack() function. The teplate string is stored in the logfile header and is used by binlogcat to render a human-readable representation. * src/.gitignore: New file. * pack.c: New file. * pack.h: New file. * src/Makefile.am: Add pack.c, pack.h * src/binlog.c: Rewrite. Use pack routines to construct each record. * src/binlogcat.c: Likewise. Use packout to unpack each record. * src/vmod-binlog.h (struct binlog_record): Remove nid,aid. (struct binlog_file_header): Add hdrsize. (BINLOG_HEADER_SIZE,union binlog_header): Remove (binlog_recnum): Remove. (binlog_size): Rewrite. * src/vmod.vcc (append,sappend): Remove. (init): Change signature. (start,commit,pack): New functions. * tests/test01.at: Rewrite. * tests/test02.at: Rewrite. --- tests/test01.at | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tests/test01.at') diff --git a/tests/test01.at b/tests/test01.at index 116c8f1..62eb4fb 100644 --- a/tests/test01.at +++ b/tests/test01.at @@ -15,7 +15,7 @@ # along with vmod-binlog. If not, see . AT_SETUP([appends]) -AT_KEYWORDS([append]) +AT_KEYWORDS([test01 append]) AT_CHECK([ cwd=`pwd` @@ -32,13 +32,16 @@ server s1 { varnish v1 -vcl+backend { import binlog from "$abs_top_builddir/src/.libs/libvmod_binlog.so"; sub vcl_init { - binlog.init("dir=$cwd/log;size=1M;pattern=logfile"); + binlog.init("$cwd/log", "LL", "size=1M;pattern=logfile"); } sub vcl_fini { binlog.close(); } sub vcl_recv { - binlog.sappend(req.http.X-nid, req.http.X-aid); + binlog.start(); + binlog.pack(req.http.X-nid); + binlog.pack(req.http.X-aid); + binlog.commit(); return (lookup); } } -start -- cgit v1.2.1