AccessLogEntry.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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"
17 #include "http/ProtocolVersion.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 */
36 class HttpReply;
37 class HttpRequest;
38 class CustomLog;
39 
41 {
42 
43 public:
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 
107  } http;
108 
113  {
114  public:
116  } icp;
117 
122  {
123  public:
124  const char *opcode = nullptr;
125  } htcp;
126 
127 #if USE_OPENSSL
128  class SslDetails
130  {
131  public:
132  const char *user = nullptr;
134  } ssl;
135 #endif
136 
143  {
144  public:
146  caddr.setNoAddr();
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
163  } cache;
164 
168  class Headers
169  {
170  public:
171  char *request = nullptr; //< virgin HTTP request headers
172  char *adapted_request = nullptr; //< HTTP request headers after adaptation and redirection
173  } headers;
174 
175 #if USE_ADAPTATION
176 
180  {
181  public:
183  char *last_meta = nullptr;
184  } adapt;
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
209 
213  {
214  public:
216  memset(&trTime, 0, sizeof(trTime));
217  memset(&ioTime, 0, sizeof(ioTime));
218  memset(&processingTime, 0, sizeof(processingTime));
219  }
220 
225  int64_t bytesSent = 0;
226  int64_t bytesRead = 0;
227 
231  int64_t bodyBytesRead = -1;
232  HttpRequest* request = nullptr;
233  HttpReply* reply = nullptr;
234 
236 
240  struct timeval trTime;
246  struct timeval ioTime;
248  struct timeval processingTime;
249  }
250  icap;
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 
272 private:
276 
280 };
281 
282 class ACLChecklist;
283 class StoreEntry;
284 
285 /* Should be in 'AccessLog.h' as the driver */
286 void accessLogLogTo(CustomLog *, const AccessLogEntryPointer &, ACLChecklist *checklist = nullptr);
288 void accessLogRotate(void);
289 void accessLogClose(void);
290 void accessLogInit(void);
291 const char *accessLogTime(time_t);
292 
293 #endif /* SQUID_SRC_ACCESSLOGENTRY_H */
294 
void accessLogClose(void)
Definition: access_log.cc:159
void accessLogInit(void)
Definition: access_log.cc:274
int64_t bytesRead
number of bytes read from ICAP server so far
void accessLogLogTo(CustomLog *, const AccessLogEntryPointer &, ACLChecklist *checklist=nullptr)
Definition: access_log.cc:66
SBuf virginUrlForMissingRequest_
const char * getLogClientFqdn(char *buf, size_t bufSize) const
This subclass holds log info for Squid internal stats TODO: Inner class declarations should be moved ...
@ scNone
Definition: StatusCode.h:21
const Error * error() const
const XactOutcome xoUnknown
initial value: outcome was not set
Definition: Elements.cc:18
void updateError(const Error &)
sets (or updates the already stored) transaction error as needed
String reqUri
ICAP Request-URI.
class AccessLogEntry::HtcpDetails htcp
HttpRequest * request
ICAP request.
HttpReplyPointer reply
Definition: SBuf.h:93
const SBuf * effectiveVirginUrl() const
void setVirginUrlForMissingRequest(const SBuf &vu)
Remember Client URI (or equivalent) when there is no HttpRequest.
class AccessLogEntry::SslDetails ssl
@ bumpEnd
Definition: support.h:132
HierarchyLogEntry hier
This subclass holds log info for HTCP protocol TODO: Inner class declarations should be moved outside...
struct timeval start_time
The time the master transaction started.
struct timeval trTime
The response time.
void accessLogLog(const AccessLogEntryPointer &, ACLChecklist *)
Definition: access_log.cc:136
AnyP::ProtocolVersion version
NotePairs::Pointer notes
StatusCode
Definition: StatusCode.h:20
SBuf lastAclData
string for external_acl_type DATA format code
This subclass holds log info for ICAP part of request TODO: Inner class declarations should be moved ...
class AccessLogEntry::HttpDetails http
class AccessLogEntry::IcpDetails icp
a transaction problem
Definition: Error.h:27
class AccessLogEntry::IcapLogEntry icap
void syncNotes(HttpRequest *request)
HttpRequest * request
@ ICP_INVALID
Definition: icp_opcode.h:15
This subclass holds log info for various headers in raw format TODO: shuffle this to the relevant pro...
char * last_meta
image of the last ICAP response header or eCAP meta received
const char * user
emailAddress from the SSL client certificate
void setNoAddr()
Definition: Address.cc:312
Definition: MemBuf.h:23
Adaptation::Icap::XactOutcome outcome
final transaction status
This subclass holds log info for ICP protocol TODO: Inner class declarations should be moved outside.
Comm::ConnectionPointer tcpClient
TCP/IP level details about the client connection.
int64_t bytesSent
number of bytes sent to ICAP server so far
const char * accessLogTime(time_t)
struct timeval ioTime
Transaction I/O time. The timer starts when the first ICAP request byte is scheduled for sending and ...
logging information specific to the SSL protocol
This subclass holds general adaptation log info. TODO: Inner class declarations should be moved outsi...
class AccessLogEntry::CacheDetails cache
HttpRequestMethod method
MessageSizes clientRequestSz
counters for the original request received from client
HttpReply * reply
ICAP reply.
@ methodNone
Definition: Elements.h:17
class AccessLogEntry::Headers headers
String serviceName
ICAP service name.
class AccessLogEntry::AdaptationDetails adapt
struct timeval trTime
Transaction response time. The timer starts when the ICAP transaction is created and stops when the r...
Security::CertPointer sslClientCert
cert received from the client
std::ostream & detailCodeContext(std::ostream &os) const override
appends human-friendly context description line(s) to a cache.log record
~AccessLogEntry() override
ProxyProtocol::HeaderPointer proxyProtocolHeader
see ConnStateData::proxyProtocolHeader_
const typedef char * XactOutcome
transaction result for logging
Definition: Elements.h:39
HttpRequest * adapted_request
struct timeval processingTime
total ICAP processing time
Http::StatusCode resStatus
ICAP response status code.
MessageSizes clientReplySz
counters for the response sent to client
void getLogClientIp(char *buf, size_t bufsz) const
AnyP::PortCfgPointer port
void accessLogRotate(void)
Definition: access_log.cc:145
This subclass holds log info for HTTP protocol TODO: Inner class declarations should be moved outside...
void packReplyHeaders(MemBuf &mb) const
dump all reply headers (for sending or risky logging)
SBuf lastAclName
string for external_acl_type ACL format code
bool hasLogMethod() const
whether we know what the request method is
ScopedId codeContextGist() const override
int bumpMode
whether and how the request was SslBumped
Ip::Address hostAddr
ICAP server IP address.
icp_opcode
Definition: icp_opcode.h:13
RefCount< AccessLogEntry > Pointer
Adaptation::Icap::ICAP::Method reqMethod
ICAP request method.
const char * getExtUser() const
Fetch the external ACL provided 'user=' string, or nil if none is available.
SBuf getLogMethod() const
Fetch the transaction method string (ICP opcode, HTCP opcode or HTTP method)

 

Introduction

Documentation

Support

Miscellaneous