Squid Web Cache
master
Loading...
Searching...
No Matches
FormatSquidReferer.cc
Go to the documentation of this file.
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 referer 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::SquidReferer
(
const
AccessLogEntry::Pointer
&al,
Logfile
*logfile)
19
{
20
const
char
*referer =
nullptr
;
21
if
(al->
request
)
22
referer = al->
request
->
header
.
getStr
(
Http::HdrType::REFERER
);
23
24
if
(!referer || *referer ==
'\0'
)
25
referer =
"-"
;
26
27
char
clientip[
MAX_IPSTRLEN
];
28
al->
getLogClientIp
(clientip,
MAX_IPSTRLEN
);
29
30
const
SBuf
url = !al->
url
.
isEmpty
() ? al->
url
:
::Format::Dash
;
31
32
logfilePrintf
(logfile,
"%9ld.%03d %s %s "
SQUIDSBUFPH
"\n"
,
33
(
long
int
)
current_time
.tv_sec,
34
(
int
)
current_time
.tv_usec / 1000,
35
clientip,
36
referer,
37
SQUIDSBUFPRINT
(url));
38
}
39
AccessLogEntry.h
Formats.h
HttpRequest.h
SQUIDSBUFPH
#define SQUIDSBUFPH
Definition
SBuf.h:31
SQUIDSBUFPRINT
#define SQUIDSBUFPRINT(s)
Definition
SBuf.h:32
AccessLogEntry::getLogClientIp
void getLogClientIp(char *buf, size_t bufsz) const
Definition
AccessLogEntry.cc:20
AccessLogEntry::url
SBuf url
Definition
AccessLogEntry.h:77
AccessLogEntry::request
HttpRequest * request
Definition
AccessLogEntry.h:192
HttpHeader::getStr
const char * getStr(Http::HdrType id) const
Definition
HttpHeader.cc:1296
Http::Message::header
HttpHeader header
Definition
Message.h:74
Logfile
Definition
File.h:39
RefCount< AccessLogEntry >
SBuf
Definition
SBuf.h:94
SBuf::isEmpty
bool isEmpty() const
Definition
SBuf.h:435
MAX_IPSTRLEN
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
Definition
forward.h:25
logfilePrintf
void logfilePrintf(Logfile *lf, const char *fmt,...)
Definition
File.cc:114
File.h
Format::Dash
const SBuf Dash
Http::REFERER
@ REFERER
Definition
RegisteredHeaders.h:87
Log::Format::SquidReferer
void SquidReferer(const AccessLogEntryPointer &al, Logfile *logfile)
Display log details in Squid old refererlog format.
Definition
FormatSquidReferer.cc:18
squid.h
current_time
struct timeval current_time
the current UNIX time in timeval {seconds, microseconds} format
Definition
gadgets.cc:18
squid
src
log
FormatSquidReferer.cc
Generated by
1.9.8