AccessLogEntry.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2021 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_HTTPACCESSLOGENTRY_H
10 #define SQUID_HTTPACCESSLOGENTRY_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/SBuf.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  virtual ~AccessLogEntry();
48 
49  /* CodeContext API */
50  virtual std::ostream &detailCodeContext(std::ostream &os) const override;
51  virtual ScopedId codeContextGist() const override;
52 
56  void getLogClientIp(char *buf, size_t bufsz) const;
57 
59  const char *getClientIdent() const;
60 
62  const char *getExtUser() const;
63 
65  bool hasLogMethod() const { return icp.opcode || htcp.opcode || http.method; }
66 
68  SBuf getLogMethod() const;
69 
71 
73  void packReplyHeaders(MemBuf &mb) const;
74 
76 
79  // TCP/IP level details about the server or peer connection
80  // are stored in hier.tcpServer
81 
87  {
88 
89  public:
91  int code = 0;
92  const char *content_type = nullptr;
94 
96  // TODO calculate header and payload better (by parser)
97  // XXX payload encoding overheads not calculated at all yet.
99 
101  // TODO calculate header and payload better (by parser)
102  // XXX payload encoding overheads not calculated at all yet.
104 
105  } http;
106 
111  {
112  public:
114  } icp;
115 
120  {
121  public:
122  const char *opcode = nullptr;
123  } htcp;
124 
125 #if USE_OPENSSL
126  class SslDetails
128  {
129  public:
130  const char *user = nullptr;
132  } ssl;
133 #endif
134 
141  {
142  public:
144  caddr.setNoAddr();
145  memset(&start_time, 0, sizeof(start_time));
146  memset(&trTime, 0, sizeof(start_time));
147  }
148 
150  int64_t highOffset = 0;
151  int64_t objectSize = 0;
153  struct timeval start_time;
154  struct timeval trTime;
155  const char *rfc931 = nullptr;
156  const char *extuser = nullptr;
157 #if USE_OPENSSL
158  const char *ssluser = nullptr;
160 #endif
162  } cache;
163 
167  class Headers
168  {
169  public:
170  char *request = nullptr; //< virgin HTTP request headers
171  char *adapted_request = nullptr; //< HTTP request headers after adaptation and redirection
173 
174 #if USE_ADAPTATION
175 
179  {
180  public:
182  char *last_meta = nullptr;
183  } adapt;
184 #endif
185 
186  const char *lastAclName = nullptr;
188 
191  HttpRequest *request = nullptr; //< virgin HTTP request
192  HttpRequest *adapted_request = nullptr; //< HTTP request after adaptation and redirection
193 
197 
200 
201 #if ICAP_CLIENT
202 
206  {
207  public:
209  memset(&trTime, 0, sizeof(trTime));
210  memset(&ioTime, 0, sizeof(ioTime));
211  memset(&processingTime, 0, sizeof(processingTime));
212  }
213 
218  int64_t bytesSent = 0;
219  int64_t bytesRead = 0;
220 
224  int64_t bodyBytesRead = -1;
225  HttpRequest* request = nullptr;
226  HttpReply* reply = nullptr;
227 
229 
233  struct timeval trTime;
239  struct timeval ioTime;
241  struct timeval processingTime;
242  }
244 #endif
245 
250  const SBuf *effectiveVirginUrl() const;
251 
254  {
255  if (!request)
257  }
258 
260  const Error *error() const;
261 
263  void updateError(const Error &);
264 
265 private:
269 
273 };
274 
275 class ACLChecklist;
276 class StoreEntry;
277 
278 /* Should be in 'AccessLog.h' as the driver */
279 void accessLogLogTo(CustomLog *, const AccessLogEntryPointer &, ACLChecklist *checklist = nullptr);
281 void accessLogRotate(void);
282 void accessLogClose(void);
283 void accessLogInit(void);
284 const char *accessLogTime(time_t);
285 
286 #endif /* SQUID_HTTPACCESSLOGENTRY_H */
287 
void accessLogClose(void)
Definition: access_log.cc:203
const char * getClientIdent() const
Fetch the client IDENT string, or nil if none is available.
void accessLogInit(void)
Definition: access_log.cc:365
int64_t bytesRead
number of bytes read from ICAP server so far
void accessLogLogTo(CustomLog *, const AccessLogEntryPointer &, ACLChecklist *checklist=nullptr)
Definition: access_log.cc:78
SBuf virginUrlForMissingRequest_
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:87
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:126
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:148
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:18
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:292
Definition: MemBuf.h:24
Adaptation::Icap::XactOutcome outcome
final transaction status
const char * lastAclName
string for external_acl_type ACL format code
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 ...
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...
virtual ~AccessLogEntry()
Security::CertPointer sslClientCert
cert received from the client
virtual std::ostream & detailCodeContext(std::ostream &os) const override
appends human-friendly context description line(s) to a cache.log record
ProxyProtocol::HeaderPointer proxyProtocolHeader
see ConnStateData::proxyProtocolHeader_
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:183
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)
bool hasLogMethod() const
whether we know what the request method is
virtual 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.
const char * XactOutcome
transaction result for logging
Definition: Elements.h:39
SBuf getLogMethod() const
Fetch the transaction method string (ICP opcode, HTCP opcode or HTTP method)

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors