]> git.ipfire.org Git - thirdparty/squid.git/blob - src/AccessLogEntry.h
Merge from trunk
[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
52 const char *url;
53
54 class HttpDetails
55 {
56
57 public:
58 HttpDetails() : method(METHOD_NONE), code(0), content_type(NULL) {}
59
60 HttpRequestMethod method;
61 int code;
62 const char *content_type;
63 HttpVersion version;
64 } http;
65
66 class ICPDetails
67 {
68
69 public:
70 ICPDetails() : opcode(ICP_INVALID) {}
71
72 icp_opcode opcode;
73 } icp;
74
75 class HtcpDetails
76 {
77 public:
78 HtcpDetails() : opcode(NULL) {};
79
80 const char *opcode;
81 } htcp;
82
83 class CacheDetails
84 {
85
86 public:
87 CacheDetails() : caddr(),
88 requestSize(0),
89 replySize(0),
90 requestHeadersSize(0),
91 replyHeadersSize(0),
92 highOffset(0),
93 objectSize(0),
94 code (LOG_TAG_NONE),
95 msec(0),
96 rfc931 (NULL),
97 authuser (NULL),
98 extuser(NULL)
99 #if USE_SSL
100 ,ssluser(NULL)
101 #endif
102 {;
103 }
104
105 IpAddress caddr;
106 int64_t requestSize;
107 int64_t replySize;
108 int requestHeadersSize; ///< received, including request line
109 int replyHeadersSize; ///< sent, including status line
110 int64_t highOffset;
111 int64_t objectSize;
112 log_type code;
113 int msec;
114 const char *rfc931;
115 const char *authuser;
116 const char *extuser;
117 #if USE_SSL
118
119 const char *ssluser;
120 #endif
121
122 } cache;
123
124 class Headers
125 {
126
127 public:
128 Headers() : request(NULL),
129 #if ICAP_CLIENT
130 icap(NULL),
131 #endif
132 reply(NULL) {}
133
134 char *request;
135
136 #if ICAP_CLIENT
137 char * icap; ///< last matching ICAP response header.
138 #endif
139 char *reply;
140 } headers;
141
142 // Why is this a sub-class and not a set of real "private:" fields?
143 // It looks like its duplicating HTTPRequestMethod anyway!
144 class Private
145 {
146
147 public:
148 Private() : method_str(NULL) {}
149
150 const char *method_str;
151 } _private;
152 HierarchyLogEntry hier;
153 HttpReply *reply;
154 HttpRequest *request;
155
156 #if ICAP_CLIENT
157 /** \brief This subclass holds log info for ICAP part of request
158 * \todo Inner class declarations should be moved outside
159 */
160 class IcapLogEntry {
161 public:
162 IcapLogEntry():request(NULL),reply(NULL),outcome(Adaptation::Icap::xoUnknown),trTime(0),ioTime(0),resStatus(HTTP_STATUS_NONE){}
163
164 IpAddress hostAddr; ///< ICAP server IP address
165 String serviceName; ///< ICAP service name
166 String reqUri; ///< ICAP Request-URI
167 Adaptation::Icap::ICAP::Method reqMethod; ///< ICAP request method
168 int64_t bytesSent; ///< number of bytes sent to ICAP server so far
169 int64_t bytesRead; ///< number of bytes read from ICAP server so far
170 HttpRequest* request; ///< ICAP request
171 HttpReply* reply; ///< ICAP reply
172
173 Adaptation::Icap::XactOutcome outcome; ///< final transaction status
174 /** \brief Transaction response time.
175 * The timer starts when the ICAP transaction
176 * is created and stops when the result of the transaction is logged
177 */
178 int trTime;
179 /** \brief Transaction I/O time.
180 * The timer starts when the first ICAP request
181 * byte is scheduled for sending and stops when the lastbyte of the
182 * ICAP response is received.
183 */
184 int ioTime;
185 http_status resStatus; ///< ICAP response status code
186 int processingTime; ///< total ICAP processing time in milliseconds
187 }
188 icap;
189 #endif
190 };
191
192 class ACLChecklist;
193 class StoreEntry;
194 class logformat_token;
195
196 /* Should be in 'AccessLog.h' as the driver */
197 extern void accessLogLogTo(customlog* log, AccessLogEntry* al, ACLChecklist* checklist = NULL);
198 extern void accessLogLog(AccessLogEntry *, ACLChecklist * checklist);
199 extern void accessLogRotate(void);
200 extern void accessLogClose(void);
201 extern void accessLogInit(void);
202 extern void accessLogFreeMemory(AccessLogEntry * aLogEntry);
203 extern const char *accessLogTime(time_t);
204 extern int accessLogParseLogFormat(logformat_token ** fmt, char *def);
205 extern void accessLogDumpLogFormat(StoreEntry * entry, const char *name, logformat * definitions);
206 extern void accessLogFreeLogFormat(logformat_token ** fmt);
207
208 #endif /* SQUID_HTTPACCESSLOGENTRY_H */