]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 1996-2025 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 | |
23 | Log::Format::SquidIcap(const AccessLogEntry::Pointer &al, Logfile * logfile) | |
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) | |
32 | user = ::Format::QuoteUrlEncodeUsername(al->request->auth_user_request->username()); | |
33 | #endif | |
34 | ||
35 | if (!user) | |
36 | user = ::Format::QuoteUrlEncodeUsername(al->getExtUser()); | |
37 | ||
38 | #if USE_OPENSSL | |
39 | if (!user) | |
40 | user = ::Format::QuoteUrlEncodeUsername(al->cache.ssluser); | |
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, | |
54 | Adaptation::Icap::ICAP::methodStr(al->icap.reqMethod), | |
55 | al->icap.reqUri.termedBuf(), | |
56 | user ? user : "-", | |
57 | al->icap.hostAddr.toStr(tmp, MAX_IPSTRLEN)); | |
58 | safe_free(user); | |
59 | } | |
60 | #endif | |
61 |