blob: b733811d3f0e62ef765815d0274f80992aaddaa8 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 * General logging functions.
3 *
Willy Tarreaub7f694f2008-06-22 17:18:02 +02004 * Copyright 2000-2008 Willy Tarreau <w@1wt.eu>
Willy Tarreaubaaee002006-06-26 02:48:02 +02005 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
Willy Tarreau8a3f52f2012-12-20 21:23:42 +010013#include <ctype.h>
Willy Tarreauc8f24f82007-11-30 18:38:35 +010014#include <fcntl.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020015#include <stdarg.h>
16#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19#include <syslog.h>
20#include <time.h>
21#include <unistd.h>
Robert Tsai81ae1952007-12-05 10:47:29 +010022#include <errno.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020023
24#include <sys/time.h>
25
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020026#include <common/config.h>
Willy Tarreaud6d06902009-08-19 11:22:33 +020027#include <common/compat.h>
Willy Tarreau2dd0d472006-06-29 17:53:05 +020028#include <common/standard.h>
Willy Tarreaufb278672006-10-15 15:38:50 +020029#include <common/time.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020030
Willy Tarreaubaaee002006-06-26 02:48:02 +020031#include <types/global.h>
William Lallemand723b73a2012-02-08 16:37:49 +010032#include <types/log.h>
Willy Tarreauec6c5df2008-07-15 00:22:45 +020033
William Lallemand5f232402012-04-05 18:02:55 +020034#include <proto/frontend.h>
Willy Tarreauec6c5df2008-07-15 00:22:45 +020035#include <proto/log.h>
Willy Tarreauc8368452012-12-21 00:09:23 +010036#include <proto/sample.h>
Willy Tarreau827aee92011-03-10 16:55:02 +010037#include <proto/stream_interface.h>
Willy Tarreau773d65f2012-10-12 14:56:11 +020038#ifdef USE_OPENSSL
39#include <proto/ssl_sock.h>
40#endif
Willy Tarreaubaaee002006-06-26 02:48:02 +020041
Willy Tarreaubaaee002006-06-26 02:48:02 +020042const char *log_facilities[NB_LOG_FACILITIES] = {
43 "kern", "user", "mail", "daemon",
44 "auth", "syslog", "lpr", "news",
45 "uucp", "cron", "auth2", "ftp",
46 "ntp", "audit", "alert", "cron2",
47 "local0", "local1", "local2", "local3",
48 "local4", "local5", "local6", "local7"
49};
50
51
52const char *log_levels[NB_LOG_LEVELS] = {
53 "emerg", "alert", "crit", "err",
54 "warning", "notice", "info", "debug"
55};
56
Justin Karnegeseb2c24a2012-05-24 15:28:52 -070057const char sess_term_cond[16] = "-cCsSPRIDKUIIIII"; /* normal, CliTo, CliErr, SrvTo, SrvErr, PxErr, Resource, Internal, Down, Killed, Up, -- */
Willy Tarreaub8750a82006-09-03 09:56:00 +020058const char sess_fin_state[8] = "-RCHDLQT"; /* cliRequest, srvConnect, srvHeader, Data, Last, Queue, Tarpit */
Willy Tarreaubaaee002006-06-26 02:48:02 +020059
William Lallemand723b73a2012-02-08 16:37:49 +010060
61/* log_format */
62struct logformat_type {
63 char *name;
64 int type;
William Lallemandbddd4fd2012-02-27 11:23:10 +010065 int mode;
William Lallemand5e19a282012-04-02 16:22:10 +020066 int lw; /* logwait bitsfield */
William Lallemandb7ff6a32012-03-02 14:35:21 +010067 int (*config_callback)(struct logformat_node *node, struct proxy *curproxy);
Willy Tarreau2beef582012-12-20 17:22:52 +010068 const char *replace_by; /* new option to use instead of old one */
William Lallemand723b73a2012-02-08 16:37:49 +010069};
70
William Lallemandb7ff6a32012-03-02 14:35:21 +010071int prepare_addrsource(struct logformat_node *node, struct proxy *curproxy);
72
William Lallemand723b73a2012-02-08 16:37:49 +010073/* log_format variable names */
74static const struct logformat_type logformat_keywords[] = {
William Lallemand5e19a282012-04-02 16:22:10 +020075 { "o", LOG_FMT_GLOBAL, PR_MODE_TCP, 0, NULL }, /* global option */
Willy Tarreau2beef582012-12-20 17:22:52 +010076
77 /* please keep these lines sorted ! */
78 { "B", LOG_FMT_BYTES, PR_MODE_TCP, LW_BYTES, NULL }, /* bytes from server to client */
79 { "CC", LOG_FMT_CCLIENT, PR_MODE_HTTP, LW_REQHDR, NULL }, /* client cookie */
80 { "CS", LOG_FMT_CSERVER, PR_MODE_HTTP, LW_RSPHDR, NULL }, /* server cookie */
81 { "H", LOG_FMT_HOSTNAME, PR_MODE_TCP, LW_INIT, NULL }, /* Hostname */
82 { "ID", LOG_FMT_UNIQUEID, PR_MODE_HTTP, LW_BYTES, NULL }, /* Unique ID */
83 { "ST", LOG_FMT_STATUS, PR_MODE_HTTP, LW_RESP, NULL }, /* status code */
William Lallemand5e19a282012-04-02 16:22:10 +020084 { "T", LOG_FMT_DATEGMT, PR_MODE_TCP, LW_INIT, NULL }, /* date GMT */
Willy Tarreau2beef582012-12-20 17:22:52 +010085 { "Tc", LOG_FMT_TC, PR_MODE_TCP, LW_BYTES, NULL }, /* Tc */
Yuxans Yao4e25b012012-10-19 10:36:09 +080086 { "Tl", LOG_FMT_DATELOCAL, PR_MODE_TCP, LW_INIT, NULL }, /* date local timezone */
William Lallemand5e19a282012-04-02 16:22:10 +020087 { "Tq", LOG_FMT_TQ, PR_MODE_HTTP, LW_BYTES, NULL }, /* Tq */
William Lallemand5e19a282012-04-02 16:22:10 +020088 { "Tr", LOG_FMT_TR, PR_MODE_HTTP, LW_BYTES, NULL }, /* Tr */
Willy Tarreau2beef582012-12-20 17:22:52 +010089 { "Ts", LOG_FMT_TS, PR_MODE_TCP, LW_INIT, NULL }, /* timestamp GMT */
William Lallemand5e19a282012-04-02 16:22:10 +020090 { "Tt", LOG_FMT_TT, PR_MODE_TCP, LW_BYTES, NULL }, /* Tt */
Willy Tarreau2beef582012-12-20 17:22:52 +010091 { "Tw", LOG_FMT_TW, PR_MODE_TCP, LW_BYTES, NULL }, /* Tw */
92 { "U", LOG_FMT_BYTES_UP, PR_MODE_TCP, LW_BYTES, NULL }, /* bytes from client to server */
William Lallemand5e19a282012-04-02 16:22:10 +020093 { "ac", LOG_FMT_ACTCONN, PR_MODE_TCP, LW_BYTES, NULL }, /* actconn */
Willy Tarreau2beef582012-12-20 17:22:52 +010094 { "b", LOG_FMT_BACKEND, PR_MODE_TCP, LW_INIT, NULL }, /* backend */
William Lallemand5e19a282012-04-02 16:22:10 +020095 { "bc", LOG_FMT_BECONN, PR_MODE_TCP, LW_BYTES, NULL }, /* beconn */
Willy Tarreau2beef582012-12-20 17:22:52 +010096 { "bi", LOG_FMT_BACKENDIP, PR_MODE_TCP, LW_BCKIP, prepare_addrsource }, /* backend source ip */
97 { "bp", LOG_FMT_BACKENDPORT, PR_MODE_TCP, LW_BCKIP, prepare_addrsource }, /* backend source port */
William Lallemand5e19a282012-04-02 16:22:10 +020098 { "bq", LOG_FMT_BCKQUEUE, PR_MODE_TCP, LW_BYTES, NULL }, /* backend_queue */
Willy Tarreau2beef582012-12-20 17:22:52 +010099 { "ci", LOG_FMT_CLIENTIP, PR_MODE_TCP, LW_CLIP, NULL }, /* client ip */
100 { "cp", LOG_FMT_CLIENTPORT, PR_MODE_TCP, LW_CLIP, NULL }, /* client port */
101 { "f", LOG_FMT_FRONTEND, PR_MODE_TCP, LW_INIT, NULL }, /* frontend */
102 { "fc", LOG_FMT_FECONN, PR_MODE_TCP, LW_BYTES, NULL }, /* feconn */
103 { "fi", LOG_FMT_FRONTENDIP, PR_MODE_TCP, LW_FRTIP, NULL }, /* frontend ip */
104 { "fp", LOG_FMT_FRONTENDPORT, PR_MODE_TCP, LW_FRTIP, NULL }, /* frontend port */
105 { "ft", LOG_FMT_FRONTEND_XPRT, PR_MODE_TCP, LW_INIT, NULL }, /* frontend with transport mode */
William Lallemand5e19a282012-04-02 16:22:10 +0200106 { "hr", LOG_FMT_HDRREQUEST, PR_MODE_HTTP, LW_REQHDR, NULL }, /* header request */
William Lallemand5e19a282012-04-02 16:22:10 +0200107 { "hrl", LOG_FMT_HDRREQUESTLIST, PR_MODE_HTTP, LW_REQHDR, NULL }, /* header request list */
Willy Tarreau2beef582012-12-20 17:22:52 +0100108 { "hs", LOG_FMT_HDRRESPONS, PR_MODE_HTTP, LW_RSPHDR, NULL }, /* header response */
William Lallemand5e19a282012-04-02 16:22:10 +0200109 { "hsl", LOG_FMT_HDRRESPONSLIST, PR_MODE_HTTP, LW_RSPHDR, NULL }, /* header response list */
Willy Tarreau2beef582012-12-20 17:22:52 +0100110 { "ms", LOG_FMT_MS, PR_MODE_TCP, LW_INIT, NULL }, /* accept date millisecond */
William Lallemand5e19a282012-04-02 16:22:10 +0200111 { "pid", LOG_FMT_PID, PR_MODE_TCP, LW_INIT, NULL }, /* log pid */
Willy Tarreau2beef582012-12-20 17:22:52 +0100112 { "r", LOG_FMT_REQ, PR_MODE_HTTP, LW_REQ, NULL }, /* request */
113 { "rc", LOG_FMT_RETRIES, PR_MODE_TCP, LW_BYTES, NULL }, /* retries */
William Lallemand5e19a282012-04-02 16:22:10 +0200114 { "rt", LOG_FMT_COUNTER, PR_MODE_HTTP, LW_REQ, NULL }, /* HTTP request counter */
Willy Tarreau2beef582012-12-20 17:22:52 +0100115 { "s", LOG_FMT_SERVER, PR_MODE_TCP, LW_SVID, NULL }, /* server */
116 { "sc", LOG_FMT_SRVCONN, PR_MODE_TCP, LW_BYTES, NULL }, /* srv_conn */
117 { "si", LOG_FMT_SERVERIP, PR_MODE_TCP, LW_SVIP, NULL }, /* server destination ip */
118 { "sp", LOG_FMT_SERVERPORT, PR_MODE_TCP, LW_SVIP, NULL }, /* server destination port */
119 { "sq", LOG_FMT_SRVQUEUE, PR_MODE_TCP, LW_BYTES, NULL }, /* srv_queue */
Willy Tarreauffc3fcd2012-10-12 20:17:54 +0200120 { "sslc", LOG_FMT_SSL_CIPHER, PR_MODE_TCP, LW_XPRT, NULL }, /* client-side SSL ciphers */
121 { "sslv", LOG_FMT_SSL_VERSION, PR_MODE_TCP, LW_XPRT, NULL }, /* client-side SSL protocol version */
Willy Tarreau2beef582012-12-20 17:22:52 +0100122 { "t", LOG_FMT_DATE, PR_MODE_TCP, LW_INIT, NULL }, /* date */
123 { "ts", LOG_FMT_TERMSTATE, PR_MODE_TCP, LW_BYTES, NULL },/* termination state */
124 { "tsc", LOG_FMT_TERMSTATE_CK, PR_MODE_TCP, LW_INIT, NULL },/* termination state */
125
126 /* The following tags are deprecated and will be removed soon */
127 { "Bi", LOG_FMT_BACKENDIP, PR_MODE_TCP, LW_BCKIP, prepare_addrsource, "bi" }, /* backend source ip */
128 { "Bp", LOG_FMT_BACKENDPORT, PR_MODE_TCP, LW_BCKIP, prepare_addrsource, "bp" }, /* backend source port */
129 { "Ci", LOG_FMT_CLIENTIP, PR_MODE_TCP, LW_CLIP, NULL, "ci" }, /* client ip */
130 { "Cp", LOG_FMT_CLIENTPORT, PR_MODE_TCP, LW_CLIP, NULL, "cp" }, /* client port */
131 { "Fi", LOG_FMT_FRONTENDIP, PR_MODE_TCP, LW_FRTIP, NULL, "fi" }, /* frontend ip */
132 { "Fp", LOG_FMT_FRONTENDPORT, PR_MODE_TCP, LW_FRTIP, NULL, "fp" }, /* frontend port */
133 { "Si", LOG_FMT_SERVERIP, PR_MODE_TCP, LW_SVIP, NULL, "si" }, /* server destination ip */
134 { "Sp", LOG_FMT_SERVERPORT, PR_MODE_TCP, LW_SVIP, NULL, "sp" }, /* server destination port */
135 { "cc", LOG_FMT_CCLIENT, PR_MODE_HTTP, LW_REQHDR, NULL, "CC" }, /* client cookie */
136 { "cs", LOG_FMT_CSERVER, PR_MODE_HTTP, LW_RSPHDR, NULL, "CS" }, /* server cookie */
137 { "st", LOG_FMT_STATUS, PR_MODE_HTTP, LW_RESP, NULL, "ST" }, /* status code */
William Lallemand5e19a282012-04-02 16:22:10 +0200138 { 0, 0, 0, 0, NULL }
William Lallemand723b73a2012-02-08 16:37:49 +0100139};
140
Willy Tarreau2beef582012-12-20 17:22:52 +0100141char default_http_log_format[] = "%ci:%cp [%t] %ft %b/%s %Tq/%Tw/%Tc/%Tr/%Tt %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r"; // default format
142char clf_http_log_format[] = "%{+Q}o %{-Q}ci - - [%T] %r %ST %B \"\" \"\" %cp %ms %ft %b %s %Tq %Tw %Tc %Tr %Tt %tsc %ac %fc %bc %sc %rc %sq %bq %CC %CS %hrl %hsl";
143char default_tcp_log_format[] = "%ci:%cp [%t] %ft %b/%s %Tw/%Tc/%Tt %B %ts %ac/%fc/%bc/%sc/%rc %sq/%bq";
William Lallemand723b73a2012-02-08 16:37:49 +0100144char *log_format = NULL;
145
Willy Tarreaub1a2faf2012-03-19 16:51:53 +0100146/* This is a global syslog line, common to all outgoing messages. It begins
147 * with the syslog tag and the date that are updated by update_log_hdr().
148 */
149static char logline[MAX_SYSLOG_LEN];
150
William Lallemand723b73a2012-02-08 16:37:49 +0100151struct logformat_var_args {
152 char *name;
153 int mask;
154};
155
156struct logformat_var_args var_args_list[] = {
157// global
158 { "M", LOG_OPT_MANDATORY },
159 { "Q", LOG_OPT_QUOTE },
William Lallemand5f232402012-04-05 18:02:55 +0200160 { "X", LOG_OPT_HEXA },
William Lallemand723b73a2012-02-08 16:37:49 +0100161 { 0, 0 }
162};
163
164/*
William Lallemandb7ff6a32012-03-02 14:35:21 +0100165 * callback used to configure addr source retrieval
166 */
167int prepare_addrsource(struct logformat_node *node, struct proxy *curproxy)
168{
169 curproxy->options2 |= PR_O2_SRC_ADDR;
170
171 return 0;
172}
173
174
175/*
William Lallemand723b73a2012-02-08 16:37:49 +0100176 * Parse args in a logformat_var
177 */
178int parse_logformat_var_args(char *args, struct logformat_node *node)
179{
180 int i = 0;
181 int end = 0;
182 int flags = 0; // 1 = + 2 = -
183 char *sp = NULL; // start pointer
184
185 if (args == NULL)
186 return 1;
187
188 while (1) {
189 if (*args == '\0')
190 end = 1;
191
192 if (*args == '+') {
193 // add flag
194 sp = args + 1;
195 flags = 1;
196 }
197 if (*args == '-') {
198 // delete flag
199 sp = args + 1;
200 flags = 2;
201 }
202
203 if (*args == '\0' || *args == ',') {
204 *args = '\0';
Willy Tarreau254d44c2012-12-20 18:19:26 +0100205 for (i = 0; sp && var_args_list[i].name; i++) {
William Lallemand723b73a2012-02-08 16:37:49 +0100206 if (strcmp(sp, var_args_list[i].name) == 0) {
207 if (flags == 1) {
208 node->options |= var_args_list[i].mask;
209 break;
210 } else if (flags == 2) {
211 node->options &= ~var_args_list[i].mask;
212 break;
213 }
214 }
215 }
216 sp = NULL;
217 if (end)
218 break;
219 }
Willy Tarreau254d44c2012-12-20 18:19:26 +0100220 args++;
William Lallemand723b73a2012-02-08 16:37:49 +0100221 }
222 return 0;
223}
224
225/*
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100226 * Parse a variable '%varname' or '%{args}varname' in log-format. The caller
227 * must pass the args part in the <arg> pointer with its length in <arg_len>,
228 * and varname with its length in <var> and <var_len> respectively. <arg> is
229 * ignored when arg_len is 0. Neither <var> nor <var_len> may be null.
William Lallemand723b73a2012-02-08 16:37:49 +0100230 */
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100231int parse_logformat_var(char *arg, int arg_len, char *var, int var_len, struct proxy *curproxy, struct list *list_format, int *defoptions)
William Lallemand723b73a2012-02-08 16:37:49 +0100232{
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100233 int j;
234 struct logformat_node *node;
William Lallemand723b73a2012-02-08 16:37:49 +0100235
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100236 for (j = 0; logformat_keywords[j].name; j++) { // search a log type
237 if (strlen(logformat_keywords[j].name) == var_len &&
238 strncmp(var, logformat_keywords[j].name, var_len) == 0) {
239 if (logformat_keywords[j].mode != PR_MODE_HTTP || curproxy->mode == PR_MODE_HTTP) {
240 node = calloc(1, sizeof(struct logformat_node));
241 node->type = logformat_keywords[j].type;
242 node->options = *defoptions;
243 if (arg_len) {
244 node->arg = my_strndup(arg, arg_len);
245 parse_logformat_var_args(node->arg, node);
246 }
247 if (node->type == LOG_FMT_GLOBAL) {
248 *defoptions = node->options;
249 free(node->arg);
250 free(node);
251 } else {
252 if (logformat_keywords[j].config_callback &&
253 logformat_keywords[j].config_callback(node, curproxy) != 0) {
William Lallemandbddd4fd2012-02-27 11:23:10 +0100254 return -1;
William Lallemand723b73a2012-02-08 16:37:49 +0100255 }
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100256 curproxy->to_log |= logformat_keywords[j].lw;
257 LIST_ADDQ(list_format, &node->list);
William Lallemand723b73a2012-02-08 16:37:49 +0100258 }
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100259 if (logformat_keywords[j].replace_by)
260 Warning("Warning: deprecated variable '%s' in log-format, please replace it with '%s'\n",
261 logformat_keywords[j].name, logformat_keywords[j].replace_by);
262 return 0;
263 } else {
264 Warning("Warning: log-format variable name '%s' is not suited to HTTP mode\n", logformat_keywords[j].name);
265 return -1;
William Lallemand723b73a2012-02-08 16:37:49 +0100266 }
William Lallemand723b73a2012-02-08 16:37:49 +0100267 }
268 }
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100269
270 j = var[var_len];
271 var[var_len] = 0;
272 Warning("Warning: no such variable name '%s' in log-format\n", var);
273 var[var_len] = j;
William Lallemand723b73a2012-02-08 16:37:49 +0100274 return -1;
275}
276
277/*
278 * push to the logformat linked list
279 *
280 * start: start pointer
281 * end: end text pointer
282 * type: string type
William Lallemand1d705562012-03-12 12:46:41 +0100283 * list_format: destination list
William Lallemand723b73a2012-02-08 16:37:49 +0100284 *
285 * LOG_TEXT: copy chars from start to end excluding end.
286 *
287*/
William Lallemand1d705562012-03-12 12:46:41 +0100288void add_to_logformat_list(char *start, char *end, int type, struct list *list_format)
William Lallemand723b73a2012-02-08 16:37:49 +0100289{
290 char *str;
291
Willy Tarreaua3571662012-12-20 21:59:12 +0100292 if (type == LF_TEXT) { /* type text */
William Lallemand723b73a2012-02-08 16:37:49 +0100293 struct logformat_node *node = calloc(1, sizeof(struct logformat_node));
William Lallemand723b73a2012-02-08 16:37:49 +0100294 str = calloc(end - start + 1, 1);
295 strncpy(str, start, end - start);
William Lallemand723b73a2012-02-08 16:37:49 +0100296 str[end - start] = '\0';
297 node->arg = str;
William Lallemand1d705562012-03-12 12:46:41 +0100298 node->type = LOG_FMT_TEXT; // type string
299 LIST_ADDQ(list_format, &node->list);
Willy Tarreaua3571662012-12-20 21:59:12 +0100300 } else if (type == LF_SEPARATOR) {
William Lallemand723b73a2012-02-08 16:37:49 +0100301 struct logformat_node *node = calloc(1, sizeof(struct logformat_node));
William Lallemand1d705562012-03-12 12:46:41 +0100302 node->type = LOG_FMT_SEPARATOR;
303 LIST_ADDQ(list_format, &node->list);
William Lallemand723b73a2012-02-08 16:37:49 +0100304 }
305}
306
307/*
Willy Tarreauc8368452012-12-21 00:09:23 +0100308 * Parse the sample fetch expression <text> and add a node to <list_format> upon
309 * success. At the moment, sample converters are not yet supported but fetch arguments
310 * should work.
311 */
312void add_sample_to_logformat_list(char *text, char *arg, int arg_len, struct proxy *curpx, struct list *list_format, int options)
313{
314 char *cmd[2];
315 struct sample_expr *expr;
316 struct logformat_node *node;
317 int cmd_arg;
318
319 cmd[0] = text;
320 cmd[1] = "";
321 cmd_arg = 0;
322
323 expr = sample_parse_expr(cmd, &cmd_arg, trash.str, trash.size);
324 if (!expr) {
325 Warning("log-format: sample fetch <%s> failed with : %s\n", text, trash.str);
326 return;
327 }
328
329 node = calloc(1, sizeof(struct logformat_node));
330 node->type = LOG_FMT_EXPR;
331 node->expr = expr;
332 node->options = options;
333
334 if (arg_len) {
335 node->arg = my_strndup(arg, arg_len);
336 parse_logformat_var_args(node->arg, node);
337 }
338 if (expr->fetch->cap & SMP_CAP_REQ)
339 node->options |= LOG_OPT_REQ_CAP; /* fetch method is request-compatible */
340
341 if (expr->fetch->cap & SMP_CAP_RES)
342 node->options |= LOG_OPT_RES_CAP; /* fetch method is response-compatible */
343
344 /* check if we need to allocate an hdr_idx struct for HTTP parsing */
345 /* Note, we may also need to set curpx->to_log with certain fetches */
346 if (expr->fetch->cap & SMP_CAP_L7)
347 curpx->acl_requires |= ACL_USE_L7_ANY;
348
349 LIST_ADDQ(list_format, &node->list);
350}
351
352/*
William Lallemand723b73a2012-02-08 16:37:49 +0100353 * Parse the log_format string and fill a linked list.
354 * Variable name are preceded by % and composed by characters [a-zA-Z0-9]* : %varname
355 * You can set arguments using { } : %{many arguments}varname
William Lallemand1d705562012-03-12 12:46:41 +0100356 *
357 * str: the string to parse
358 * curproxy: the proxy affected
359 * list_format: the destination list
360 * capabilities: PR_MODE_TCP_ | PR_MODE_HTTP
William Lallemand723b73a2012-02-08 16:37:49 +0100361 */
Willy Tarreaub83bc1e2012-12-24 12:36:33 +0100362void parse_logformat_string(const char *fmt, struct proxy *curproxy, struct list *list_format, int capabilities)
William Lallemand723b73a2012-02-08 16:37:49 +0100363{
Willy Tarreaub83bc1e2012-12-24 12:36:33 +0100364 char *sp, *str, *backfmt; /* start pointer for text parts */
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100365 char *arg = NULL; /* start pointer for args */
366 char *var = NULL; /* start pointer for vars */
367 int arg_len = 0;
368 int var_len = 0;
369 int cformat; /* current token format */
370 int pformat; /* previous token format */
William Lallemand723b73a2012-02-08 16:37:49 +0100371 struct logformat_node *tmplf, *back;
William Lallemand81f51172012-03-12 11:03:47 +0100372 int options = 0;
William Lallemand723b73a2012-02-08 16:37:49 +0100373
Willy Tarreaub83bc1e2012-12-24 12:36:33 +0100374 sp = str = backfmt = strdup(fmt);
William Lallemand1dc00ef2012-08-09 16:41:35 +0200375 curproxy->to_log |= LW_INIT;
William Lallemand5e19a282012-04-02 16:22:10 +0200376
William Lallemand723b73a2012-02-08 16:37:49 +0100377 /* flush the list first. */
William Lallemand1d705562012-03-12 12:46:41 +0100378 list_for_each_entry_safe(tmplf, back, list_format, list) {
William Lallemand723b73a2012-02-08 16:37:49 +0100379 LIST_DEL(&tmplf->list);
380 free(tmplf);
381 }
382
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100383 for (cformat = LF_INIT; cformat != LF_END; str++) {
William Lallemand723b73a2012-02-08 16:37:49 +0100384 pformat = cformat;
385
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100386 if (!*str)
387 cformat = LF_END; // preset it to save all states from doing this
William Lallemand723b73a2012-02-08 16:37:49 +0100388
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100389 /* The prinicple of the two-step state machine below is to first detect a change, and
390 * second have all common paths processed at one place. The common paths are the ones
391 * encountered in text areas (LF_INIT, LF_TEXT, LF_SEPARATOR) and at the end (LF_END).
392 * We use the common LF_INIT state to dispatch to the different final states.
393 */
394 switch (pformat) {
395 case LF_STARTVAR: // text immediately following a '%'
Willy Tarreauc8368452012-12-21 00:09:23 +0100396 arg = NULL; var = NULL;
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100397 arg_len = var_len = 0;
398 if (*str == '{') { // optional argument
399 cformat = LF_STARG;
400 arg = str + 1;
William Lallemand723b73a2012-02-08 16:37:49 +0100401 }
Willy Tarreauc8368452012-12-21 00:09:23 +0100402 else if (*str == '[') {
403 cformat = LF_STEXPR;
404 var = str + 1; // store expr in variable name
405 }
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100406 else if (isalnum((int)*str)) { // variable name
William Lallemand723b73a2012-02-08 16:37:49 +0100407 cformat = LF_VAR;
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100408 var = str;
William Lallemand723b73a2012-02-08 16:37:49 +0100409 }
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100410 else if (*str == '%')
411 cformat = LF_TEXT; // convert this character to a litteral (useful for '%')
412 else
413 cformat = LF_INIT; // handle other cases of litterals
414 break;
415
416 case LF_STARG: // text immediately following '%{'
417 if (*str == '}') { // end of arg
William Lallemand723b73a2012-02-08 16:37:49 +0100418 cformat = LF_EDARG;
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100419 arg_len = str - arg;
420 *str = 0; // used for reporting errors
William Lallemand723b73a2012-02-08 16:37:49 +0100421 }
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100422 break;
423
424 case LF_EDARG: // text immediately following '%{arg}'
Willy Tarreauc8368452012-12-21 00:09:23 +0100425 if (*str == '[') {
426 cformat = LF_STEXPR;
427 var = str + 1; // store expr in variable name
428 break;
429 }
430 else if (isalnum((int)*str)) { // variable name
William Lallemand723b73a2012-02-08 16:37:49 +0100431 cformat = LF_VAR;
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100432 var = str;
433 break;
434 }
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100435 Warning("Skipping isolated argument in log-format line : '%%{%s}'\n", arg);
436 cformat = LF_INIT;
437 break;
438
Willy Tarreauc8368452012-12-21 00:09:23 +0100439 case LF_STEXPR: // text immediately following '%['
440 if (*str == ']') { // end of arg
441 cformat = LF_EDEXPR;
442 var_len = str - var;
443 *str = 0; // needed for parsing the expression
444 }
445 break;
446
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100447 case LF_VAR: // text part of a variable name
448 var_len = str - var;
449 if (!isalnum((int)*str))
450 cformat = LF_INIT; // not variable name anymore
451 break;
452
Willy Tarreauc8368452012-12-21 00:09:23 +0100453 default: // LF_INIT, LF_TEXT, LF_SEPARATOR, LF_END, LF_EDEXPR
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100454 cformat = LF_INIT;
455 }
456
457 if (cformat == LF_INIT) { /* resynchronize state to text/sep/startvar */
458 switch (*str) {
459 case '%': cformat = LF_STARTVAR; break;
460 case ' ': cformat = LF_SEPARATOR; break;
461 case 0 : cformat = LF_END; break;
462 default : cformat = LF_TEXT; break;
William Lallemand723b73a2012-02-08 16:37:49 +0100463 }
464 }
465
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100466 if (cformat != pformat || pformat == LF_SEPARATOR) {
467 switch (pformat) {
468 case LF_VAR:
469 parse_logformat_var(arg, arg_len, var, var_len, curproxy, list_format, &options);
470 break;
Willy Tarreauc8368452012-12-21 00:09:23 +0100471 case LF_STEXPR:
472 add_sample_to_logformat_list(var, arg, arg_len, curproxy, list_format, options);
473 break;
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100474 case LF_TEXT:
475 case LF_SEPARATOR:
476 add_to_logformat_list(sp, str, pformat, list_format);
477 break;
478 }
479 sp = str; /* new start of text at every state switch and at every separator */
William Lallemand723b73a2012-02-08 16:37:49 +0100480 }
481 }
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100482
Willy Tarreauc8368452012-12-21 00:09:23 +0100483 if (pformat == LF_STARTVAR || pformat == LF_STARG || pformat == LF_STEXPR)
484 Warning("Ignoring end of truncated log-format line after '%s'\n", var ? var : arg ? arg : "%");
Willy Tarreau3ed22a42012-12-23 17:29:07 +0100485
Willy Tarreaub83bc1e2012-12-24 12:36:33 +0100486 free(backfmt);
William Lallemand723b73a2012-02-08 16:37:49 +0100487}
488
Willy Tarreaubaaee002006-06-26 02:48:02 +0200489/*
490 * Displays the message on stderr with the date and pid. Overrides the quiet
491 * mode during startup.
492 */
Willy Tarreaub17916e2006-10-15 15:17:57 +0200493void Alert(const char *fmt, ...)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200494{
495 va_list argp;
Willy Tarreaufe944602007-10-25 10:34:16 +0200496 struct tm tm;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200497
498 if (!(global.mode & MODE_QUIET) || (global.mode & (MODE_VERBOSE | MODE_STARTING))) {
499 va_start(argp, fmt);
500
Willy Tarreaub7f694f2008-06-22 17:18:02 +0200501 get_localtime(date.tv_sec, &tm);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200502 fprintf(stderr, "[ALERT] %03d/%02d%02d%02d (%d) : ",
Willy Tarreaufe944602007-10-25 10:34:16 +0200503 tm.tm_yday, tm.tm_hour, tm.tm_min, tm.tm_sec, (int)getpid());
Willy Tarreaubaaee002006-06-26 02:48:02 +0200504 vfprintf(stderr, fmt, argp);
505 fflush(stderr);
506 va_end(argp);
507 }
508}
509
510
511/*
512 * Displays the message on stderr with the date and pid.
513 */
Willy Tarreaub17916e2006-10-15 15:17:57 +0200514void Warning(const char *fmt, ...)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200515{
516 va_list argp;
Willy Tarreaufe944602007-10-25 10:34:16 +0200517 struct tm tm;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200518
519 if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) {
520 va_start(argp, fmt);
521
Willy Tarreaub7f694f2008-06-22 17:18:02 +0200522 get_localtime(date.tv_sec, &tm);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200523 fprintf(stderr, "[WARNING] %03d/%02d%02d%02d (%d) : ",
Willy Tarreaufe944602007-10-25 10:34:16 +0200524 tm.tm_yday, tm.tm_hour, tm.tm_min, tm.tm_sec, (int)getpid());
Willy Tarreaubaaee002006-06-26 02:48:02 +0200525 vfprintf(stderr, fmt, argp);
526 fflush(stderr);
527 va_end(argp);
528 }
529}
530
531/*
532 * Displays the message on <out> only if quiet mode is not set.
533 */
Willy Tarreaub17916e2006-10-15 15:17:57 +0200534void qfprintf(FILE *out, const char *fmt, ...)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200535{
536 va_list argp;
537
538 if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) {
539 va_start(argp, fmt);
540 vfprintf(out, fmt, argp);
541 fflush(out);
542 va_end(argp);
543 }
544}
545
546/*
547 * returns log level for <lev> or -1 if not found.
548 */
549int get_log_level(const char *lev)
550{
551 int level;
552
553 level = NB_LOG_LEVELS - 1;
554 while (level >= 0 && strcmp(log_levels[level], lev))
555 level--;
556
557 return level;
558}
559
560
561/*
562 * returns log facility for <fac> or -1 if not found.
563 */
564int get_log_facility(const char *fac)
565{
566 int facility;
567
568 facility = NB_LOG_FACILITIES - 1;
569 while (facility >= 0 && strcmp(log_facilities[facility], fac))
570 facility--;
William Lallemand2a4a44f2012-02-06 16:00:33 +0100571
Willy Tarreaubaaee002006-06-26 02:48:02 +0200572 return facility;
573}
574
William Lallemanda1cc3812012-02-08 16:38:44 +0100575/*
576 * Write a string in the log string
William Lallemand5f232402012-04-05 18:02:55 +0200577 * Take cares of quote options
William Lallemanda1cc3812012-02-08 16:38:44 +0100578 *
579 * Return the adress of the \0 character, or NULL on error
580 */
Willy Tarreau2b0108a2012-12-21 19:23:44 +0100581char *lf_text_len(char *dst, const char *src, size_t len, size_t size, struct logformat_node *node)
William Lallemanda1cc3812012-02-08 16:38:44 +0100582{
Willy Tarreau2b0108a2012-12-21 19:23:44 +0100583 if (size < 2)
584 return NULL;
William Lallemanda1cc3812012-02-08 16:38:44 +0100585
Willy Tarreau2b0108a2012-12-21 19:23:44 +0100586 if (node->options & LOG_OPT_QUOTE) {
587 *(dst++) = '"';
588 size--;
William Lallemandbddd4fd2012-02-27 11:23:10 +0100589 }
Willy Tarreau2b0108a2012-12-21 19:23:44 +0100590
591 if (src) {
592 if (++len > size)
593 len = size;
594 len = strlcpy2(dst, src, len);
595
596 size -= len;
597 dst += len;
598 }
599
600 if (node->options & LOG_OPT_QUOTE) {
601 if (size < 2)
602 return NULL;
603 *(dst++) = '"';
604 }
605
606 *dst = '\0';
William Lallemandbddd4fd2012-02-27 11:23:10 +0100607 return dst;
William Lallemanda1cc3812012-02-08 16:38:44 +0100608}
609
Willy Tarreau2b0108a2012-12-21 19:23:44 +0100610static inline char *lf_text(char *dst, const char *src, size_t size, struct logformat_node *node)
611{
612 return lf_text_len(dst, src, size, size, node);
613}
614
William Lallemand5f232402012-04-05 18:02:55 +0200615/*
616 * Write a IP adress to the log string
617 * +X option write in hexadecimal notation, most signifant byte on the left
618 */
619char *lf_ip(char *dst, struct sockaddr *sockaddr, size_t size, struct logformat_node *node)
620{
621 char *ret = dst;
622 int iret;
623 char pn[INET6_ADDRSTRLEN];
624
625 if (node->options & LOG_OPT_HEXA) {
626 const unsigned char *addr = (const unsigned char *)&((struct sockaddr_in *)sockaddr)->sin_addr.s_addr;
627 iret = snprintf(dst, size, "%02X%02X%02X%02X", addr[0], addr[1], addr[2], addr[3]);
628 if (iret < 0 || iret > size)
629 return NULL;
630 ret += iret;
631 } else {
632 addr_to_str((struct sockaddr_storage *)sockaddr, pn, sizeof(pn));
633 ret = lf_text(dst, pn, size, node);
634 if (ret == NULL)
635 return NULL;
636 }
637 return ret;
638}
639
640/*
641 * Write a port to the log
642 * +X option write in hexadecimal notation, most signifant byte on the left
643 */
644char *lf_port(char *dst, struct sockaddr *sockaddr, size_t size, struct logformat_node *node)
645{
646 char *ret = dst;
647 int iret;
648
649 if (node->options & LOG_OPT_HEXA) {
650 const unsigned char *port = (const unsigned char *)&((struct sockaddr_in *)sockaddr)->sin_port;
651 iret = snprintf(dst, size, "%02X%02X", port[0], port[1]);
652 if (iret < 0 || iret > size)
653 return NULL;
654 ret += iret;
655 } else {
656 ret = ltoa_o(get_host_port((struct sockaddr_storage *)sockaddr), dst, size);
657 if (ret == NULL)
658 return NULL;
659 }
660 return ret;
661}
662
Willy Tarreaub1a2faf2012-03-19 16:51:53 +0100663/* Re-generate the syslog header at the beginning of logline once a second and
664 * return the pointer to the first character after the header.
665 */
666static char *update_log_hdr()
Willy Tarreaubaaee002006-06-26 02:48:02 +0200667{
Willy Tarreaub1a2faf2012-03-19 16:51:53 +0100668 static long tvsec;
669 static char *dataptr = NULL; /* backup of last end of header, NULL first time */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200670
Willy Tarreaub7f694f2008-06-22 17:18:02 +0200671 if (unlikely(date.tv_sec != tvsec || dataptr == NULL)) {
Willy Tarreaubaaee002006-06-26 02:48:02 +0200672 /* this string is rebuild only once a second */
Willy Tarreaufe944602007-10-25 10:34:16 +0200673 struct tm tm;
Willy Tarreaub1a2faf2012-03-19 16:51:53 +0100674 int hdr_len;
Willy Tarreaufe944602007-10-25 10:34:16 +0200675
Willy Tarreaub7f694f2008-06-22 17:18:02 +0200676 tvsec = date.tv_sec;
Willy Tarreaufe944602007-10-25 10:34:16 +0200677 get_localtime(tvsec, &tm);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200678
Willy Tarreaub1a2faf2012-03-19 16:51:53 +0100679 hdr_len = snprintf(logline, MAX_SYSLOG_LEN,
Joe Williamsdf5b38f2010-12-29 17:05:48 +0100680 "<<<<>%s %2d %02d:%02d:%02d %s%s[%d]: ",
Willy Tarreaufe944602007-10-25 10:34:16 +0200681 monthname[tm.tm_mon],
682 tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
Joe Williamsdf5b38f2010-12-29 17:05:48 +0100683 global.log_send_hostname ? global.log_send_hostname : "",
Kevinm48936af2010-12-22 16:08:21 +0000684 global.log_tag, pid);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200685 /* WARNING: depending upon implementations, snprintf may return
686 * either -1 or the number of bytes that would be needed to store
687 * the total message. In both cases, we must adjust it.
688 */
William Lallemand2a4a44f2012-02-06 16:00:33 +0100689 if (hdr_len < 0 || hdr_len > MAX_SYSLOG_LEN)
690 hdr_len = MAX_SYSLOG_LEN;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200691
Willy Tarreaub1a2faf2012-03-19 16:51:53 +0100692 dataptr = logline + hdr_len;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200693 }
694
William Lallemand2a4a44f2012-02-06 16:00:33 +0100695 return dataptr;
696}
697
698/*
699 * This function adds a header to the message and sends the syslog message
Willy Tarreau53bf6af2012-02-24 11:46:54 +0100700 * using a printf format string. It expects an LF-terminated message.
William Lallemand2a4a44f2012-02-06 16:00:33 +0100701 */
702void send_log(struct proxy *p, int level, const char *format, ...)
703{
704 va_list argp;
Willy Tarreaub1a2faf2012-03-19 16:51:53 +0100705 char *dataptr;
706 int data_len;
William Lallemand2a4a44f2012-02-06 16:00:33 +0100707
708 if (level < 0 || format == NULL)
709 return;
710
Willy Tarreaub1a2faf2012-03-19 16:51:53 +0100711 dataptr = update_log_hdr(); /* update log header and skip it */
712 data_len = dataptr - logline;
William Lallemand2a4a44f2012-02-06 16:00:33 +0100713
714 va_start(argp, format);
Willy Tarreaub1a2faf2012-03-19 16:51:53 +0100715 data_len += vsnprintf(dataptr, logline + sizeof(logline) - dataptr, format, argp);
William Lallemand2a4a44f2012-02-06 16:00:33 +0100716 if (data_len < 0 || data_len > MAX_SYSLOG_LEN)
717 data_len = MAX_SYSLOG_LEN;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200718 va_end(argp);
William Lallemand2a4a44f2012-02-06 16:00:33 +0100719
Willy Tarreaub1a2faf2012-03-19 16:51:53 +0100720 __send_log(p, level, logline, data_len);
William Lallemand2a4a44f2012-02-06 16:00:33 +0100721}
722
723/*
724 * This function sends a syslog message.
725 * It doesn't care about errors nor does it report them.
Willy Tarreau53bf6af2012-02-24 11:46:54 +0100726 * It overrides the last byte (message[size-1]) with an LF character.
William Lallemand2a4a44f2012-02-06 16:00:33 +0100727 */
728void __send_log(struct proxy *p, int level, char *message, size_t size)
729{
730 static int logfdunix = -1; /* syslog to AF_UNIX socket */
731 static int logfdinet = -1; /* syslog to AF_INET socket */
732 static char *dataptr = NULL;
733 int fac_level;
734 struct list *logsrvs = NULL;
735 struct logsrv *tmp = NULL;
736 int nblogger;
737 char *log_ptr;
738
739 dataptr = message;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200740
741 if (p == NULL) {
William Lallemand0f99e342011-10-12 17:50:54 +0200742 if (!LIST_ISEMPTY(&global.logsrvs)) {
743 logsrvs = &global.logsrvs;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200744 }
745 } else {
William Lallemand0f99e342011-10-12 17:50:54 +0200746 if (!LIST_ISEMPTY(&p->logsrvs)) {
747 logsrvs = &p->logsrvs;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200748 }
Robert Tsai81ae1952007-12-05 10:47:29 +0100749 }
750
William Lallemand0f99e342011-10-12 17:50:54 +0200751 if (!logsrvs)
752 return;
753
William Lallemand2a4a44f2012-02-06 16:00:33 +0100754 message[size - 1] = '\n';
755
Robert Tsai81ae1952007-12-05 10:47:29 +0100756 /* Lazily set up syslog sockets for protocol families of configured
757 * syslog servers. */
William Lallemand0f99e342011-10-12 17:50:54 +0200758 nblogger = 0;
759 list_for_each_entry(tmp, logsrvs, list) {
760 const struct logsrv *logsrv = tmp;
Robert Tsai81ae1952007-12-05 10:47:29 +0100761 int proto, *plogfd;
William Lallemand0f99e342011-10-12 17:50:54 +0200762
David du Colombier11bcb6c2011-03-24 12:23:00 +0100763 if (logsrv->addr.ss_family == AF_UNIX) {
Robert Tsai81ae1952007-12-05 10:47:29 +0100764 proto = 0;
765 plogfd = &logfdunix;
766 } else {
Robert Tsai81ae1952007-12-05 10:47:29 +0100767 proto = IPPROTO_UDP;
768 plogfd = &logfdinet;
769 }
770 if (*plogfd >= 0) {
771 /* socket already created. */
772 continue;
773 }
David du Colombier11bcb6c2011-03-24 12:23:00 +0100774 if ((*plogfd = socket(logsrv->addr.ss_family, SOCK_DGRAM,
Robert Tsai81ae1952007-12-05 10:47:29 +0100775 proto)) < 0) {
776 Alert("socket for logger #%d failed: %s (errno=%d)\n",
777 nblogger + 1, strerror(errno), errno);
778 return;
779 }
780 /* we don't want to receive anything on this socket */
781 setsockopt(*plogfd, SOL_SOCKET, SO_RCVBUF, &zero, sizeof(zero));
782 /* does nothing under Linux, maybe needed for others */
783 shutdown(*plogfd, SHUT_RD);
William Lallemand0f99e342011-10-12 17:50:54 +0200784 nblogger++;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200785 }
786
Robert Tsai81ae1952007-12-05 10:47:29 +0100787 /* Send log messages to syslog server. */
William Lallemand0f99e342011-10-12 17:50:54 +0200788 nblogger = 0;
789 list_for_each_entry(tmp, logsrvs, list) {
790 const struct logsrv *logsrv = tmp;
David du Colombier11bcb6c2011-03-24 12:23:00 +0100791 int *plogfd = logsrv->addr.ss_family == AF_UNIX ?
Robert Tsai81ae1952007-12-05 10:47:29 +0100792 &logfdunix : &logfdinet;
793 int sent;
794
Willy Tarreaubaaee002006-06-26 02:48:02 +0200795 /* we can filter the level of the messages that are sent to each logger */
William Lallemand0f99e342011-10-12 17:50:54 +0200796 if (level > logsrv->level)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200797 continue;
William Lallemandbddd4fd2012-02-27 11:23:10 +0100798
Willy Tarreaubaaee002006-06-26 02:48:02 +0200799 /* For each target, we may have a different facility.
800 * We can also have a different log level for each message.
801 * This induces variations in the message header length.
802 * Since we don't want to recompute it each time, nor copy it every
803 * time, we only change the facility in the pre-computed header,
804 * and we change the pointer to the header accordingly.
805 */
William Lallemand0f99e342011-10-12 17:50:54 +0200806 fac_level = (logsrv->facility << 3) + MAX(level, logsrv->minlvl);
William Lallemand2a4a44f2012-02-06 16:00:33 +0100807 log_ptr = dataptr + 3; /* last digit of the log level */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200808 do {
809 *log_ptr = '0' + fac_level % 10;
810 fac_level /= 10;
811 log_ptr--;
William Lallemand2a4a44f2012-02-06 16:00:33 +0100812 } while (fac_level && log_ptr > dataptr);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200813 *log_ptr = '<';
William Lallemand2a4a44f2012-02-06 16:00:33 +0100814
William Lallemandbfb099c2012-03-19 16:15:12 +0100815 sent = sendto(*plogfd, log_ptr, size + log_ptr - dataptr,
Willy Tarreau1b4b7ce2011-04-05 16:56:50 +0200816 MSG_DONTWAIT | MSG_NOSIGNAL,
817 (struct sockaddr *)&logsrv->addr, get_addr_len(&logsrv->addr));
Robert Tsai81ae1952007-12-05 10:47:29 +0100818 if (sent < 0) {
819 Alert("sendto logger #%d failed: %s (errno=%d)\n",
820 nblogger, strerror(errno), errno);
821 }
William Lallemand0f99e342011-10-12 17:50:54 +0200822 nblogger++;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200823 }
824}
825
William Lallemandbddd4fd2012-02-27 11:23:10 +0100826extern fd_set hdr_encode_map[];
827extern fd_set url_encode_map[];
828
Willy Tarreaubaaee002006-06-26 02:48:02 +0200829
Willy Tarreauc89ccb62012-04-05 21:18:22 +0200830const char sess_cookie[8] = "NIDVEOU7"; /* No cookie, Invalid cookie, cookie for a Down server, Valid cookie, Expired cookie, Old cookie, Unused, unknown */
William Lallemandbddd4fd2012-02-27 11:23:10 +0100831const char sess_set_cookie[8] = "NPDIRU67"; /* No set-cookie, Set-cookie found and left unchanged (passive),
832 Set-cookie Deleted, Set-Cookie Inserted, Set-cookie Rewritten,
833 Set-cookie Updated, unknown, unknown */
834
William Lallemand1d705562012-03-12 12:46:41 +0100835/*
836 * try to write a character if there is enough space, or goto out
837 */
William Lallemandbddd4fd2012-02-27 11:23:10 +0100838#define LOGCHAR(x) do { \
William Lallemand1d705562012-03-12 12:46:41 +0100839 if (tmplog < dst + maxsize - 1) { \
William Lallemandbddd4fd2012-02-27 11:23:10 +0100840 *(tmplog++) = (x); \
841 } else { \
842 goto out; \
843 } \
844 } while(0)
845
William Lallemand1d705562012-03-12 12:46:41 +0100846
Willy Tarreaudf974472012-12-28 02:44:01 +0100847/* Builds a log line in <dst> based on <list_format>, and stops before reaching
848 * <maxsize> characters. Returns the size of the output string in characters,
849 * not counting the trailing zero which is always added if the resulting size
850 * is not zero.
851 */
William Lallemand1d705562012-03-12 12:46:41 +0100852int build_logline(struct session *s, char *dst, size_t maxsize, struct list *list_format)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200853{
Willy Tarreau73de9892006-11-30 11:40:23 +0100854 struct proxy *fe = s->fe;
Willy Tarreauddb358d2006-12-17 22:55:52 +0100855 struct proxy *be = s->be;
William Lallemandbddd4fd2012-02-27 11:23:10 +0100856 struct http_txn *txn = &s->txn;
William Lallemand1d705562012-03-12 12:46:41 +0100857 int tolog;
William Lallemandbddd4fd2012-02-27 11:23:10 +0100858 char *uri;
859 const char *svid;
Willy Tarreaufe944602007-10-25 10:34:16 +0200860 struct tm tm;
William Lallemandbddd4fd2012-02-27 11:23:10 +0100861 int t_request;
862 int hdr;
863 int last_isspace = 1;
Willy Tarreaub1a2faf2012-03-19 16:51:53 +0100864 char *tmplog;
William Lallemand1d705562012-03-12 12:46:41 +0100865 char *ret;
866 int iret;
William Lallemandbddd4fd2012-02-27 11:23:10 +0100867 struct logformat_node *tmp;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200868
William Lallemandbddd4fd2012-02-27 11:23:10 +0100869 /* FIXME: let's limit ourselves to frontend logging for now. */
Willy Tarreau42250582007-04-01 01:30:43 +0200870 tolog = fe->to_log;
Willy Tarreau71904a42011-02-13 14:30:26 +0100871
872 if (!(tolog & LW_SVID))
873 svid = "-";
Willy Tarreau3fdb3662012-11-12 00:42:33 +0100874 else switch (obj_type(s->target)) {
875 case OBJ_TYPE_SERVER:
876 svid = objt_server(s->target)->id;
Willy Tarreau71904a42011-02-13 14:30:26 +0100877 break;
Willy Tarreau3fdb3662012-11-12 00:42:33 +0100878 case OBJ_TYPE_APPLET:
879 svid = objt_applet(s->target)->name;
Willy Tarreau71904a42011-02-13 14:30:26 +0100880 break;
881 default:
882 svid = "<NOSRV>";
883 break;
884 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200885
William Lallemandbddd4fd2012-02-27 11:23:10 +0100886 t_request = -1;
887 if (tv_isge(&s->logs.tv_request, &s->logs.tv_accept))
888 t_request = tv_ms_elapsed(&s->logs.tv_accept, &s->logs.tv_request);
889
William Lallemand1d705562012-03-12 12:46:41 +0100890 tmplog = dst;
Willy Tarreauc9bd0cc2009-05-10 11:57:02 +0200891
William Lallemandbddd4fd2012-02-27 11:23:10 +0100892 /* fill logbuffer */
William Lallemand1d705562012-03-12 12:46:41 +0100893 if (LIST_ISEMPTY(list_format))
894 return 0;
William Lallemandbddd4fd2012-02-27 11:23:10 +0100895
William Lallemand1d705562012-03-12 12:46:41 +0100896 list_for_each_entry(tmp, list_format, list) {
Willy Tarreau4f653562012-10-12 19:48:16 +0200897 const char *src = NULL;
Willy Tarreauc8368452012-12-21 00:09:23 +0100898 struct sample *key;
William Lallemandbddd4fd2012-02-27 11:23:10 +0100899
Willy Tarreauc8368452012-12-21 00:09:23 +0100900 switch (tmp->type) {
William Lallemand1d705562012-03-12 12:46:41 +0100901 case LOG_FMT_SEPARATOR:
William Lallemandbddd4fd2012-02-27 11:23:10 +0100902 if (!last_isspace) {
903 LOGCHAR(' ');
904 last_isspace = 1;
William Lallemandbddd4fd2012-02-27 11:23:10 +0100905 }
906 break;
907
William Lallemand1d705562012-03-12 12:46:41 +0100908 case LOG_FMT_TEXT: // text
William Lallemandbddd4fd2012-02-27 11:23:10 +0100909 src = tmp->arg;
William Lallemand5f232402012-04-05 18:02:55 +0200910 iret = strlcpy2(tmplog, src, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +0100911 if (iret == 0)
William Lallemandbddd4fd2012-02-27 11:23:10 +0100912 goto out;
William Lallemand1d705562012-03-12 12:46:41 +0100913 tmplog += iret;
William Lallemandbddd4fd2012-02-27 11:23:10 +0100914 last_isspace = 0;
915 break;
916
Willy Tarreauc8368452012-12-21 00:09:23 +0100917 case LOG_FMT_EXPR: // sample expression, may be request or response
918 key = NULL;
919 if (tmp->options & LOG_OPT_REQ_CAP)
920 key = sample_fetch_string(be, s, txn, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, tmp->expr);
921 if (!key && (tmp->options & LOG_OPT_RES_CAP))
922 key = sample_fetch_string(be, s, txn, SMP_OPT_DIR_RES|SMP_OPT_FINAL, tmp->expr);
923 if (!key)
924 break;
925 ret = lf_text_len(tmplog, key->data.str.str, key->data.str.len, dst + maxsize - tmplog, tmp);
926 if (ret == 0)
927 goto out;
928 tmplog = ret;
929 last_isspace = 0;
930 break;
931
Willy Tarreau2beef582012-12-20 17:22:52 +0100932 case LOG_FMT_CLIENTIP: // %ci
Willy Tarreauf2943dc2012-10-26 20:10:28 +0200933 ret = lf_ip(tmplog, (struct sockaddr *)&s->req->prod->conn->addr.from,
William Lallemand5f232402012-04-05 18:02:55 +0200934 dst + maxsize - tmplog, tmp);
William Lallemand1d705562012-03-12 12:46:41 +0100935 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +0100936 goto out;
William Lallemand1d705562012-03-12 12:46:41 +0100937 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +0100938 last_isspace = 0;
939 break;
940
Willy Tarreau2beef582012-12-20 17:22:52 +0100941 case LOG_FMT_CLIENTPORT: // %cp
Willy Tarreauf2943dc2012-10-26 20:10:28 +0200942 if (s->req->prod->conn->addr.from.ss_family == AF_UNIX) {
William Lallemand5f232402012-04-05 18:02:55 +0200943 ret = ltoa_o(s->listener->luid, tmplog, dst + maxsize - tmplog);
944 } else {
Willy Tarreauf2943dc2012-10-26 20:10:28 +0200945 ret = lf_port(tmplog, (struct sockaddr *)&s->req->prod->conn->addr.from,
William Lallemand5f232402012-04-05 18:02:55 +0200946 dst + maxsize - tmplog, tmp);
947 }
948 if (ret == NULL)
949 goto out;
950 tmplog = ret;
951 last_isspace = 0;
952 break;
953
Willy Tarreau2beef582012-12-20 17:22:52 +0100954 case LOG_FMT_FRONTENDIP: // %fi
Willy Tarreauf2943dc2012-10-26 20:10:28 +0200955 conn_get_to_addr(s->req->prod->conn);
956 ret = lf_ip(tmplog, (struct sockaddr *)&s->req->prod->conn->addr.to,
William Lallemand5f232402012-04-05 18:02:55 +0200957 dst + maxsize - tmplog, tmp);
William Lallemand1d705562012-03-12 12:46:41 +0100958 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +0100959 goto out;
William Lallemand1d705562012-03-12 12:46:41 +0100960 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +0100961 last_isspace = 0;
962 break;
963
Willy Tarreau2beef582012-12-20 17:22:52 +0100964 case LOG_FMT_FRONTENDPORT: // %fp
Willy Tarreauf2943dc2012-10-26 20:10:28 +0200965 conn_get_to_addr(s->req->prod->conn);
966 if (s->req->prod->conn->addr.to.ss_family == AF_UNIX) {
William Lallemand5f232402012-04-05 18:02:55 +0200967 ret = ltoa_o(s->listener->luid,
968 tmplog, dst + maxsize - tmplog);
969 } else {
Willy Tarreauf2943dc2012-10-26 20:10:28 +0200970 ret = lf_port(tmplog, (struct sockaddr *)&s->req->prod->conn->addr.to,
William Lallemand5f232402012-04-05 18:02:55 +0200971 dst + maxsize - tmplog, tmp);
972 }
973 if (ret == NULL)
974 goto out;
975 tmplog = ret;
976 last_isspace = 0;
977 break;
978
Willy Tarreau2beef582012-12-20 17:22:52 +0100979 case LOG_FMT_BACKENDIP: // %bi
Willy Tarreauf2943dc2012-10-26 20:10:28 +0200980 ret = lf_ip(tmplog, (struct sockaddr *)&s->req->cons->conn->addr.from,
William Lallemand5f232402012-04-05 18:02:55 +0200981 dst + maxsize - tmplog, tmp);
William Lallemand1d705562012-03-12 12:46:41 +0100982 if (ret == NULL)
William Lallemandb7ff6a32012-03-02 14:35:21 +0100983 goto out;
William Lallemand1d705562012-03-12 12:46:41 +0100984 tmplog = ret;
William Lallemandb7ff6a32012-03-02 14:35:21 +0100985 last_isspace = 0;
986 break;
987
Willy Tarreau2beef582012-12-20 17:22:52 +0100988 case LOG_FMT_BACKENDPORT: // %bp
Willy Tarreauf2943dc2012-10-26 20:10:28 +0200989 ret = lf_port(tmplog, (struct sockaddr *)&s->req->cons->conn->addr.from,
William Lallemand5f232402012-04-05 18:02:55 +0200990 dst + maxsize - tmplog, tmp);
991 if (ret == NULL)
992 goto out;
993 tmplog = ret;
994 last_isspace = 0;
995 break;
996
Willy Tarreau2beef582012-12-20 17:22:52 +0100997 case LOG_FMT_SERVERIP: // %si
Willy Tarreauf2943dc2012-10-26 20:10:28 +0200998 ret = lf_ip(tmplog, (struct sockaddr *)&s->req->cons->conn->addr.to,
William Lallemand5f232402012-04-05 18:02:55 +0200999 dst + maxsize - tmplog, tmp);
1000 if (ret == NULL)
1001 goto out;
1002 tmplog = ret;
1003 last_isspace = 0;
1004 break;
1005
Willy Tarreau2beef582012-12-20 17:22:52 +01001006 case LOG_FMT_SERVERPORT: // %sp
Willy Tarreauf2943dc2012-10-26 20:10:28 +02001007 ret = lf_port(tmplog, (struct sockaddr *)&s->req->cons->conn->addr.to,
William Lallemand5f232402012-04-05 18:02:55 +02001008 dst + maxsize - tmplog, tmp);
William Lallemand1d705562012-03-12 12:46:41 +01001009 if (ret == NULL)
William Lallemandb7ff6a32012-03-02 14:35:21 +01001010 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001011 tmplog = ret;
William Lallemandb7ff6a32012-03-02 14:35:21 +01001012 last_isspace = 0;
1013 break;
1014
William Lallemand1d705562012-03-12 12:46:41 +01001015 case LOG_FMT_DATE: // %t
William Lallemandbddd4fd2012-02-27 11:23:10 +01001016 get_localtime(s->logs.accept_date.tv_sec, &tm);
William Lallemand5f232402012-04-05 18:02:55 +02001017 ret = date2str_log(tmplog, &tm, &(s->logs.accept_date),
1018 dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001019 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001020 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001021 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001022 last_isspace = 0;
1023 break;
1024
William Lallemand1d705562012-03-12 12:46:41 +01001025 case LOG_FMT_DATEGMT: // %T
William Lallemandbddd4fd2012-02-27 11:23:10 +01001026 get_gmtime(s->logs.accept_date.tv_sec, &tm);
William Lallemand5f232402012-04-05 18:02:55 +02001027 ret = gmt2str_log(tmplog, &tm, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001028 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001029 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001030 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001031 last_isspace = 0;
1032 break;
1033
Yuxans Yao4e25b012012-10-19 10:36:09 +08001034 case LOG_FMT_DATELOCAL: // %Tl
1035 get_localtime(s->logs.accept_date.tv_sec, &tm);
1036 ret = localdate2str_log(tmplog, &tm, dst + maxsize - tmplog);
1037 if (ret == NULL)
1038 goto out;
1039 tmplog = ret;
1040 last_isspace = 0;
1041 break;
1042
William Lallemand5f232402012-04-05 18:02:55 +02001043 case LOG_FMT_TS: // %Ts
1044 get_gmtime(s->logs.accept_date.tv_sec, &tm);
1045 if (tmp->options & LOG_OPT_HEXA) {
1046 iret = snprintf(tmplog, dst + maxsize - tmplog, "%04X", (unsigned int)s->logs.accept_date.tv_sec);
1047 if (iret < 0 || iret > dst + maxsize - tmplog)
1048 goto out;
1049 last_isspace = 0;
1050 tmplog += iret;
1051 } else {
1052 ret = ltoa_o(s->logs.accept_date.tv_sec, tmplog, dst + maxsize - tmplog);
1053 if (ret == NULL)
1054 goto out;
1055 tmplog = ret;
1056 last_isspace = 0;
1057 }
1058 break;
1059
William Lallemand1d705562012-03-12 12:46:41 +01001060 case LOG_FMT_MS: // %ms
William Lallemand5f232402012-04-05 18:02:55 +02001061 if (tmp->options & LOG_OPT_HEXA) {
1062 iret = snprintf(tmplog, dst + maxsize - tmplog, "%02X",(unsigned int)s->logs.accept_date.tv_usec/1000);
1063 if (iret < 0 || iret > dst + maxsize - tmplog)
1064 goto out;
1065 last_isspace = 0;
1066 tmplog += iret;
1067 } else {
1068 if ((dst + maxsize - tmplog) < 4)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001069 goto out;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001070 tmplog = utoa_pad((unsigned int)s->logs.accept_date.tv_usec/1000,
1071 tmplog, 4);
William Lallemand51b5dca2012-03-26 17:52:55 +02001072 if (!tmplog)
1073 goto out;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001074 last_isspace = 0;
William Lallemand5f232402012-04-05 18:02:55 +02001075 }
1076 break;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001077
William Lallemand1d705562012-03-12 12:46:41 +01001078 case LOG_FMT_FRONTEND: // %f
William Lallemandbddd4fd2012-02-27 11:23:10 +01001079 src = fe->id;
William Lallemand5f232402012-04-05 18:02:55 +02001080 ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);
William Lallemand1d705562012-03-12 12:46:41 +01001081 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001082 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001083 tmplog = ret;
William Lallemand51b5dca2012-03-26 17:52:55 +02001084 last_isspace = 0;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001085 break;
1086
Willy Tarreau773d65f2012-10-12 14:56:11 +02001087 case LOG_FMT_FRONTEND_XPRT: // %ft
1088 src = fe->id;
1089 if (tmp->options & LOG_OPT_QUOTE)
1090 LOGCHAR('"');
1091 iret = strlcpy2(tmplog, src, dst + maxsize - tmplog);
1092 if (iret == 0)
1093 goto out;
1094 tmplog += iret;
1095#ifdef USE_OPENSSL
1096 if (s->listener->xprt == &ssl_sock)
1097 LOGCHAR('~');
1098#endif
1099 if (tmp->options & LOG_OPT_QUOTE)
1100 LOGCHAR('"');
1101 last_isspace = 0;
1102 break;
Willy Tarreauffc3fcd2012-10-12 20:17:54 +02001103#ifdef USE_OPENSSL
1104 case LOG_FMT_SSL_CIPHER: // %sslc
1105 src = NULL;
1106 if (s->listener->xprt == &ssl_sock)
Willy Tarreauf2943dc2012-10-26 20:10:28 +02001107 src = ssl_sock_get_cipher_name(s->si[0].conn);
Willy Tarreauffc3fcd2012-10-12 20:17:54 +02001108 ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);
1109 if (ret == NULL)
1110 goto out;
1111 tmplog = ret;
1112 last_isspace = 0;
1113 break;
Willy Tarreau773d65f2012-10-12 14:56:11 +02001114
Willy Tarreauffc3fcd2012-10-12 20:17:54 +02001115 case LOG_FMT_SSL_VERSION: // %sslv
1116 src = NULL;
1117 if (s->listener->xprt == &ssl_sock)
Willy Tarreauf2943dc2012-10-26 20:10:28 +02001118 src = ssl_sock_get_proto_version(s->si[0].conn);
Willy Tarreauffc3fcd2012-10-12 20:17:54 +02001119 ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);
1120 if (ret == NULL)
1121 goto out;
1122 tmplog = ret;
1123 last_isspace = 0;
1124 break;
1125#endif
William Lallemand1d705562012-03-12 12:46:41 +01001126 case LOG_FMT_BACKEND: // %b
William Lallemandbddd4fd2012-02-27 11:23:10 +01001127 src = be->id;
William Lallemand5f232402012-04-05 18:02:55 +02001128 ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);
William Lallemand1d705562012-03-12 12:46:41 +01001129 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001130 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001131 tmplog = ret;
William Lallemand51b5dca2012-03-26 17:52:55 +02001132 last_isspace = 0;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001133 break;
1134
William Lallemand1d705562012-03-12 12:46:41 +01001135 case LOG_FMT_SERVER: // %s
William Lallemandbddd4fd2012-02-27 11:23:10 +01001136 src = (char *)svid;
William Lallemand5f232402012-04-05 18:02:55 +02001137 ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);
William Lallemand1d705562012-03-12 12:46:41 +01001138 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001139 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001140 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001141 last_isspace = 0;
1142 break;
1143
William Lallemand1d705562012-03-12 12:46:41 +01001144 case LOG_FMT_TQ: // %Tq
William Lallemand5f232402012-04-05 18:02:55 +02001145 ret = ltoa_o(t_request, tmplog, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001146 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001147 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001148 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001149 last_isspace = 0;
1150 break;
1151
William Lallemand1d705562012-03-12 12:46:41 +01001152 case LOG_FMT_TW: // %Tw
1153 ret = ltoa_o((s->logs.t_queue >= 0) ? s->logs.t_queue - t_request : -1,
William Lallemand5f232402012-04-05 18:02:55 +02001154 tmplog, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001155 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001156 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001157 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001158 last_isspace = 0;
1159 break;
1160
William Lallemand1d705562012-03-12 12:46:41 +01001161 case LOG_FMT_TC: // %Tc
1162 ret = ltoa_o((s->logs.t_connect >= 0) ? s->logs.t_connect - s->logs.t_queue : -1,
William Lallemand5f232402012-04-05 18:02:55 +02001163 tmplog, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001164 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001165 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001166 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001167 last_isspace = 0;
1168 break;
1169
William Lallemand1d705562012-03-12 12:46:41 +01001170 case LOG_FMT_TR: // %Tr
1171 ret = ltoa_o((s->logs.t_data >= 0) ? s->logs.t_data - s->logs.t_connect : -1,
William Lallemand5f232402012-04-05 18:02:55 +02001172 tmplog, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001173 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001174 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001175 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001176 last_isspace = 0;
1177 break;
1178
William Lallemand1d705562012-03-12 12:46:41 +01001179 case LOG_FMT_TT: // %Tt
William Lallemandbddd4fd2012-02-27 11:23:10 +01001180 if (!(tolog & LW_BYTES))
William Lallemand1d705562012-03-12 12:46:41 +01001181 LOGCHAR('+');
William Lallemand5f232402012-04-05 18:02:55 +02001182 ret = ltoa_o(s->logs.t_close, tmplog, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001183 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001184 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001185 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001186 last_isspace = 0;
1187 break;
1188
Willy Tarreau2beef582012-12-20 17:22:52 +01001189 case LOG_FMT_STATUS: // %ST
William Lallemand5f232402012-04-05 18:02:55 +02001190 ret = ltoa_o(txn->status, tmplog, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001191 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001192 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001193 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001194 last_isspace = 0;
1195 break;
1196
William Lallemand1d705562012-03-12 12:46:41 +01001197 case LOG_FMT_BYTES: // %B
William Lallemandbddd4fd2012-02-27 11:23:10 +01001198 if (!(tolog & LW_BYTES))
William Lallemand1d705562012-03-12 12:46:41 +01001199 LOGCHAR('+');
William Lallemand5f232402012-04-05 18:02:55 +02001200 ret = lltoa(s->logs.bytes_out, tmplog, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001201 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001202 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001203 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001204 last_isspace = 0;
1205 break;
1206
Willy Tarreauc5259fd2012-12-20 15:38:04 +01001207 case LOG_FMT_BYTES_UP: // %U
1208 if (!(tolog & LW_BYTES))
1209 LOGCHAR('+');
1210 ret = lltoa(s->logs.bytes_in, tmplog, dst + maxsize - tmplog);
1211 if (ret == NULL)
1212 goto out;
1213 tmplog = ret;
1214 last_isspace = 0;
1215 break;
1216
Willy Tarreau2beef582012-12-20 17:22:52 +01001217 case LOG_FMT_CCLIENT: // %CC
William Lallemandbddd4fd2012-02-27 11:23:10 +01001218 src = txn->cli_cookie;
William Lallemand5f232402012-04-05 18:02:55 +02001219 ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);
William Lallemand1d705562012-03-12 12:46:41 +01001220 if (ret == NULL)
William Lallemand51b5dca2012-03-26 17:52:55 +02001221 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001222 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001223 last_isspace = 0;
1224 break;
1225
Willy Tarreau2beef582012-12-20 17:22:52 +01001226 case LOG_FMT_CSERVER: // %CS
William Lallemandbddd4fd2012-02-27 11:23:10 +01001227 src = txn->srv_cookie;
William Lallemand5f232402012-04-05 18:02:55 +02001228 ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);
William Lallemand1d705562012-03-12 12:46:41 +01001229 if (ret == NULL)
William Lallemand51b5dca2012-03-26 17:52:55 +02001230 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001231 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001232 last_isspace = 0;
1233 break;
1234
William Lallemand1d705562012-03-12 12:46:41 +01001235 case LOG_FMT_TERMSTATE: // %ts
Willy Tarreau6580c062012-03-12 15:09:42 +01001236 LOGCHAR(sess_term_cond[(s->flags & SN_ERR_MASK) >> SN_ERR_SHIFT]);
1237 LOGCHAR(sess_fin_state[(s->flags & SN_FINST_MASK) >> SN_FINST_SHIFT]);
1238 *tmplog = '\0';
1239 last_isspace = 0;
1240 break;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001241
William Lallemand1d705562012-03-12 12:46:41 +01001242 case LOG_FMT_TERMSTATE_CK: // %tsc, same as TS with cookie state (for mode HTTP)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001243 LOGCHAR(sess_term_cond[(s->flags & SN_ERR_MASK) >> SN_ERR_SHIFT]);
1244 LOGCHAR(sess_fin_state[(s->flags & SN_FINST_MASK) >> SN_FINST_SHIFT]);
Willy Tarreau67402132012-05-31 20:40:20 +02001245 LOGCHAR((be->ck_opts & PR_CK_ANY) ? sess_cookie[(txn->flags & TX_CK_MASK) >> TX_CK_SHIFT] : '-');
1246 LOGCHAR((be->ck_opts & PR_CK_ANY) ? sess_set_cookie[(txn->flags & TX_SCK_MASK) >> TX_SCK_SHIFT] : '-');
William Lallemandbddd4fd2012-02-27 11:23:10 +01001247 last_isspace = 0;
1248 break;
1249
William Lallemand1d705562012-03-12 12:46:41 +01001250 case LOG_FMT_ACTCONN: // %ac
William Lallemand5f232402012-04-05 18:02:55 +02001251 ret = ltoa_o(actconn, tmplog, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001252 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001253 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001254 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001255 last_isspace = 0;
1256 break;
1257
William Lallemand1d705562012-03-12 12:46:41 +01001258 case LOG_FMT_FECONN: // %fc
William Lallemand5f232402012-04-05 18:02:55 +02001259 ret = ltoa_o(fe->feconn, tmplog, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001260 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001261 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001262 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001263 last_isspace = 0;
1264 break;
1265
William Lallemand1d705562012-03-12 12:46:41 +01001266 case LOG_FMT_BECONN: // %bc
William Lallemand5f232402012-04-05 18:02:55 +02001267 ret = ltoa_o(be->beconn, tmplog, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001268 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001269 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001270 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001271 last_isspace = 0;
1272 break;
1273
William Lallemand1d705562012-03-12 12:46:41 +01001274 case LOG_FMT_SRVCONN: // %sc
Willy Tarreau54a08d32012-11-12 01:14:56 +01001275 ret = ultoa_o(objt_server(s->target) ?
Willy Tarreau3fdb3662012-11-12 00:42:33 +01001276 objt_server(s->target)->cur_sess :
William Lallemand5f232402012-04-05 18:02:55 +02001277 0, tmplog, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001278 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001279 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001280 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001281 last_isspace = 0;
1282 break;
1283
William Lallemand1d705562012-03-12 12:46:41 +01001284 case LOG_FMT_RETRIES: // %rq
William Lallemandbddd4fd2012-02-27 11:23:10 +01001285 if (s->flags & SN_REDISP)
William Lallemand1d705562012-03-12 12:46:41 +01001286 LOGCHAR('+');
1287 ret = ltoa_o((s->req->cons->conn_retries>0) ?
1288 (be->conn_retries - s->req->cons->conn_retries) :
William Lallemand5f232402012-04-05 18:02:55 +02001289 be->conn_retries, tmplog, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001290 if (ret == NULL)
William Lallemand51b5dca2012-03-26 17:52:55 +02001291 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001292 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001293 last_isspace = 0;
1294 break;
1295
William Lallemand1d705562012-03-12 12:46:41 +01001296 case LOG_FMT_SRVQUEUE: // %sq
William Lallemand5f232402012-04-05 18:02:55 +02001297 ret = ltoa_o(s->logs.srv_queue_size, tmplog, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001298 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001299 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001300 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001301 last_isspace = 0;
1302 break;
1303
William Lallemand1d705562012-03-12 12:46:41 +01001304 case LOG_FMT_BCKQUEUE: // %bq
William Lallemand5f232402012-04-05 18:02:55 +02001305 ret = ltoa_o(s->logs.prx_queue_size, tmplog, dst + maxsize - tmplog);
William Lallemand1d705562012-03-12 12:46:41 +01001306 if (ret == NULL)
William Lallemandbddd4fd2012-02-27 11:23:10 +01001307 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001308 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001309 last_isspace = 0;
1310 break;
1311
William Lallemand1d705562012-03-12 12:46:41 +01001312 case LOG_FMT_HDRREQUEST: // %hr
William Lallemandbddd4fd2012-02-27 11:23:10 +01001313 /* request header */
1314 if (fe->to_log & LW_REQHDR && txn->req.cap) {
1315 if (tmp->options & LOG_OPT_QUOTE)
1316 LOGCHAR('"');
1317 LOGCHAR('{');
1318 for (hdr = 0; hdr < fe->nb_req_cap; hdr++) {
1319 if (hdr)
1320 LOGCHAR('|');
William Lallemand51b5dca2012-03-26 17:52:55 +02001321 if (txn->req.cap[hdr] != NULL) {
William Lallemand1d705562012-03-12 12:46:41 +01001322 ret = encode_string(tmplog, dst + maxsize,
William Lallemandbddd4fd2012-02-27 11:23:10 +01001323 '#', hdr_encode_map, txn->req.cap[hdr]);
William Lallemand1d705562012-03-12 12:46:41 +01001324 if (ret == NULL || *ret != '\0')
William Lallemand51b5dca2012-03-26 17:52:55 +02001325 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001326 tmplog = ret;
William Lallemand51b5dca2012-03-26 17:52:55 +02001327 }
William Lallemandbddd4fd2012-02-27 11:23:10 +01001328 }
1329 LOGCHAR('}');
William Lallemand51b5dca2012-03-26 17:52:55 +02001330 if (tmp->options & LOG_OPT_QUOTE)
1331 LOGCHAR('"');
William Lallemandbddd4fd2012-02-27 11:23:10 +01001332 last_isspace = 0;
William Lallemand1d705562012-03-12 12:46:41 +01001333 if (tmp->options & LOG_OPT_QUOTE)
1334 LOGCHAR('"');
William Lallemandbddd4fd2012-02-27 11:23:10 +01001335 }
William Lallemandbddd4fd2012-02-27 11:23:10 +01001336 break;
1337
William Lallemand1d705562012-03-12 12:46:41 +01001338 case LOG_FMT_HDRREQUESTLIST: // %hrl
William Lallemandbddd4fd2012-02-27 11:23:10 +01001339 /* request header list */
1340 if (fe->to_log & LW_REQHDR && txn->req.cap) {
1341 for (hdr = 0; hdr < fe->nb_req_cap; hdr++) {
1342 if (hdr > 0)
1343 LOGCHAR(' ');
1344 if (tmp->options & LOG_OPT_QUOTE)
1345 LOGCHAR('"');
1346 if (txn->req.cap[hdr] != NULL) {
William Lallemand1d705562012-03-12 12:46:41 +01001347 ret = encode_string(tmplog, dst + maxsize,
William Lallemandbddd4fd2012-02-27 11:23:10 +01001348 '#', hdr_encode_map, txn->req.cap[hdr]);
William Lallemand1d705562012-03-12 12:46:41 +01001349 if (ret == NULL || *ret != '\0')
William Lallemand51b5dca2012-03-26 17:52:55 +02001350 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001351 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001352 } else if (!(tmp->options & LOG_OPT_QUOTE))
1353 LOGCHAR('-');
1354 if (tmp->options & LOG_OPT_QUOTE)
1355 LOGCHAR('"');
William Lallemandbddd4fd2012-02-27 11:23:10 +01001356 last_isspace = 0;
1357 }
1358 }
1359 break;
Willy Tarreaubaaee002006-06-26 02:48:02 +02001360
William Lallemand1d705562012-03-12 12:46:41 +01001361
1362 case LOG_FMT_HDRRESPONS: // %hs
William Lallemandbddd4fd2012-02-27 11:23:10 +01001363 /* response header */
1364 if (fe->to_log & LW_RSPHDR &&
1365 txn->rsp.cap) {
1366 if (tmp->options & LOG_OPT_QUOTE)
1367 LOGCHAR('"');
1368 LOGCHAR('{');
1369 for (hdr = 0; hdr < fe->nb_rsp_cap; hdr++) {
1370 if (hdr)
1371 LOGCHAR('|');
William Lallemand51b5dca2012-03-26 17:52:55 +02001372 if (txn->rsp.cap[hdr] != NULL) {
William Lallemand1d705562012-03-12 12:46:41 +01001373 ret = encode_string(tmplog, dst + maxsize,
1374 '#', hdr_encode_map, txn->rsp.cap[hdr]);
1375 if (ret == NULL || *ret != '\0')
William Lallemand51b5dca2012-03-26 17:52:55 +02001376 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001377 tmplog = ret;
William Lallemand51b5dca2012-03-26 17:52:55 +02001378 }
William Lallemandbddd4fd2012-02-27 11:23:10 +01001379 }
1380 LOGCHAR('}');
1381 last_isspace = 0;
1382 if (tmp->options & LOG_OPT_QUOTE)
1383 LOGCHAR('"');
1384 }
William Lallemandbddd4fd2012-02-27 11:23:10 +01001385 break;
1386
William Lallemand1d705562012-03-12 12:46:41 +01001387 case LOG_FMT_HDRRESPONSLIST: // %hsl
William Lallemandbddd4fd2012-02-27 11:23:10 +01001388 /* response header list */
1389 if (fe->to_log & LW_RSPHDR && txn->rsp.cap) {
1390 for (hdr = 0; hdr < fe->nb_rsp_cap; hdr++) {
1391 if (hdr > 0)
1392 LOGCHAR(' ');
1393 if (tmp->options & LOG_OPT_QUOTE)
1394 LOGCHAR('"');
1395 if (txn->rsp.cap[hdr] != NULL) {
William Lallemand1d705562012-03-12 12:46:41 +01001396 ret = encode_string(tmplog, dst + maxsize,
1397 '#', hdr_encode_map, txn->rsp.cap[hdr]);
1398 if (ret == NULL || *ret != '\0')
William Lallemand51b5dca2012-03-26 17:52:55 +02001399 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001400 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001401 } else if (!(tmp->options & LOG_OPT_QUOTE))
1402 LOGCHAR('-');
1403 if (tmp->options & LOG_OPT_QUOTE)
1404 LOGCHAR('"');
William Lallemandbddd4fd2012-02-27 11:23:10 +01001405 last_isspace = 0;
1406 }
1407 }
1408 break;
1409
William Lallemand1d705562012-03-12 12:46:41 +01001410 case LOG_FMT_REQ: // %r
William Lallemandbddd4fd2012-02-27 11:23:10 +01001411 /* Request */
1412 if (tmp->options & LOG_OPT_QUOTE)
1413 LOGCHAR('"');
1414 uri = txn->uri ? txn->uri : "<BADREQ>";
William Lallemand1d705562012-03-12 12:46:41 +01001415 ret = encode_string(tmplog, dst + maxsize,
William Lallemandbddd4fd2012-02-27 11:23:10 +01001416 '#', url_encode_map, uri);
William Lallemand1d705562012-03-12 12:46:41 +01001417 if (ret == NULL || *ret != '\0')
William Lallemand51b5dca2012-03-26 17:52:55 +02001418 goto out;
William Lallemand1d705562012-03-12 12:46:41 +01001419 tmplog = ret;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001420 if (tmp->options & LOG_OPT_QUOTE)
1421 LOGCHAR('"');
William Lallemandbddd4fd2012-02-27 11:23:10 +01001422 last_isspace = 0;
1423 break;
William Lallemand5f232402012-04-05 18:02:55 +02001424
1425 case LOG_FMT_COUNTER: // %rt
1426 if (tmp->options & LOG_OPT_HEXA) {
1427 iret = snprintf(tmplog, dst + maxsize - tmplog, "%04X", global.req_count);
1428 if (iret < 0 || iret > dst + maxsize - tmplog)
1429 goto out;
1430 last_isspace = 0;
1431 tmplog += iret;
1432 } else {
1433 ret = ltoa_o(global.req_count, tmplog, dst + maxsize - tmplog);
1434 if (ret == NULL)
1435 goto out;
1436 tmplog = ret;
1437 last_isspace = 0;
1438 }
1439 break;
1440
1441 case LOG_FMT_HOSTNAME: // %H
1442 src = hostname;
1443 ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);
1444 if (ret == NULL)
1445 goto out;
1446 tmplog = ret;
1447 last_isspace = 0;
1448 break;
1449
1450 case LOG_FMT_PID: // %pid
1451 if (tmp->options & LOG_OPT_HEXA) {
1452 iret = snprintf(tmplog, dst + maxsize - tmplog, "%04X", pid);
1453 if (iret < 0 || iret > dst + maxsize - tmplog)
1454 goto out;
1455 last_isspace = 0;
1456 tmplog += iret;
1457 } else {
1458 ret = ltoa_o(pid, tmplog, dst + maxsize - tmplog);
1459 if (ret == NULL)
1460 goto out;
1461 tmplog = ret;
1462 last_isspace = 0;
1463 }
1464 break;
William Lallemanda73203e2012-03-12 12:48:57 +01001465
1466 case LOG_FMT_UNIQUEID: // %ID
1467 src = s->unique_id;
1468 ret = lf_text(tmplog, src, maxsize - (tmplog - dst), tmp);
1469 if (ret == NULL)
1470 goto out;
1471 tmplog = ret;
1472 last_isspace = 0;
1473 break;
1474
William Lallemandbddd4fd2012-02-27 11:23:10 +01001475 }
1476 }
1477
1478out:
William Lallemand1d705562012-03-12 12:46:41 +01001479 /* *tmplog is a unused character */
1480 *tmplog = '\0';
Willy Tarreaudf974472012-12-28 02:44:01 +01001481 return tmplog - dst;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001482
Willy Tarreaubaaee002006-06-26 02:48:02 +02001483}
1484
William Lallemand1d705562012-03-12 12:46:41 +01001485/*
1486 * send a log for the session when we have enough info about it.
1487 * Will not log if the frontend has no log defined.
1488 */
1489void sess_log(struct session *s)
1490{
1491 char *tmplog;
1492 int size, err, level;
1493
1494 /* if we don't want to log normal traffic, return now */
1495 err = (s->flags & (SN_ERR_MASK | SN_REDISP)) ||
1496 (s->req->cons->conn_retries != s->be->conn_retries) ||
1497 ((s->fe->mode == PR_MODE_HTTP) && s->txn.status >= 500);
Willy Tarreaubaaee002006-06-26 02:48:02 +02001498
William Lallemand1d705562012-03-12 12:46:41 +01001499 if (!err && (s->fe->options2 & PR_O2_NOLOGNORM))
1500 return;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001501
William Lallemand1d705562012-03-12 12:46:41 +01001502 if (LIST_ISEMPTY(&s->fe->logsrvs))
1503 return;
William Lallemandbddd4fd2012-02-27 11:23:10 +01001504
William Lallemand1d705562012-03-12 12:46:41 +01001505 level = LOG_INFO;
1506 if (err && (s->fe->options2 & PR_O2_LOGERRORS))
1507 level = LOG_ERR;
1508
1509 tmplog = update_log_hdr();
1510 size = tmplog - logline;
1511 size += build_logline(s, tmplog, sizeof(logline) - size, &s->fe->logformat);
1512 if (size > 0) {
Willy Tarreaudf974472012-12-28 02:44:01 +01001513 __send_log(s->fe, level, logline, size + 1);
William Lallemand1d705562012-03-12 12:46:41 +01001514 s->logs.logwait = 0;
1515 }
1516}
William Lallemandbddd4fd2012-02-27 11:23:10 +01001517
Willy Tarreaubaaee002006-06-26 02:48:02 +02001518/*
1519 * Local variables:
1520 * c-indent-level: 8
1521 * c-basic-offset: 8
1522 * End:
1523 */