Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishevent
Commits
b38ed7c9
Commit
b38ed7c9
authored
Mar 31, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement and test formatter for %t
parent
c05ba7e6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
15 deletions
+55
-15
format.c
src/format.c
+16
-15
format.h
src/format.h
+2
-0
Makefile.am
src/test/Makefile.am
+1
-0
test_format.c
src/test/test_format.c
+36
-0
No files found.
src/format.c
View file @
b38ed7c9
...
...
@@ -40,6 +40,7 @@
#include "varnishevent.h"
#include "format.h"
#include "strfTIM.h"
typedef
struct
arg_t
{
char
*
name
;
...
...
@@ -409,28 +410,28 @@ FORMAT_r(backend, Bereq)
FORMAT
(
client
,
s
,
RespStatus
)
FORMAT
(
backend
,
s
,
BerespStatus
)
#if 0
#define FORMAT_tim(ltr, fmt, extra) \
static void
\
format_##ltr(
logline_t *ll, char *name, enum VSL_tag_e tag,
\
char **s, size_t *len)
\
void
\
format_##ltr(
tx_t *tx, char *name, enum VSL_tag_e tag,
\
char **s, size_t *len)
\
{ \
struct tm t;
\
double t;
\
(void) tag; \
extra;
\
if (get_tm(ll, &t)) {
\
AN(scratch);
\
size_t n = strftime(scratch, config.max_reclen, fmt, &t);
\
if (n == 0)
\
*scratch = '\0';
\
*s
= scratch;
\
*len = strlen(scratch);
\
}
\
(extra);
\
\
t = get_tm(tx);
\
AN(scratch);
\
size_t n = strfTIMlocal(scratch, config.max_reclen, fmt, t);
\
if (n == 0)
\
*s
cratch = '\0';
\
*s = scratch;
\
*len = strlen(scratch);
\
}
FORMAT_tim
(
t
,
"[%d/%b/%Y:%T %z]"
,
(
void
)
name
)
#if 0
#define FORMAT_U(dir, dx) \
static void \
format_U_##dir(logline_t *ll, char *name, enum VSL_tag_e tag, \
...
...
src/format.h
View file @
b38ed7c9
...
...
@@ -86,3 +86,5 @@ formatter_f format_r_backend;
formatter_f
format_s_client
;
formatter_f
format_s_backend
;
formatter_f
format_t
;
src/test/Makefile.am
View file @
b38ed7c9
...
...
@@ -21,6 +21,7 @@ test_format_SOURCES = \
test_format_LDADD
=
\
../config.
$(OBJEXT)
\
../strfTIM.
$(OBJEXT)
\
../format.
$(OBJEXT)
\
@VARNISH_LIBS@ @VARNISH_LIBVARNISH_LIB@
-lm
-lvarnish
...
...
src/test/test_format.c
View file @
b38ed7c9
...
...
@@ -794,6 +794,41 @@ static const char
return
NULL
;
}
static
const
char
*
test_format_t
(
void
)
{
tx_t
tx
;
logline_t
rec
;
chunk_t
chunk
;
char
*
str
;
const
char
*
error
;
size_t
len
;
vre_t
*
time_re
;
int
n
;
printf
(
"... testing format_t()
\n
"
);
#define HTTP_DATA_REGEX \
"^\\[\\d\\d/Mar/2015:\\d\\d:\\d\\d:\\d\\d [+-]\\d{4}\\]$"
time_re
=
VRE_compile
(
HTTP_DATA_REGEX
,
0
,
&
error
,
&
n
);
VMASSERT
(
time_re
!=
NULL
,
"Error compiling '"
HTTP_DATA_REGEX
"': %s (offset %d)"
,
error
,
n
);
init_tx_rec_chunk
(
&
tx
,
&
rec
,
&
chunk
);
MAN
(
chunk
.
data
);
set_record_data
(
&
rec
,
&
chunk
,
T1
,
SLT_Timestamp
);
format_t
(
&
tx
,
NULL
,
SLT__Bogus
,
&
str
,
&
len
);
n
=
VRE_exec
(
time_re
,
str
,
strlen
(
str
),
0
,
0
,
NULL
,
0
,
NULL
);
VMASSERT
(
n
>
0
,
"'%s' does not match '"
HTTP_DATA_REGEX
"', "
"return code = %d"
,
str
,
n
);
MASSERT
(
len
==
28
);
return
NULL
;
}
static
const
char
*
all_tests
(
void
)
{
...
...
@@ -814,6 +849,7 @@ static const char
mu_run_test
(
test_format_q
);
mu_run_test
(
test_format_r
);
mu_run_test
(
test_format_s
);
mu_run_test
(
test_format_t
);
return
NULL
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment