blob: ac985fc478e17b9b023ea4e946f52f906624a0d8 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 include/types/log.h
3 This file contains definitions of log-related structures and macros.
4
5 Copyright (C) 2000-2006 Willy Tarreau - w@1wt.eu
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation, version 2.1
10 exclusively.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
22#ifndef _TYPES_LOG_H
23#define _TYPES_LOG_H
24
Willy Tarreau019767b2007-12-05 11:11:55 +010025#include <sys/socket.h>
Robert Tsai81ae1952007-12-05 10:47:29 +010026#include <sys/un.h>
27#include <netinet/in.h>
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020028#include <common/config.h>
Willy Tarreauc7e42382012-08-24 19:22:53 +020029#include <common/mini-clist.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020030
31#define MAX_SYSLOG_LEN 1024
32#define NB_LOG_FACILITIES 24
33#define NB_LOG_LEVELS 8
34#define SYSLOG_PORT 514
William Lallemanda73203e2012-03-12 12:48:57 +010035#define UNIQUEID_LEN 128
36
Willy Tarreaubaaee002006-06-26 02:48:02 +020037
William Lallemand723b73a2012-02-08 16:37:49 +010038/* lists of fields that can be logged */
39enum {
40
William Lallemand1d705562012-03-12 12:46:41 +010041 LOG_FMT_TEXT = 0, /* raw text */
William Lallemand723b73a2012-02-08 16:37:49 +010042
William Lallemand1d705562012-03-12 12:46:41 +010043 LOG_FMT_SEPARATOR, /* separator replaced by one space */
44 LOG_FMT_VARIABLE,
William Lallemand723b73a2012-02-08 16:37:49 +010045
46 /* information fields */
William Lallemand1d705562012-03-12 12:46:41 +010047 LOG_FMT_GLOBAL,
48 LOG_FMT_CLIENTIP,
49 LOG_FMT_CLIENTPORT,
50 LOG_FMT_BACKENDIP,
51 LOG_FMT_BACKENDPORT,
William Lallemand5f232402012-04-05 18:02:55 +020052 LOG_FMT_FRONTENDIP,
53 LOG_FMT_FRONTENDPORT,
54 LOG_FMT_SERVERPORT,
55 LOG_FMT_SERVERIP,
56 LOG_FMT_COUNTER,
57 LOG_FMT_PID,
William Lallemand1d705562012-03-12 12:46:41 +010058 LOG_FMT_DATE,
59 LOG_FMT_DATEGMT,
William Lallemand5f232402012-04-05 18:02:55 +020060 LOG_FMT_TS,
William Lallemand1d705562012-03-12 12:46:41 +010061 LOG_FMT_MS,
62 LOG_FMT_FRONTEND,
63 LOG_FMT_BACKEND,
64 LOG_FMT_SERVER,
65 LOG_FMT_BYTES,
66 LOG_FMT_T,
67 LOG_FMT_TQ,
68 LOG_FMT_TW,
69 LOG_FMT_TC,
70 LOG_FMT_TR,
71 LOG_FMT_TT,
72 LOG_FMT_STATUS,
73 LOG_FMT_CCLIENT,
74 LOG_FMT_CSERVER,
75 LOG_FMT_TERMSTATE,
76 LOG_FMT_TERMSTATE_CK,
77 LOG_FMT_CONN,
78 LOG_FMT_ACTCONN,
79 LOG_FMT_FECONN,
80 LOG_FMT_BECONN,
81 LOG_FMT_SRVCONN,
82 LOG_FMT_RETRIES,
83 LOG_FMT_QUEUES,
84 LOG_FMT_SRVQUEUE,
85 LOG_FMT_BCKQUEUE,
86 LOG_FMT_HDRREQUEST,
87 LOG_FMT_HDRRESPONS,
88 LOG_FMT_HDRREQUESTLIST,
89 LOG_FMT_HDRRESPONSLIST,
90 LOG_FMT_REQ,
William Lallemand5f232402012-04-05 18:02:55 +020091 LOG_FMT_HOSTNAME,
William Lallemanda73203e2012-03-12 12:48:57 +010092 LOG_FMT_UNIQUEID,
William Lallemand723b73a2012-02-08 16:37:49 +010093};
94
95/* enum for parse_logformat */
96enum {
97 LF_TEXT = 0,
98 LF_SEPARATOR,
99 LF_VAR, // after %
100
101 LF_STARTVAR, // %
102 LF_STARG, // { and within { }
103 LF_EDARG, // end arg }
104};
105
106
107struct logformat_node {
108 struct list list;
109 int type;
110 int options;
111 char *arg;
112};
113
William Lallemand5f232402012-04-05 18:02:55 +0200114#define LOG_OPT_HEXA 0x00000001
William Lallemand723b73a2012-02-08 16:37:49 +0100115#define LOG_OPT_MANDATORY 0x00000002
116#define LOG_OPT_QUOTE 0x00000004
117
118
Willy Tarreaubaaee002006-06-26 02:48:02 +0200119
120/* fields that need to be logged. They appear as flags in session->logs.logwait */
William Lallemand5e19a282012-04-02 16:22:10 +0200121#define LW_INIT 1 /* date */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200122#define LW_CLIP 2 /* CLient IP */
123#define LW_SVIP 4 /* SerVer IP */
124#define LW_SVID 8 /* server ID */
125#define LW_REQ 16 /* http REQuest */
126#define LW_RESP 32 /* http RESPonse */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200127#define LW_BYTES 256 /* bytes read from server */
128#define LW_COOKIE 512 /* captured cookie */
129#define LW_REQHDR 1024 /* request header(s) */
130#define LW_RSPHDR 2048 /* response header(s) */
William Lallemand5e19a282012-04-02 16:22:10 +0200131#define LW_BCKIP 4096 /* backend IP */
132#define LW_FRTIP 8192 /* frontend IP */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200133
Robert Tsai81ae1952007-12-05 10:47:29 +0100134struct logsrv {
William Lallemand0f99e342011-10-12 17:50:54 +0200135 struct list list;
David du Colombier11bcb6c2011-03-24 12:23:00 +0100136 struct sockaddr_storage addr;
William Lallemand0f99e342011-10-12 17:50:54 +0200137 int facility;
138 int level;
139 int minlvl;
Robert Tsai81ae1952007-12-05 10:47:29 +0100140};
141
Willy Tarreaubaaee002006-06-26 02:48:02 +0200142#endif /* _TYPES_LOG_H */
143
144/*
145 * Local variables:
146 * c-indent-level: 8
147 * c-basic-offset: 8
148 * End:
149 */