]> git.ipfire.org Git - thirdparty/squid.git/blame - src/log/FormatSquidUseragent.cc
mkrelease: allow two digits for minor release numbers (#1837)
[thirdparty/squid.git] / src / log / FormatSquidUseragent.cc
CommitLineData
b012353a 1/*
b8ae064d 2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
e25c139f 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.
b012353a 7 */
8
bbc27441
AJ
9/* DEBUG: section 46 Access Log - Squid useragent format */
10
f7f3304a 11#include "squid.h"
20efa1c2
AJ
12#include "AccessLogEntry.h"
13#include "HttpRequest.h"
82b7abe3 14#include "log/File.h"
20efa1c2 15#include "log/Formats.h"
b012353a 16
b012353a 17void
41ebd397 18Log::Format::SquidUserAgent(const AccessLogEntry::Pointer &al, Logfile * logfile)
b012353a 19{
aee3523a 20 const char *agent = nullptr;
db543dc9 21
41ebd397 22 if (al->request)
789217a2 23 agent = al->request->header.getStr(Http::HdrType::USER_AGENT);
62e76326 24
20efa1c2 25 if (!agent || *agent == '\0')
e24fa1c7 26 agent = "-";
62e76326 27
d4204018
AJ
28 char clientip[MAX_IPSTRLEN];
29 al->getLogClientIp(clientip, MAX_IPSTRLEN);
30
20efa1c2 31 logfilePrintf(logfile, "%s [%s] \"%s\"\n",
d4204018 32 clientip,
20efa1c2 33 Time::FormatHttpd(squid_curtime),
62e76326 34 agent);
5b824235 35}
f53969cc 36