]> git.ipfire.org Git - thirdparty/squid.git/blame - src/AccessLogEntry.h
Update class MessageCounters to MessageSizes
[thirdparty/squid.git] / src / AccessLogEntry.h
CommitLineData
450e0c10 1/*
450e0c10 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.
26ac0430 18 *
450e0c10 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.
26ac0430 23 *
450e0c10 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 */
450e0c10 30#ifndef SQUID_HTTPACCESSLOGENTRY_H
31#define SQUID_HTTPACCESSLOGENTRY_H
32
65d448bc 33#include "anyp/PortCfg.h"
8bf217bd 34#include "base/RefCount.h"
a14f38d0 35#include "comm/Connection.h"
602d9612 36#include "HierarchyLogEntry.h"
526ed14e 37#include "http/ProtocolVersion.h"
602d9612 38#include "HttpHeader.h"
75cb38cb 39#include "HttpRequestMethod.h"
c8f1812b 40#include "icp_opcode.h"
96d89ea0 41#include "ip/Address.h"
02c8dde5 42#include "LogTags.h"
cc0ca3b9 43#include "MessageSizes.h"
02c8dde5 44#include "Notes.h"
3ff65596
AR
45#if ICAP_CLIENT
46#include "adaptation/icap/Elements.h"
47#endif
f4698e0b
CT
48#if USE_SSL
49#include "ssl/gadgets.h"
50#endif
450e0c10 51
62ee09ca 52/* forward decls */
e1f7507e
AJ
53class HttpReply;
54class HttpRequest;
613924ee 55class CustomLog;
62ee09ca 56
41ebd397 57class AccessLogEntry: public RefCountable
450e0c10 58{
59
60public:
41ebd397
CT
61 typedef RefCount<AccessLogEntry> Pointer;
62
a14f38d0 63 AccessLogEntry() : url(NULL), tcpClient(), reply(NULL), request(NULL),
105d1937 64 adapted_request(NULL) {}
41ebd397 65 ~AccessLogEntry();
450e0c10 66
d4204018
AJ
67 /// Fetch the client IP log string into the given buffer.
68 /// Knows about several alternate locations of the IP
69 /// including indirect forwarded-for IP if configured to log that
70 void getLogClientIp(char *buf, size_t bufsz) const;
71
450e0c10 72 const char *url;
73
a14f38d0
AJ
74 /// TCP/IP level details about the client connection
75 Comm::ConnectionPointer tcpClient;
76 // TCP/IP level details about the server or peer connection
77 // are stored in hier.tcpServer
78
4e26d606
AJ
79 /** \brief This subclass holds log info for HTTP protocol
80 * \todo Inner class declarations should be moved outside
81 * \todo details of HTTP held in the parent class need moving into here.
82 */
450e0c10 83 class HttpDetails
84 {
85
86 public:
c2a7cefd 87 HttpDetails() : method(Http::METHOD_NONE), code(0), content_type(NULL),
d6df21d2
AJ
88 timedout(false),
89 aborted(false),
cc0ca3b9
AJ
90 clientRequestSz(),
91 clientReplySz() {}
450e0c10 92
60745f24 93 HttpRequestMethod method;
450e0c10 94 int code;
95 const char *content_type;
526ed14e 96 Http::ProtocolVersion version;
f692498b
AJ
97 bool timedout; ///< terminated due to a lifetime or I/O timeout
98 bool aborted; ///< other abnormal termination (e.g., I/O error)
99
100 /// compute suffix for the status access.log field
101 const char *statusSfx() const {
102 return timedout ? "_TIMEDOUT" : (aborted ? "_ABORTED" : "");
103 }
d6df21d2
AJ
104
105 /// counters for the original request received from client
106 // TODO calculate header and payload better (by parser)
107 // XXX payload encoding overheads not calculated at all yet.
cc0ca3b9 108 MessageSizes clientRequestSz;
d6df21d2
AJ
109
110 /// counters for the response sent to client
111 // TODO calculate header and payload better (by parser)
112 // XXX payload encoding overheads not calculated at all yet.
cc0ca3b9 113 MessageSizes clientReplySz;
d6df21d2 114
2fadd50d 115 } http;
450e0c10 116
4e26d606
AJ
117 /** \brief This subclass holds log info for ICP protocol
118 * \todo Inner class declarations should be moved outside
119 */
120 class IcpDetails
450e0c10 121 {
122
123 public:
4e26d606 124 IcpDetails() : opcode(ICP_INVALID) {}
450e0c10 125
126 icp_opcode opcode;
2fadd50d 127 } icp;
450e0c10 128
4e26d606
AJ
129 /** \brief This subclass holds log info for HTCP protocol
130 * \todo Inner class declarations should be moved outside
131 */
04f7fd38
AJ
132 class HtcpDetails
133 {
a8b1cdf6
AJ
134 public:
135 HtcpDetails() : opcode(NULL) {};
136
137 const char *opcode;
138 } htcp;
139
08097970
AR
140#if USE_SSL
141 /// logging information specific to the SSL protocol
87f237a9
A
142 class SslDetails
143 {
08097970 144 public:
71cae389 145 SslDetails();
08097970
AR
146
147 const char *user; ///< emailAddress from the SSL client certificate
148 int bumpMode; ///< whether and how the request was SslBumped
149 } ssl;
150#endif
151
4e26d606
AJ
152 /** \brief This subclass holds log info for Squid internal stats
153 * \todo Inner class declarations should be moved outside
154 * \todo some details relevant to particular protocols need shuffling to other sub-classes
155 * \todo this object field need renaming to 'squid' or something.
156 */
450e0c10 157 class CacheDetails
158 {
159
160 public:
cc192b50 161 CacheDetails() : caddr(),
450e0c10 162 highOffset(0),
163 objectSize(0),
164 code (LOG_TAG_NONE),
165 msec(0),
166 rfc931 (NULL),
41ebd397 167 extuser(NULL),
450e0c10 168#if USE_SSL
41ebd397 169 ssluser(NULL),
450e0c10 170#endif
999aa5d2
A
171 port(NULL) {
172 ;
450e0c10 173 }
174
b7ac5457 175 Ip::Address caddr;
47f6e231 176 int64_t highOffset;
177 int64_t objectSize;
02c8dde5 178 LogTags code;
450e0c10 179 int msec;
180 const char *rfc931;
661ef4eb 181 const char *extuser;
450e0c10 182#if USE_SSL
183
184 const char *ssluser;
f4698e0b 185 Ssl::X509_Pointer sslClientCert; ///< cert received from the client
450e0c10 186#endif
65d448bc 187 AnyP::PortCfg *port;
450e0c10 188
2fadd50d 189 } cache;
450e0c10 190
4e26d606
AJ
191 /** \brief This subclass holds log info for various headers in raw format
192 * \todo shuffle this to the relevant protocol section.
193 */
450e0c10 194 class Headers
195 {
196
197 public:
3ff65596 198 Headers() : request(NULL),
105d1937 199 adapted_request(NULL),
e1381638 200 reply(NULL) {}
450e0c10 201
6fca33e0
CT
202 char *request; //< virgin HTTP request headers
203
105d1937 204 char *adapted_request; //< HTTP request headers after adaptation and redirection
6fca33e0 205
99690f32
AR
206 char *reply;
207 } headers;
3ff65596 208
5038f9d8 209#if USE_ADAPTATION
99690f32
AR
210 /** \brief This subclass holds general adaptation log info.
211 * \todo Inner class declarations should be moved outside.
212 */
213 class AdaptationDetails
214 {
215
216 public:
217 AdaptationDetails(): last_meta(NULL) {}
5038f9d8 218
99690f32
AR
219 /// image of the last ICAP response header or eCAP meta received
220 char *last_meta;
221 } adapt;
3ff65596 222#endif
450e0c10 223
e1f7507e
AJ
224 // Why is this a sub-class and not a set of real "private:" fields?
225 // It looks like its duplicating HTTPRequestMethod anyway!
4e26d606 226 // TODO: shuffle this to the relevant protocol section OR replace with request->method
450e0c10 227 class Private
228 {
229
230 public:
231 Private() : method_str(NULL) {}
232
233 const char *method_str;
2fadd50d 234 } _private;
450e0c10 235 HierarchyLogEntry hier;
236 HttpReply *reply;
105d1937 237 HttpRequest *request; //< virgin HTTP request
6fca33e0 238 HttpRequest *adapted_request; //< HTTP request after adaptation and redirection
d06e17ea 239
f4f55a21 240 /// key:value pairs set by squid.conf note directive and
cf9f0261 241 /// key=value pairs returned from URL rewrite/redirect helper
f4f55a21 242 NotePairs::Pointer notes;
6fca33e0 243
3ff65596
AR
244#if ICAP_CLIENT
245 /** \brief This subclass holds log info for ICAP part of request
246 * \todo Inner class declarations should be moved outside
247 */
e1381638
AJ
248 class IcapLogEntry
249 {
3ff65596 250 public:
f5d0906a 251 IcapLogEntry() : reqMethod(Adaptation::methodNone), bytesSent(0), bytesRead(0),
99c1b994
A
252 bodyBytesRead(-1), request(NULL), reply(NULL),
253 outcome(Adaptation::Icap::xoUnknown), trTime(0),
955394ce 254 ioTime(0), resStatus(Http::scNone), processingTime(0) {}
3ff65596 255
b7ac5457 256 Ip::Address hostAddr; ///< ICAP server IP address
3ff65596
AR
257 String serviceName; ///< ICAP service name
258 String reqUri; ///< ICAP Request-URI
259 Adaptation::Icap::ICAP::Method reqMethod; ///< ICAP request method
260 int64_t bytesSent; ///< number of bytes sent to ICAP server so far
261 int64_t bytesRead; ///< number of bytes read from ICAP server so far
bae917ac 262 /**
dcaab393 263 * number of ICAP body bytes read from ICAP server or -1 for no encapsulated
bae917ac
CT
264 * message data in ICAP reply (eg 204 responses)
265 */
266 int64_t bodyBytesRead;
3ff65596
AR
267 HttpRequest* request; ///< ICAP request
268 HttpReply* reply; ///< ICAP reply
269
270 Adaptation::Icap::XactOutcome outcome; ///< final transaction status
271 /** \brief Transaction response time.
272 * The timer starts when the ICAP transaction
273 * is created and stops when the result of the transaction is logged
274 */
275 int trTime;
276 /** \brief Transaction I/O time.
277 * The timer starts when the first ICAP request
e1381638 278 * byte is scheduled for sending and stops when the lastbyte of the
3ff65596
AR
279 * ICAP response is received.
280 */
281 int ioTime;
955394ce 282 Http::StatusCode resStatus; ///< ICAP response status code
3ff65596
AR
283 int processingTime; ///< total ICAP processing time in milliseconds
284 }
285 icap;
286#endif
450e0c10 287};
288
e1f7507e
AJ
289class ACLChecklist;
290class StoreEntry;
e1f7507e 291
450e0c10 292/* Should be in 'AccessLog.h' as the driver */
8a648e8d
FC
293void accessLogLogTo(CustomLog* log, AccessLogEntry::Pointer &al, ACLChecklist* checklist = NULL);
294void accessLogLog(AccessLogEntry::Pointer &, ACLChecklist * checklist);
295void accessLogRotate(void);
296void accessLogClose(void);
297void accessLogInit(void);
298const char *accessLogTime(time_t);
450e0c10 299
300#endif /* SQUID_HTTPACCESSLOGENTRY_H */