2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
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.
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.
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.
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.
28 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
30 #ifndef SQUID_HTTPACCESSLOGENTRY_H
31 #define SQUID_HTTPACCESSLOGENTRY_H
33 #include "anyp/PortCfg.h"
34 #include "base/RefCount.h"
35 #include "comm/Connection.h"
36 #include "HttpHeader.h"
37 #include "HttpVersion.h"
38 #include "HttpRequestMethod.h"
39 #include "HierarchyLogEntry.h"
40 #include "icp_opcode.h"
41 #include "ip/Address.h"
42 #include "HttpRequestMethod.h"
44 #include "adaptation/icap/Elements.h"
48 #include "ssl/gadgets.h"
56 class AccessLogEntry
: public RefCountable
60 typedef RefCount
<AccessLogEntry
> Pointer
;
62 AccessLogEntry() : url(NULL
), tcpClient(), reply(NULL
), request(NULL
),
63 adapted_request(NULL
) {}
66 /// Fetch the client IP log string into the given buffer.
67 /// Knows about several alternate locations of the IP
68 /// including indirect forwarded-for IP if configured to log that
69 void getLogClientIp(char *buf
, size_t bufsz
) const;
73 /// TCP/IP level details about the client connection
74 Comm::ConnectionPointer tcpClient
;
75 // TCP/IP level details about the server or peer connection
76 // are stored in hier.tcpServer
78 /** \brief This subclass holds log info for HTTP protocol
79 * \todo Inner class declarations should be moved outside
80 * \todo details of HTTP held in the parent class need moving into here.
86 HttpDetails() : method(Http::METHOD_NONE
), code(0), content_type(NULL
),
87 timedout(false), aborted(false) {}
89 HttpRequestMethod method
;
91 const char *content_type
;
93 bool timedout
; ///< terminated due to a lifetime or I/O timeout
94 bool aborted
; ///< other abnormal termination (e.g., I/O error)
96 /// compute suffix for the status access.log field
97 const char *statusSfx() const {
98 return timedout
? "_TIMEDOUT" : (aborted
? "_ABORTED" : "");
102 /** \brief This subclass holds log info for ICP protocol
103 * \todo Inner class declarations should be moved outside
109 IcpDetails() : opcode(ICP_INVALID
) {}
114 /** \brief This subclass holds log info for HTCP protocol
115 * \todo Inner class declarations should be moved outside
120 HtcpDetails() : opcode(NULL
) {};
126 /// logging information specific to the SSL protocol
132 const char *user
; ///< emailAddress from the SSL client certificate
133 int bumpMode
; ///< whether and how the request was SslBumped
137 /** \brief This subclass holds log info for Squid internal stats
138 * \todo Inner class declarations should be moved outside
139 * \todo some details relevant to particular protocols need shuffling to other sub-classes
140 * \todo this object field need renaming to 'squid' or something.
146 CacheDetails() : caddr(),
149 requestHeadersSize(0),
168 int requestHeadersSize
; ///< received, including request line
169 int replyHeadersSize
; ///< sent, including status line
175 const char *authuser
;
180 Ssl::X509_Pointer sslClientCert
; ///< cert received from the client
186 /** \brief This subclass holds log info for various headers in raw format
187 * \todo shuffle this to the relevant protocol section.
193 Headers() : request(NULL
),
194 adapted_request(NULL
),
197 char *request
; //< virgin HTTP request headers
199 char *adapted_request
; //< HTTP request headers after adaptation and redirection
205 /** \brief This subclass holds general adaptation log info.
206 * \todo Inner class declarations should be moved outside.
208 class AdaptationDetails
212 AdaptationDetails(): last_meta(NULL
) {}
214 /// image of the last ICAP response header or eCAP meta received
219 // Why is this a sub-class and not a set of real "private:" fields?
220 // It looks like its duplicating HTTPRequestMethod anyway!
221 // TODO: shuffle this to the relevant protocol section OR replace with request->method
226 Private() : method_str(NULL
) {}
228 const char *method_str
;
230 HierarchyLogEntry hier
;
232 HttpRequest
*request
; //< virgin HTTP request
233 HttpRequest
*adapted_request
; //< HTTP request after adaptation and redirection
235 /// key:value pairs set by note and adaptation_meta directives
236 /// plus key=value pairs returned from URL rewrite/redirect helper
240 /** \brief This subclass holds log info for ICAP part of request
241 * \todo Inner class declarations should be moved outside
246 IcapLogEntry():bodyBytesRead(-1),request(NULL
),reply(NULL
),outcome(Adaptation::Icap::xoUnknown
),trTime(0),ioTime(0),resStatus(HTTP_STATUS_NONE
) {}
248 Ip::Address hostAddr
; ///< ICAP server IP address
249 String serviceName
; ///< ICAP service name
250 String reqUri
; ///< ICAP Request-URI
251 Adaptation::Icap::ICAP::Method reqMethod
; ///< ICAP request method
252 int64_t bytesSent
; ///< number of bytes sent to ICAP server so far
253 int64_t bytesRead
; ///< number of bytes read from ICAP server so far
255 * number of ICAP body bytes read from ICAP server or -1 for no encapsulated
256 * message data in ICAP reply (eg 204 responses)
258 int64_t bodyBytesRead
;
259 HttpRequest
* request
; ///< ICAP request
260 HttpReply
* reply
; ///< ICAP reply
262 Adaptation::Icap::XactOutcome outcome
; ///< final transaction status
263 /** \brief Transaction response time.
264 * The timer starts when the ICAP transaction
265 * is created and stops when the result of the transaction is logged
268 /** \brief Transaction I/O time.
269 * The timer starts when the first ICAP request
270 * byte is scheduled for sending and stops when the lastbyte of the
271 * ICAP response is received.
274 http_status resStatus
; ///< ICAP response status code
275 int processingTime
; ///< total ICAP processing time in milliseconds
284 /* Should be in 'AccessLog.h' as the driver */
285 void accessLogLogTo(CustomLog
* log
, AccessLogEntry::Pointer
&al
, ACLChecklist
* checklist
= NULL
);
286 void accessLogLog(AccessLogEntry::Pointer
&, ACLChecklist
* checklist
);
287 void accessLogRotate(void);
288 void accessLogClose(void);
289 void accessLogInit(void);
290 const char *accessLogTime(time_t);
292 #endif /* SQUID_HTTPACCESSLOGENTRY_H */