]> git.ipfire.org Git - thirdparty/squid.git/blame - src/log/FormatSquidUseragent.cc
Renamed http_hdr_type to Http::HdrType, fixed some HdrType-int implicit conversions
[thirdparty/squid.git] / src / log / FormatSquidUseragent.cc
CommitLineData
b012353a 1/*
bde978a6 2 * Copyright (C) 1996-2015 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"
a4452e04 16#include "SquidTime.h"
b012353a 17
b012353a 18void
41ebd397 19Log::Format::SquidUserAgent(const AccessLogEntry::Pointer &al, Logfile * logfile)
b012353a 20{
e24fa1c7 21 const char *agent = NULL;
db543dc9 22
41ebd397 23 if (al->request)
789217a2 24 agent = al->request->header.getStr(Http::HdrType::USER_AGENT);
62e76326 25
20efa1c2 26 if (!agent || *agent == '\0')
e24fa1c7 27 agent = "-";
62e76326 28
d4204018
AJ
29 char clientip[MAX_IPSTRLEN];
30 al->getLogClientIp(clientip, MAX_IPSTRLEN);
31
20efa1c2 32 logfilePrintf(logfile, "%s [%s] \"%s\"\n",
d4204018 33 clientip,
20efa1c2 34 Time::FormatHttpd(squid_curtime),
62e76326 35 agent);
5b824235 36}
f53969cc 37