]> git.ipfire.org Git - thirdparty/squid.git/blob - src/AccessLogEntry.h
SourceLayout: Add Ip namespace for internal libip
[thirdparty/squid.git] / src / AccessLogEntry.h
1 /*
2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
4 *
5 * Squid is the result of efforts by numerous individuals from
6 * the Internet community; see the CONTRIBUTORS file for full
7 * details. Many organizations have provided support for Squid's
8 * development; see the SPONSORS file for full details. Squid is
9 * Copyrighted (C) 2001 by the Regents of the University of
10 * California; see the COPYRIGHT file for full details. Squid
11 * incorporates software developed and/or copyrighted by other
12 * sources; see the CREDITS file for full details.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
27 *
28 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
29 */
30 #ifndef SQUID_HTTPACCESSLOGENTRY_H
31 #define SQUID_HTTPACCESSLOGENTRY_H
32
33 #include "HttpVersion.h"
34 #include "HttpRequestMethod.h"
35 #include "HierarchyLogEntry.h"
36 #include "ip/IpAddress.h"
37 #include "HttpRequestMethod.h"
38 #if ICAP_CLIENT
39 #include "adaptation/icap/Elements.h"
40 #endif
41
42 /* forward decls */
43 class HttpReply;
44 class HttpRequest;
45
46 class AccessLogEntry
47 {
48
49 public:
50 AccessLogEntry() : url(NULL) , reply(NULL), request(NULL),
51 adapted_request(NULL) {}
52
53 const char *url;
54
55 class HttpDetails
56 {
57
58 public:
59 HttpDetails() : method(METHOD_NONE), code(0), content_type(NULL),
60 timedout(false), aborted(false) {}
61
62 HttpRequestMethod method;
63 int code;
64 const char *content_type;
65 HttpVersion version;
66 bool timedout; ///< terminated due to a lifetime or I/O timeout
67 bool aborted; ///< other abnormal termination (e.g., I/O error)
68
69 /// compute suffix for the status access.log field
70 const char *statusSfx() const {
71 return timedout ? "_TIMEDOUT" : (aborted ? "_ABORTED" : "");
72 }
73 } http;
74
75 class ICPDetails
76 {
77
78 public:
79 ICPDetails() : opcode(ICP_INVALID) {}
80
81 icp_opcode opcode;
82 } icp;
83
84 class HtcpDetails
85 {
86 public:
87 HtcpDetails() : opcode(NULL) {};
88
89 const char *opcode;
90 } htcp;
91
92 class CacheDetails
93 {
94
95 public:
96 CacheDetails() : caddr(),
97 requestSize(0),
98 replySize(0),
99 requestHeadersSize(0),
100 replyHeadersSize(0),
101 highOffset(0),
102 objectSize(0),
103 code (LOG_TAG_NONE),
104 msec(0),
105 rfc931 (NULL),
106 authuser (NULL),
107 extuser(NULL)
108 #if USE_SSL
109 ,ssluser(NULL)
110 #endif
111 {;
112 }
113
114 Ip::Address caddr;
115 int64_t requestSize;
116 int64_t replySize;
117 int requestHeadersSize; ///< received, including request line
118 int replyHeadersSize; ///< sent, including status line
119 int64_t highOffset;
120 int64_t objectSize;
121 log_type code;
122 int msec;
123 const char *rfc931;
124 const char *authuser;
125 const char *extuser;
126 #if USE_SSL
127
128 const char *ssluser;
129 #endif
130
131 } cache;
132
133 class Headers
134 {
135
136 public:
137 Headers() : request(NULL),
138 adapted_request(NULL),
139
140 #if ICAP_CLIENT
141 icap(NULL),
142 #endif
143 reply(NULL) {}
144
145 char *request; //< virgin HTTP request headers
146
147 char *adapted_request; //< HTTP request headers after adaptation and redirection
148
149
150 #if ICAP_CLIENT
151 char * icap; ///< last matching ICAP response header.
152 #endif
153 char *reply;
154 } headers;
155
156 // Why is this a sub-class and not a set of real "private:" fields?
157 // It looks like its duplicating HTTPRequestMethod anyway!
158 class Private
159 {
160
161 public:
162 Private() : method_str(NULL) {}
163
164 const char *method_str;
165 } _private;
166 HierarchyLogEntry hier;
167 HttpReply *reply;
168 HttpRequest *request; //< virgin HTTP request
169 HttpRequest *adapted_request; //< HTTP request after adaptation and redirection
170
171
172 #if ICAP_CLIENT
173 /** \brief This subclass holds log info for ICAP part of request
174 * \todo Inner class declarations should be moved outside
175 */
176 class IcapLogEntry
177 {
178 public:
179 IcapLogEntry():request(NULL),reply(NULL),outcome(Adaptation::Icap::xoUnknown),trTime(0),ioTime(0),resStatus(HTTP_STATUS_NONE) {}
180
181 Ip::Address hostAddr; ///< ICAP server IP address
182 String serviceName; ///< ICAP service name
183 String reqUri; ///< ICAP Request-URI
184 Adaptation::Icap::ICAP::Method reqMethod; ///< ICAP request method
185 int64_t bytesSent; ///< number of bytes sent to ICAP server so far
186 int64_t bytesRead; ///< number of bytes read from ICAP server so far
187 HttpRequest* request; ///< ICAP request
188 HttpReply* reply; ///< ICAP reply
189
190 Adaptation::Icap::XactOutcome outcome; ///< final transaction status
191 /** \brief Transaction response time.
192 * The timer starts when the ICAP transaction
193 * is created and stops when the result of the transaction is logged
194 */
195 int trTime;
196 /** \brief Transaction I/O time.
197 * The timer starts when the first ICAP request
198 * byte is scheduled for sending and stops when the lastbyte of the
199 * ICAP response is received.
200 */
201 int ioTime;
202 http_status resStatus; ///< ICAP response status code
203 int processingTime; ///< total ICAP processing time in milliseconds
204 }
205 icap;
206 #endif
207 };
208
209 class ACLChecklist;
210 class StoreEntry;
211 class logformat_token;
212
213 /* Should be in 'AccessLog.h' as the driver */
214 extern void accessLogLogTo(customlog* log, AccessLogEntry* al, ACLChecklist* checklist = NULL);
215 extern void accessLogLog(AccessLogEntry *, ACLChecklist * checklist);
216 extern void accessLogRotate(void);
217 extern void accessLogClose(void);
218 extern void accessLogInit(void);
219 extern void accessLogFreeMemory(AccessLogEntry * aLogEntry);
220 extern const char *accessLogTime(time_t);
221 extern int accessLogParseLogFormat(logformat_token ** fmt, char *def);
222 extern void accessLogDumpLogFormat(StoreEntry * entry, const char *name, logformat * definitions);
223 extern void accessLogFreeLogFormat(logformat_token ** fmt);
224
225 #endif /* SQUID_HTTPACCESSLOGENTRY_H */