]>
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 useragent format */ | |
10 | ||
11 | #include "squid.h" | |
12 | #include "AccessLogEntry.h" | |
13 | #include "HttpRequest.h" | |
14 | #include "log/File.h" | |
15 | #include "log/Formats.h" | |
16 | ||
17 | void | |
18 | Log::Format::SquidUserAgent(const AccessLogEntry::Pointer &al, Logfile * logfile) | |
19 | { | |
20 | const char *agent = nullptr; | |
21 | ||
22 | if (al->request) | |
23 | agent = al->request->header.getStr(Http::HdrType::USER_AGENT); | |
24 | ||
25 | if (!agent || *agent == '\0') | |
26 | agent = "-"; | |
27 | ||
28 | char clientip[MAX_IPSTRLEN]; | |
29 | al->getLogClientIp(clientip, MAX_IPSTRLEN); | |
30 | ||
31 | logfilePrintf(logfile, "%s [%s] \"%s\"\n", | |
32 | clientip, | |
33 | Time::FormatHttpd(squid_curtime), | |
34 | agent); | |
35 | } | |
36 |