]>
| Commit | Line | Data |
|---|---|---|
| fd2c5549 | 1 | /* |
| 1f7b830e | 2 | * Copyright (C) 1996-2025 The Squid Software Foundation and contributors |
| fd2c5549 | 3 | * |
| bbc27441 AJ |
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. | |
| fd2c5549 | 7 | */ |
| 8 | ||
| bbc27441 AJ |
9 | /* DEBUG: section 46 Access Log - Squid ICAP Logging */ |
| 10 | ||
| f7f3304a | 11 | #include "squid.h" |
| 20efa1c2 AJ |
12 | |
| 13 | #if ICAP_CLIENT | |
| 14 | ||
| 15 | #include "AccessLogEntry.h" | |
| 38e16f92 | 16 | #include "format/Quoting.h" |
| 20efa1c2 | 17 | #include "HttpRequest.h" |
| 82b7abe3 | 18 | #include "log/File.h" |
| 20efa1c2 | 19 | #include "log/Formats.h" |
| 4d5904f7 | 20 | #include "SquidConfig.h" |
| 0268f798 | 21 | |
| fd2c5549 | 22 | void |
| 41ebd397 | 23 | Log::Format::SquidIcap(const AccessLogEntry::Pointer &al, Logfile * logfile) |
| fd2c5549 | 24 | { |
| aee3523a | 25 | const char *user = nullptr; |
| 20efa1c2 AJ |
26 | char tmp[MAX_IPSTRLEN], clientbuf[MAX_IPSTRLEN]; |
| 27 | ||
| a8c7a110 | 28 | const auto client = al->getLogClientFqdn(clientbuf, sizeof(clientbuf)); |
| 62e76326 | 29 | |
| c0e8c76f | 30 | #if USE_AUTH |
| aee3523a | 31 | if (al->request != nullptr && al->request->auth_user_request != nullptr) |
| c0e8c76f AJ |
32 | user = ::Format::QuoteUrlEncodeUsername(al->request->auth_user_request->username()); |
| 33 | #endif | |
| 62e76326 | 34 | |
| 20efa1c2 | 35 | if (!user) |
| e3bf07f5 | 36 | user = ::Format::QuoteUrlEncodeUsername(al->getExtUser()); |
| 62e76326 | 37 | |
| cb4f4424 | 38 | #if USE_OPENSSL |
| 20efa1c2 | 39 | if (!user) |
| 38e16f92 | 40 | user = ::Format::QuoteUrlEncodeUsername(al->cache.ssluser); |
| fd2c5549 | 41 | #endif |
| fd2c5549 | 42 | |
| 20efa1c2 AJ |
43 | if (user && !*user) |
| 44 | safe_free(user); | |
| 62e76326 | 45 | |
| 01bd87d8 | 46 | logfilePrintf(logfile, "%9ld.%03d %6ld %s %s/%03d %" PRId64 " %s %s %s -/%s -\n", |
| 20efa1c2 | 47 | (long int) current_time.tv_sec, |
| 62e76326 | 48 | (int) current_time.tv_usec / 1000, |
| 01bd87d8 | 49 | tvToMsec(al->icap.trTime), |
| 62e76326 | 50 | client, |
| f5f9e44c | 51 | al->icap.outcome, |
| 20efa1c2 AJ |
52 | al->icap.resStatus, |
| 53 | al->icap.bytesRead, | |
| 54 | Adaptation::Icap::ICAP::methodStr(al->icap.reqMethod), | |
| 55 | al->icap.reqUri.termedBuf(), | |
| 56 | user ? user : "-", | |
| 4dd643d5 | 57 | al->icap.hostAddr.toStr(tmp, MAX_IPSTRLEN)); |
| 20efa1c2 | 58 | safe_free(user); |
| fd2c5549 | 59 | } |
| c9b99797 | 60 | #endif |
| f53969cc | 61 |