AccessLogEntry.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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"
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 */
36class HttpReply;
37class HttpRequest;
38class CustomLog;
39
41{
42
43public:
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
61 const char *getLogClientFqdn(char *buf, size_t bufSize) const;
62
64 const char *getClientIdent() const;
65
67 const char *getExtUser() const;
68
70 bool hasLogMethod() const { return icp.opcode || htcp.opcode || http.method; }
71
73 SBuf getLogMethod() const;
74
76
78 void packReplyHeaders(MemBuf &mb) const;
79
81
84 // TCP/IP level details about the server or peer connection
85 // are stored in hier.tcpServer
86
92 {
93
94 public:
96 int code = 0;
97 const char *content_type = nullptr;
99
101 // TODO calculate header and payload better (by parser)
102 // XXX payload encoding overheads not calculated at all yet.
104
106 // TODO calculate header and payload better (by parser)
107 // XXX payload encoding overheads not calculated at all yet.
109
111
116 {
117 public:
120
125 {
126 public:
127 const char *opcode = nullptr;
129
130#if USE_OPENSSL
133 {
134 public:
135 const char *user = nullptr;
138#endif
139
146 {
147 public:
150 memset(&start_time, 0, sizeof(start_time));
151 memset(&trTime, 0, sizeof(start_time));
152 }
153
155 int64_t highOffset = 0;
156 int64_t objectSize = 0;
158 struct timeval start_time;
159 struct timeval trTime;
160 const char *rfc931 = nullptr;
161 const char *extuser = nullptr;
162#if USE_OPENSSL
163 const char *ssluser = nullptr;
165#endif
168
173 {
174 public:
175 char *request = nullptr; //< virgin HTTP request headers
176 char *adapted_request = nullptr; //< HTTP request headers after adaptation and redirection
178
179#if USE_ADAPTATION
184 {
185 public:
187 char *last_meta = nullptr;
189#endif
190
191 const char *lastAclName = nullptr;
193
196 HttpRequest *request = nullptr; //< virgin HTTP request
197 HttpRequest *adapted_request = nullptr; //< HTTP request after adaptation and redirection
198
202
205
206#if ICAP_CLIENT
211 {
212 public:
214 memset(&trTime, 0, sizeof(trTime));
215 memset(&ioTime, 0, sizeof(ioTime));
216 memset(&processingTime, 0, sizeof(processingTime));
217 }
218
223 int64_t bytesSent = 0;
224 int64_t bytesRead = 0;
229 int64_t bodyBytesRead = -1;
230 HttpRequest* request = nullptr;
231 HttpReply* reply = nullptr;
232
238 struct timeval trTime;
244 struct timeval ioTime;
246 struct timeval processingTime;
247 }
249#endif
250
255 const SBuf *effectiveVirginUrl() const;
256
259 {
260 if (!request)
262 }
263
265 const Error *error() const;
266
268 void updateError(const Error &);
269
270private:
274
278};
279
280class ACLChecklist;
281class StoreEntry;
282
283/* Should be in 'AccessLog.h' as the driver */
284void accessLogLogTo(CustomLog *, const AccessLogEntryPointer &, ACLChecklist *checklist = nullptr);
286void accessLogRotate(void);
287void accessLogClose(void);
288void accessLogInit(void);
289const char *accessLogTime(time_t);
290
291#endif /* SQUID_HTTPACCESSLOGENTRY_H */
292
void accessLogInit(void)
Definition: access_log.cc:364
void accessLogClose(void)
Definition: access_log.cc:202
void accessLogLogTo(CustomLog *, const AccessLogEntryPointer &, ACLChecklist *checklist=nullptr)
Definition: access_log.cc:77
void accessLogRotate(void)
Definition: access_log.cc:182
void accessLogLog(const AccessLogEntryPointer &, ACLChecklist *)
Definition: access_log.cc:147
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
HttpRequestMethod method
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 ...
String reqUri
ICAP Request-URI.
String serviceName
ICAP service name.
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.
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
const Error * error() const
void getLogClientIp(char *buf, size_t bufsz) const
HttpReplyPointer reply
virtual ~AccessLogEntry()
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
const char * getClientIdent() const
Fetch the client IDENT string, or nil if none is available.
SBuf virginUrlForMissingRequest_
HierarchyLogEntry hier
void syncNotes(HttpRequest *request)
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 char * lastAclName
string for external_acl_type ACL format code
const SBuf * effectiveVirginUrl() const
virtual ScopedId codeContextGist() const override
class AccessLogEntry::SslDetails ssl
void updateError(const Error &)
sets (or updates the already stored) transaction error as needed
virtual 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:18
void setNoAddr()
Definition: Address.cc:292
Definition: MemBuf.h:24
Definition: SBuf.h:94
icp_opcode
Definition: icp_opcode.h:13
@ ICP_INVALID
Definition: icp_opcode.h:15
@ bumpEnd
Definition: support.h:126
const char * XactOutcome
transaction result for logging
Definition: Elements.h:39
const XactOutcome xoUnknown
initial value: outcome was not set
Definition: Elements.cc:18
@ methodNone
Definition: Elements.h:17
StatusCode
Definition: StatusCode.h:20
@ scNone
Definition: StatusCode.h:21

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors