FormatSquidIcap.cc
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 /* DEBUG: section 46 Access Log - Squid ICAP Logging */
10 
11 #include "squid.h"
12 
13 #if ICAP_CLIENT
14 
15 #include "AccessLogEntry.h"
16 #include "format/Quoting.h"
17 #include "HttpRequest.h"
18 #include "log/File.h"
19 #include "log/Formats.h"
20 #include "SquidConfig.h"
21 
22 void
24 {
25  const char *user = nullptr;
26  char tmp[MAX_IPSTRLEN], clientbuf[MAX_IPSTRLEN];
27 
28  const auto client = al->getLogClientFqdn(clientbuf, sizeof(clientbuf));
29 
30 #if USE_AUTH
31  if (al->request != nullptr && al->request->auth_user_request != nullptr)
33 #endif
34 
35  if (!user)
37 
38 #if USE_OPENSSL
39  if (!user)
41 #endif
42 
43  if (user && !*user)
44  safe_free(user);
45 
46  logfilePrintf(logfile, "%9ld.%03d %6ld %s %s/%03d %" PRId64 " %s %s %s -/%s -\n",
47  (long int) current_time.tv_sec,
48  (int) current_time.tv_usec / 1000,
49  tvToMsec(al->icap.trTime),
50  client,
51  al->icap.outcome,
52  al->icap.resStatus,
53  al->icap.bytesRead,
55  al->icap.reqUri.termedBuf(),
56  user ? user : "-",
57  al->icap.hostAddr.toStr(tmp, MAX_IPSTRLEN));
58  safe_free(user);
59 }
60 #endif
61 
int64_t bytesRead
number of bytes read from ICAP server so far
void SquidIcap(const AccessLogEntryPointer &al, Logfile *logfile)
Display log details in Squid ICAP format.
const char * getLogClientFqdn(char *buf, size_t bufSize) const
String reqUri
ICAP Request-URI.
Auth::UserRequest::Pointer auth_user_request
Definition: HttpRequest.h:127
char * QuoteUrlEncodeUsername(const char *name)
Definition: Quoting.cc:31
char * toStr(char *buf, const unsigned int blen, int force=AF_UNSPEC) const
Definition: Address.cc:812
void logfilePrintf(Logfile *lf, const char *fmt,...)
Definition: File.cc:114
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
Definition: forward.h:25
class AccessLogEntry::IcapLogEntry icap
HttpRequest * request
struct timeval current_time
the current UNIX time in timeval {seconds, microseconds} format
Definition: gadgets.cc:18
const char * username() const
Definition: UserRequest.cc:32
Adaptation::Icap::XactOutcome outcome
final transaction status
#define safe_free(x)
Definition: xalloc.h:73
class AccessLogEntry::CacheDetails cache
const char * methodStr(Method)
Definition: Elements.cc:15
Definition: File.h:38
struct timeval trTime
Transaction response time. The timer starts when the ICAP transaction is created and stops when the r...
const char * termedBuf() const
Definition: SquidString.h:92
Http::StatusCode resStatus
ICAP response status code.
#define PRId64
Definition: types.h:104
long int tvToMsec(struct timeval &t)
Definition: gadgets.h:93
Ip::Address hostAddr
ICAP server IP address.
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.

 

Introduction

Documentation

Support

Miscellaneous