]>
Commit | Line | Data |
---|---|---|
fd2c5549 | 1 | /* |
f6e9a3ee | 2 | * Copyright (C) 1996-2019 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 referer 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" |
0268f798 | 16 | #include "SquidTime.h" |
17 | ||
fd2c5549 | 18 | void |
41ebd397 | 19 | Log::Format::SquidReferer(const AccessLogEntry::Pointer &al, Logfile *logfile) |
fd2c5549 | 20 | { |
e24fa1c7 | 21 | const char *referer = NULL; |
41ebd397 | 22 | if (al->request) |
789217a2 | 23 | referer = al->request->header.getStr(Http::HdrType::REFERER); |
db543dc9 | 24 | |
20efa1c2 | 25 | if (!referer || *referer == '\0') |
e24fa1c7 | 26 | referer = "-"; |
fd2c5549 | 27 | |
20efa1c2 | 28 | char clientip[MAX_IPSTRLEN]; |
d4204018 | 29 | al->getLogClientIp(clientip, MAX_IPSTRLEN); |
62e76326 | 30 | |
f57ae909 NH |
31 | const SBuf url = !al->url.isEmpty() ? al->url : ::Format::Dash; |
32 | ||
33 | logfilePrintf(logfile, "%9ld.%03d %s %s " SQUIDSBUFPH "\n", | |
20efa1c2 | 34 | (long int) current_time.tv_sec, |
62e76326 | 35 | (int) current_time.tv_usec / 1000, |
d4204018 | 36 | clientip, |
62e76326 | 37 | referer, |
f57ae909 | 38 | SQUIDSBUFPRINT(url)); |
c9b99797 | 39 | } |
f53969cc | 40 |