FormatSquidIcap.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 "fqdncache.h"
18 #include "HttpRequest.h"
19 #include "log/File.h"
20 #include "log/Formats.h"
21 #include "SquidConfig.h"
22 #include "SquidTime.h"
23 
24 void
26 {
27  const char *client = NULL;
28  const char *user = NULL;
29  char tmp[MAX_IPSTRLEN], clientbuf[MAX_IPSTRLEN];
30 
31  if (al->cache.caddr.isAnyAddr()) { // ICAP OPTIONS xactions lack client
32  client = "-";
33  } else {
34  if (Config.onoff.log_fqdn)
36  if (!client)
37  client = al->cache.caddr.toStr(clientbuf, MAX_IPSTRLEN);
38  }
39 
40 #if USE_AUTH
41  if (al->request != NULL && al->request->auth_user_request != NULL)
43 #endif
44 
45  if (!user)
47 
48 #if USE_OPENSSL
49  if (!user)
51 #endif
52 
53  if (!user)
55 
56  if (user && !*user)
57  safe_free(user);
58 
59  logfilePrintf(logfile, "%9ld.%03d %6ld %s %s/%03d %" PRId64 " %s %s %s -/%s -\n",
60  (long int) current_time.tv_sec,
61  (int) current_time.tv_usec / 1000,
62  tvToMsec(al->icap.trTime),
63  client,
64  al->icap.outcome,
65  al->icap.resStatus,
66  al->icap.bytesRead,
68  al->icap.reqUri.termedBuf(),
69  user ? user : "-",
70  al->icap.hostAddr.toStr(tmp, MAX_IPSTRLEN));
71  safe_free(user);
72 }
73 #endif
74 
class AccessLogEntry::IcapLogEntry icap
void logfilePrintf(Logfile *lf, const char *fmt,...)
Definition: File.cc:112
Definition: File.h:38
#define PRId64
Definition: types.h:110
#define safe_free(x)
Definition: xalloc.h:73
const char * methodStr(Method)
Definition: Elements.cc:15
struct timeval current_time
Definition: stub_time.cc:15
String reqUri
ICAP Request-URI.
bool isAnyAddr() const
Definition: Address.cc:163
char * QuoteUrlEncodeUsername(const char *name)
Definition: Quoting.cc:31
void SquidIcap(const AccessLogEntryPointer &al, Logfile *logfile)
Display log details in Squid ICAP format.
char const * termedBuf() const
Definition: SquidString.h:90
const char * getExtUser() const
Fetch the external ACL provided 'user=' string, or nil if none is available.
HttpRequest * request
Adaptation::Icap::XactOutcome outcome
final transaction status
#define FQDN_LOOKUP_IF_MISS
Definition: defines.h:48
Http::StatusCode resStatus
ICAP response status code.
struct timeval trTime
Transaction response time. The timer starts when the ICAP transaction is created and stops when the r...
class AccessLogEntry::CacheDetails cache
struct SquidConfig::@112 onoff
const char * fqdncache_gethostbyaddr(const Ip::Address &addr, int flags)
Definition: fqdncache.cc:482
static FILE * logfile
long int tvToMsec(struct timeval &t)
Convert timeval to milliseconds.
Definition: SquidTime.h:43
char const * username() const
Definition: UserRequest.cc:32
Auth::UserRequest::Pointer auth_user_request
Definition: HttpRequest.h:115
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
Definition: forward.h:23
Ip::Address hostAddr
ICAP server IP address.
char * toStr(char *buf, const unsigned int blen, int force=AF_UNSPEC) const
Definition: Address.cc:810
Adaptation::Icap::ICAP::Method reqMethod
ICAP request method.
class SquidConfig Config
Definition: SquidConfig.cc:12
#define NULL
Definition: types.h:166
const char * getClientIdent() const
Fetch the client IDENT string, or nil if none is available.
int64_t bytesRead
number of bytes read from ICAP server so far

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors