]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/log/FormatSquidIcap.cc
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
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.
9 /* DEBUG: section 46 Access Log - Squid ICAP Logging */
15 #include "AccessLogEntry.h"
16 #include "format/Quoting.h"
17 #include "fqdncache.h"
18 #include "HttpRequest.h"
20 #include "log/Formats.h"
21 #include "SquidConfig.h"
22 #include "SquidTime.h"
25 Log::Format::SquidIcap(const AccessLogEntry::Pointer
&al
, Logfile
* logfile
)
27 const char *client
= NULL
;
28 const char *user
= NULL
;
29 char tmp
[MAX_IPSTRLEN
], clientbuf
[MAX_IPSTRLEN
];
31 if (al
->cache
.caddr
.isAnyAddr()) { // ICAP OPTIONS xactions lack client
34 if (Config
.onoff
.log_fqdn
)
35 client
= fqdncache_gethostbyaddr(al
->cache
.caddr
, FQDN_LOOKUP_IF_MISS
);
37 client
= al
->cache
.caddr
.toStr(clientbuf
, MAX_IPSTRLEN
);
41 if (al
->request
!= NULL
&& al
->request
->auth_user_request
!= NULL
)
42 user
= ::Format::QuoteUrlEncodeUsername(al
->request
->auth_user_request
->username());
46 user
= ::Format::QuoteUrlEncodeUsername(al
->cache
.extuser
);
50 user
= ::Format::QuoteUrlEncodeUsername(al
->cache
.ssluser
);
54 user
= ::Format::QuoteUrlEncodeUsername(al
->cache
.rfc931
);
59 logfilePrintf(logfile
, "%9ld.%03d %6d %s %s/%03d %" PRId64
" %s %s %s -/%s -\n",
60 (long int) current_time
.tv_sec
,
61 (int) current_time
.tv_usec
/ 1000,
67 Adaptation::Icap::ICAP::methodStr(al
->icap
.reqMethod
),
68 al
->icap
.reqUri
.termedBuf(),
70 al
->icap
.hostAddr
.toStr(tmp
, MAX_IPSTRLEN
));