blob: 0214ae675aaf31f8957ca92e19e183de6cb08092 [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
Willy Tarreaubaaee002006-06-26 02:48:02 +020031#define NB_LOG_FACILITIES 24
32#define NB_LOG_LEVELS 8
Dragan Dosen68d2e3a2015-09-19 22:35:44 +020033#define NB_MSG_IOVEC_ELEMENTS 3
Willy Tarreaubaaee002006-06-26 02:48:02 +020034#define SYSLOG_PORT 514
William Lallemanda73203e2012-03-12 12:48:57 +010035#define UNIQUEID_LEN 128
36
Thierry FOURNIER2ba18a22015-01-23 14:07:08 +010037/* The array containing the names of the log levels. */
38extern const char *log_levels[];
Willy Tarreaubaaee002006-06-26 02:48:02 +020039
William Lallemand723b73a2012-02-08 16:37:49 +010040/* lists of fields that can be logged */
41enum {
42
William Lallemand1d705562012-03-12 12:46:41 +010043 LOG_FMT_TEXT = 0, /* raw text */
Willy Tarreauc8368452012-12-21 00:09:23 +010044 LOG_FMT_EXPR, /* sample expression */
William Lallemand1d705562012-03-12 12:46:41 +010045 LOG_FMT_SEPARATOR, /* separator replaced by one space */
46 LOG_FMT_VARIABLE,
William Lallemand723b73a2012-02-08 16:37:49 +010047
48 /* information fields */
William Lallemand1d705562012-03-12 12:46:41 +010049 LOG_FMT_GLOBAL,
50 LOG_FMT_CLIENTIP,
51 LOG_FMT_CLIENTPORT,
52 LOG_FMT_BACKENDIP,
53 LOG_FMT_BACKENDPORT,
William Lallemand5f232402012-04-05 18:02:55 +020054 LOG_FMT_FRONTENDIP,
55 LOG_FMT_FRONTENDPORT,
56 LOG_FMT_SERVERPORT,
57 LOG_FMT_SERVERIP,
58 LOG_FMT_COUNTER,
Willy Tarreau7346acb2014-08-28 15:03:15 +020059 LOG_FMT_LOGCNT,
William Lallemand5f232402012-04-05 18:02:55 +020060 LOG_FMT_PID,
William Lallemand1d705562012-03-12 12:46:41 +010061 LOG_FMT_DATE,
62 LOG_FMT_DATEGMT,
Yuxans Yao4e25b012012-10-19 10:36:09 +080063 LOG_FMT_DATELOCAL,
William Lallemand5f232402012-04-05 18:02:55 +020064 LOG_FMT_TS,
William Lallemand1d705562012-03-12 12:46:41 +010065 LOG_FMT_MS,
66 LOG_FMT_FRONTEND,
Willy Tarreau773d65f2012-10-12 14:56:11 +020067 LOG_FMT_FRONTEND_XPRT,
William Lallemand1d705562012-03-12 12:46:41 +010068 LOG_FMT_BACKEND,
69 LOG_FMT_SERVER,
70 LOG_FMT_BYTES,
Willy Tarreauc5259fd2012-12-20 15:38:04 +010071 LOG_FMT_BYTES_UP,
William Lallemand1d705562012-03-12 12:46:41 +010072 LOG_FMT_T,
73 LOG_FMT_TQ,
74 LOG_FMT_TW,
75 LOG_FMT_TC,
76 LOG_FMT_TR,
77 LOG_FMT_TT,
78 LOG_FMT_STATUS,
79 LOG_FMT_CCLIENT,
80 LOG_FMT_CSERVER,
81 LOG_FMT_TERMSTATE,
82 LOG_FMT_TERMSTATE_CK,
83 LOG_FMT_CONN,
84 LOG_FMT_ACTCONN,
85 LOG_FMT_FECONN,
86 LOG_FMT_BECONN,
87 LOG_FMT_SRVCONN,
88 LOG_FMT_RETRIES,
89 LOG_FMT_QUEUES,
90 LOG_FMT_SRVQUEUE,
91 LOG_FMT_BCKQUEUE,
92 LOG_FMT_HDRREQUEST,
93 LOG_FMT_HDRRESPONS,
94 LOG_FMT_HDRREQUESTLIST,
95 LOG_FMT_HDRRESPONSLIST,
96 LOG_FMT_REQ,
Andrew Hayworth0ebc55f2015-04-27 21:37:03 +000097 LOG_FMT_HTTP_METHOD,
98 LOG_FMT_HTTP_URI,
99 LOG_FMT_HTTP_PATH,
Andrew Hayworthe63ac872015-07-31 16:14:16 +0000100 LOG_FMT_HTTP_QUERY,
Andrew Hayworth0ebc55f2015-04-27 21:37:03 +0000101 LOG_FMT_HTTP_VERSION,
William Lallemand5f232402012-04-05 18:02:55 +0200102 LOG_FMT_HOSTNAME,
William Lallemanda73203e2012-03-12 12:48:57 +0100103 LOG_FMT_UNIQUEID,
Willy Tarreauffc3fcd2012-10-12 20:17:54 +0200104 LOG_FMT_SSL_CIPHER,
105 LOG_FMT_SSL_VERSION,
William Lallemand723b73a2012-02-08 16:37:49 +0100106};
107
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100108/* enum for parse_logformat_string */
William Lallemand723b73a2012-02-08 16:37:49 +0100109enum {
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100110 LF_INIT = 0, // before first character
111 LF_TEXT, // normal text
112 LF_SEPARATOR, // a single separator
113 LF_VAR, // variable name, after '%' or '%{..}'
114 LF_STARTVAR, // % in text
115 LF_STARG, // after '%{' and berore '}'
116 LF_EDARG, // '}' after '%{'
Willy Tarreauc8368452012-12-21 00:09:23 +0100117 LF_STEXPR, // after '%[' or '%{..}[' and berore ']'
118 LF_EDEXPR, // ']' after '%['
Willy Tarreau8a3f52f2012-12-20 21:23:42 +0100119 LF_END, // \0 found
William Lallemand723b73a2012-02-08 16:37:49 +0100120};
121
122
123struct logformat_node {
124 struct list list;
Willy Tarreauc8368452012-12-21 00:09:23 +0100125 int type; // LOG_FMT_*
126 int options; // LOG_OPT_*
127 char *arg; // text for LOG_FMT_TEXT, arg for others
128 void *expr; // for use with LOG_FMT_EXPR
William Lallemand723b73a2012-02-08 16:37:49 +0100129};
130
William Lallemand5f232402012-04-05 18:02:55 +0200131#define LOG_OPT_HEXA 0x00000001
William Lallemand723b73a2012-02-08 16:37:49 +0100132#define LOG_OPT_MANDATORY 0x00000002
133#define LOG_OPT_QUOTE 0x00000004
Willy Tarreauc8368452012-12-21 00:09:23 +0100134#define LOG_OPT_REQ_CAP 0x00000008
135#define LOG_OPT_RES_CAP 0x00000010
Thierry FOURNIERd048d8b2014-03-13 16:46:18 +0100136#define LOG_OPT_HTTP 0x00000020
William Lallemand723b73a2012-02-08 16:37:49 +0100137
Willy Tarreaubaaee002006-06-26 02:48:02 +0200138
Willy Tarreaud79a3b22012-12-28 09:40:16 +0100139/* Fields that need to be extracted from the incoming connection or request for
140 * logging or for sending specific header information. They're set in px->to_log
141 * and appear as flags in session->logs.logwait, which are removed once the
142 * required information has been collected.
143 */
144#define LW_INIT 1 /* anything */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200145#define LW_CLIP 2 /* CLient IP */
146#define LW_SVIP 4 /* SerVer IP */
147#define LW_SVID 8 /* server ID */
148#define LW_REQ 16 /* http REQuest */
149#define LW_RESP 32 /* http RESPonse */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200150#define LW_BYTES 256 /* bytes read from server */
151#define LW_COOKIE 512 /* captured cookie */
152#define LW_REQHDR 1024 /* request header(s) */
153#define LW_RSPHDR 2048 /* response header(s) */
William Lallemand5e19a282012-04-02 16:22:10 +0200154#define LW_BCKIP 4096 /* backend IP */
155#define LW_FRTIP 8192 /* frontend IP */
Willy Tarreau93dbc2b2012-10-12 18:01:49 +0200156#define LW_XPRT 16384 /* transport layer information (eg: SSL) */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200157
Robert Tsai81ae1952007-12-05 10:47:29 +0100158struct logsrv {
William Lallemand0f99e342011-10-12 17:50:54 +0200159 struct list list;
David du Colombier11bcb6c2011-03-24 12:23:00 +0100160 struct sockaddr_storage addr;
William Lallemand0f99e342011-10-12 17:50:54 +0200161 int facility;
162 int level;
163 int minlvl;
Willy Tarreau18324f52014-06-27 18:10:07 +0200164 int maxlen;
Robert Tsai81ae1952007-12-05 10:47:29 +0100165};
166
Willy Tarreaubaaee002006-06-26 02:48:02 +0200167#endif /* _TYPES_LOG_H */
168
169/*
170 * Local variables:
171 * c-indent-level: 8
172 * c-basic-offset: 8
173 * End:
174 */