Squid Web Cache master
Loading...
Searching...
No Matches
AccessLogEntry.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2026 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef SQUID_SRC_ACCESSLOGENTRY_H
10#define SQUID_SRC_ACCESSLOGENTRY_H
11
12#include "anyp/PortCfg.h"
13#include "base/CodeContext.h"
14#include "comm/Connection.h"
15#include "error/Error.h"
16#include "HierarchyLogEntry.h"
18#include "http/RequestMethod.h"
19#include "HttpHeader.h"
20#include "icp_opcode.h"
21#include "ip/Address.h"
22#include "LogTags.h"
23#include "MessageSizes.h"
24#include "Notes.h"
25#include "proxyp/forward.h"
26#include "sbuf/forward.h"
27#if ICAP_CLIENT
29#endif
30#if USE_OPENSSL
31#include "ssl/gadgets.h"
32#include "ssl/support.h"
33#endif
34
35/* forward decls */
36class HttpReply;
37class HttpRequest;
38class CustomLog;
39
41{
42
43public:
45
47 ~AccessLogEntry() override;
48
49 /* CodeContext API */
50 std::ostream &detailCodeContext(std::ostream &os) const override;
51 ScopedId codeContextGist() const override;
52
56 void getLogClientIp(char *buf, size_t bufsz) const;
57
61 const char *getLogClientFqdn(char *buf, size_t bufSize) const;
62
64 const char *getExtUser() const;
65
67 bool hasLogMethod() const { return icp.opcode || htcp.opcode || http.method; }
68
70 SBuf getLogMethod() const;
71
73
75 void packReplyHeaders(MemBuf &mb) const;
76
78
81 // TCP/IP level details about the server or peer connection
82 // are stored in hier.tcpServer
83
89 {
90
91 public:
93 int code = 0;
94 const char *content_type = nullptr;
96
98 // TODO calculate header and payload better (by parser)
99 // XXX payload encoding overheads not calculated at all yet.
101
103 // TODO calculate header and payload better (by parser)
104 // XXX payload encoding overheads not calculated at all yet.
106
108
113 {
114 public:
117
122 {
123 public:
124 const char *opcode = nullptr;
126
127#if USE_OPENSSL
130 {
131 public:
132 const char *user = nullptr;
135#endif
136
143 {
144 public:
147 memset(&start_time, 0, sizeof(start_time));
148 memset(&trTime, 0, sizeof(start_time));
149 }
150
152 int64_t highOffset = 0;
153 int64_t objectSize = 0;
155 struct timeval start_time;
156 struct timeval trTime;
157 const char *extuser = nullptr;
158#if USE_OPENSSL
159 const char *ssluser = nullptr;
161#endif
164
169 {
170 public:
171 char *request = nullptr; //< virgin HTTP request headers
172 char *adapted_request = nullptr; //< HTTP request headers after adaptation and redirection
174
175#if USE_ADAPTATION
180 {
181 public:
183 char *last_meta = nullptr;
185#endif
186
189
192 HttpRequest *request = nullptr; //< virgin HTTP request
193 HttpRequest *adapted_request = nullptr; //< HTTP request after adaptation and redirection
194
198
204
207
208#if ICAP_CLIENT
213 {
214 public:
216 memset(&trTime, 0, sizeof(trTime));
217 memset(&ioTime, 0, sizeof(ioTime));
218 memset(&processingTime, 0, sizeof(processingTime));
219 }
220
224 Adaptation::Icap::ICAP::Method reqMethod = Adaptation::methodNone;
225 int64_t bytesSent = 0;
226 int64_t bytesRead = 0;
231 int64_t bodyBytesRead = -1;
232 HttpRequest* request = nullptr;
233 HttpReply* reply = nullptr;
234
240 struct timeval trTime;
246 struct timeval ioTime;
248 struct timeval processingTime;
249 }
251#endif
252
257 const SBuf *effectiveVirginUrl() const;
258
261 {
262 if (!request)
264 }
265
267 const Error *error() const;
268
270 void updateError(const Error &);
271
272private:
276
280};
281
282class ACLChecklist;
283class StoreEntry;
284
285/* Should be in 'AccessLog.h' as the driver */
286void accessLogLogTo(CustomLog *, const AccessLogEntryPointer &, ACLChecklist *checklist = nullptr);
288void accessLogRotate(void);
289void accessLogClose(void);
290void accessLogInit(void);
291const char *accessLogTime(time_t);
292
293#endif /* SQUID_SRC_ACCESSLOGENTRY_H */
294
void accessLogInit(void)
void accessLogClose(void)
void accessLogLogTo(CustomLog *, const AccessLogEntryPointer &, ACLChecklist *checklist=nullptr)
Definition access_log.cc:66
void accessLogRotate(void)
void accessLogLog(const AccessLogEntryPointer &, ACLChecklist *)
const char * accessLogTime(time_t)
This subclass holds general adaptation log info. TODO: Inner class declarations should be moved outsi...
char * last_meta
image of the last ICAP response header or eCAP meta received
This subclass holds log info for Squid internal stats TODO: Inner class declarations should be moved ...
AnyP::PortCfgPointer port
Security::CertPointer sslClientCert
cert received from the client
struct timeval start_time
The time the master transaction started.
struct timeval trTime
The response time.
This subclass holds log info for various headers in raw format TODO: shuffle this to the relevant pro...
This subclass holds log info for HTCP protocol TODO: Inner class declarations should be moved outside...
This subclass holds log info for HTTP protocol TODO: Inner class declarations should be moved outside...
MessageSizes clientReplySz
counters for the response sent to client
MessageSizes clientRequestSz
counters for the original request received from client
AnyP::ProtocolVersion version
This subclass holds log info for ICAP part of request TODO: Inner class declarations should be moved ...
SBuf reqUri
ICAP Request-URI.
struct timeval processingTime
total ICAP processing time
struct timeval trTime
Transaction response time. The timer starts when the ICAP transaction is created and stops when the r...
Adaptation::Icap::XactOutcome outcome
final transaction status
Ip::Address hostAddr
ICAP server IP address.
HttpReply * reply
ICAP reply.
SBuf serviceName
ICAP service name.
Http::StatusCode resStatus
ICAP response status code.
int64_t bytesRead
number of bytes read from ICAP server so far
Adaptation::Icap::ICAP::Method reqMethod
ICAP request method.
struct timeval ioTime
Transaction I/O time. The timer starts when the first ICAP request byte is scheduled for sending and ...
int64_t bytesSent
number of bytes sent to ICAP server so far
HttpRequest * request
ICAP request.
This subclass holds log info for ICP protocol TODO: Inner class declarations should be moved outside.
logging information specific to the SSL protocol
const char * user
emailAddress from the SSL client certificate
int bumpMode
whether and how the request was SslBumped
SBuf lastAclName
string for external_acl_type ACL format code
const Error * error() const
void getLogClientIp(char *buf, size_t bufsz) const
HttpReplyPointer reply
SBuf getLogMethod() const
Fetch the transaction method string (ICP opcode, HTCP opcode or HTTP method)
void packReplyHeaders(MemBuf &mb) const
dump all reply headers (for sending or risky logging)
class AccessLogEntry::CacheDetails cache
bool hasLogMethod() const
whether we know what the request method is
SBuf virginUrlForMissingRequest_
HierarchyLogEntry hier
void syncNotes(HttpRequest *request)
~AccessLogEntry() override
class AccessLogEntry::IcapLogEntry icap
class AccessLogEntry::Headers headers
Comm::ConnectionPointer tcpClient
TCP/IP level details about the client connection.
class AccessLogEntry::HttpDetails http
RefCount< AccessLogEntry > Pointer
HttpRequest * adapted_request
HttpRequest * request
class AccessLogEntry::HtcpDetails htcp
const char * getExtUser() const
Fetch the external ACL provided 'user=' string, or nil if none is available.
SBuf lastAclData
string for external_acl_type DATA format code
void setVirginUrlForMissingRequest(const SBuf &vu)
Remember Client URI (or equivalent) when there is no HttpRequest.
const char * getLogClientFqdn(char *buf, size_t bufSize) const
class AccessLogEntry::AdaptationDetails adapt
class AccessLogEntry::IcpDetails icp
NotePairs::Pointer notes
ProxyProtocol::HeaderPointer proxyProtocolHeader
see ConnStateData::proxyProtocolHeader_
const SBuf * effectiveVirginUrl() const
ScopedId codeContextGist() const override
class AccessLogEntry::SslDetails ssl
void updateError(const Error &)
sets (or updates the already stored) transaction error as needed
std::ostream & detailCodeContext(std::ostream &os) const override
appends human-friendly context description line(s) to a cache.log record
a transaction problem
Definition Error.h:27
void setNoAddr()
Definition Address.cc:312
Definition SBuf.h:94
icp_opcode
Definition icp_opcode.h:13
@ ICP_INVALID
Definition icp_opcode.h:15
@ bumpEnd
Definition support.h:132
const char * XactOutcome
transaction result for logging
Definition Elements.h:39
const XactOutcome xoUnknown
initial value: outcome was not set
Definition Elements.cc:18
StatusCode
Definition StatusCode.h:20
@ scNone
Definition StatusCode.h:21