1 /* 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 25 #include <sys/socket.h> 26 #include <sys/un.h> 27 #include <netinet/in.h> 28 #include <common/config.h> 29 #include <common/mini-clist.h> 30 31 #define NB_LOG_FACILITIES 24 32 #define NB_LOG_LEVELS 8 33 #define NB_MSG_IOVEC_ELEMENTS 8 34 #define SYSLOG_PORT 514 35 #define UNIQUEID_LEN 128 36 37 /* The array containing the names of the log levels. */ 38 extern const char *log_levels[]; 39 40 /* enum for log format */ 41 enum { 42 LOG_FORMAT_RFC3164 = 0, 43 LOG_FORMAT_RFC5424, 44 LOG_FORMATS, /* number of supported log formats, must always be last */ 45 }; 46 47 /* lists of fields that can be logged */ 48 enum { 49 50 LOG_FMT_TEXT = 0, /* raw text */ 51 LOG_FMT_EXPR, /* sample expression */ 52 LOG_FMT_SEPARATOR, /* separator replaced by one space */ 53 54 /* information fields */ 55 LOG_FMT_GLOBAL, 56 LOG_FMT_CLIENTIP, 57 LOG_FMT_CLIENTPORT, 58 LOG_FMT_BACKENDIP, 59 LOG_FMT_BACKENDPORT, 60 LOG_FMT_FRONTENDIP, 61 LOG_FMT_FRONTENDPORT, 62 LOG_FMT_SERVERPORT, 63 LOG_FMT_SERVERIP, 64 LOG_FMT_COUNTER, 65 LOG_FMT_LOGCNT, 66 LOG_FMT_PID, 67 LOG_FMT_DATE, 68 LOG_FMT_DATEGMT, 69 LOG_FMT_DATELOCAL, 70 LOG_FMT_TS, 71 LOG_FMT_MS, 72 LOG_FMT_FRONTEND, 73 LOG_FMT_FRONTEND_XPRT, 74 LOG_FMT_BACKEND, 75 LOG_FMT_SERVER, 76 LOG_FMT_BYTES, 77 LOG_FMT_BYTES_UP, 78 LOG_FMT_Ta, 79 LOG_FMT_Th, 80 LOG_FMT_Ti, 81 LOG_FMT_TQ, 82 LOG_FMT_TW, 83 LOG_FMT_TC, 84 LOG_FMT_Tr, 85 LOG_FMT_tr, 86 LOG_FMT_trg, 87 LOG_FMT_trl, 88 LOG_FMT_TR, 89 LOG_FMT_TD, 90 LOG_FMT_TT, 91 LOG_FMT_STATUS, 92 LOG_FMT_CCLIENT, 93 LOG_FMT_CSERVER, 94 LOG_FMT_TERMSTATE, 95 LOG_FMT_TERMSTATE_CK, 96 LOG_FMT_ACTCONN, 97 LOG_FMT_FECONN, 98 LOG_FMT_BECONN, 99 LOG_FMT_SRVCONN, 100 LOG_FMT_RETRIES, 101 LOG_FMT_SRVQUEUE, 102 LOG_FMT_BCKQUEUE, 103 LOG_FMT_HDRREQUEST, 104 LOG_FMT_HDRRESPONS, 105 LOG_FMT_HDRREQUESTLIST, 106 LOG_FMT_HDRRESPONSLIST, 107 LOG_FMT_REQ, 108 LOG_FMT_HTTP_METHOD, 109 LOG_FMT_HTTP_URI, 110 LOG_FMT_HTTP_PATH, 111 LOG_FMT_HTTP_QUERY, 112 LOG_FMT_HTTP_VERSION, 113 LOG_FMT_HOSTNAME, 114 LOG_FMT_UNIQUEID, 115 LOG_FMT_SSL_CIPHER, 116 LOG_FMT_SSL_VERSION, 117 }; 118 119 /* enum for parse_logformat_string */ 120 enum { 121 LF_INIT = 0, // before first character 122 LF_TEXT, // normal text 123 LF_SEPARATOR, // a single separator 124 LF_VAR, // variable name, after '%' or '%{..}' 125 LF_STARTVAR, // % in text 126 LF_STARG, // after '%{' and berore '}' 127 LF_EDARG, // '}' after '%{' 128 LF_STEXPR, // after '%[' or '%{..}[' and berore ']' 129 LF_EDEXPR, // ']' after '%[' 130 LF_END, // \0 found 131 }; 132 133 134 struct logformat_node { 135 struct list list; 136 int type; // LOG_FMT_* 137 int options; // LOG_OPT_* 138 char *arg; // text for LOG_FMT_TEXT, arg for others 139 void *expr; // for use with LOG_FMT_EXPR 140 }; 141 142 #define LOG_OPT_HEXA 0x00000001 143 #define LOG_OPT_MANDATORY 0x00000002 144 #define LOG_OPT_QUOTE 0x00000004 145 #define LOG_OPT_REQ_CAP 0x00000008 146 #define LOG_OPT_RES_CAP 0x00000010 147 #define LOG_OPT_HTTP 0x00000020 148 #define LOG_OPT_ESC 0x00000040 149 150 151 /* Fields that need to be extracted from the incoming connection or request for 152 * logging or for sending specific header information. They're set in px->to_log 153 * and appear as flags in session->logs.logwait, which are removed once the 154 * required information has been collected. 155 */ 156 #define LW_INIT 1 /* anything */ 157 #define LW_CLIP 2 /* CLient IP */ 158 #define LW_SVIP 4 /* SerVer IP */ 159 #define LW_SVID 8 /* server ID */ 160 #define LW_REQ 16 /* http REQuest */ 161 #define LW_RESP 32 /* http RESPonse */ 162 #define LW_BYTES 256 /* bytes read from server */ 163 #define LW_COOKIE 512 /* captured cookie */ 164 #define LW_REQHDR 1024 /* request header(s) */ 165 #define LW_RSPHDR 2048 /* response header(s) */ 166 #define LW_BCKIP 4096 /* backend IP */ 167 #define LW_FRTIP 8192 /* frontend IP */ 168 #define LW_XPRT 16384 /* transport layer information (eg: SSL) */ 169 170 struct logsrv { 171 struct list list; 172 struct sockaddr_storage addr; 173 int format; 174 int facility; 175 int level; 176 int minlvl; 177 int maxlen; 178 }; 179 180 #endif /* _TYPES_LOG_H */ 181 182 /* 183 * Local variables: 184 * c-indent-level: 8 185 * c-basic-offset: 8 186 * End: 187 */ 188