FormatSquidReferer.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 #include "SquidTime.h"
17 
18 void
20 {
21  const char *referer = NULL;
22  if (al->request)
24 
25  if (!referer || *referer == '\0')
26  referer = "-";
27 
28  char clientip[MAX_IPSTRLEN];
29  al->getLogClientIp(clientip, MAX_IPSTRLEN);
30 
31  const SBuf url = !al->url.isEmpty() ? al->url : ::Format::Dash;
32 
33  logfilePrintf(logfile, "%9ld.%03d %s %s " SQUIDSBUFPH "\n",
34  (long int) current_time.tv_sec,
35  (int) current_time.tv_usec / 1000,
36  clientip,
37  referer,
38  SQUIDSBUFPRINT(url));
39 }
40 
void logfilePrintf(Logfile *lf, const char *fmt,...)
Definition: File.cc:112
Definition: File.h:38
Definition: SBuf.h:87
void getLogClientIp(char *buf, size_t bufsz) const
bool isEmpty() const
Definition: SBuf.h:422
struct timeval current_time
Definition: stub_time.cc:15
void SquidReferer(const AccessLogEntryPointer &al, Logfile *logfile)
Display log details in Squid old refererlog format.
HttpRequest * request
HttpHeader header
Definition: Message.h:74
static FILE * logfile
const char * getStr(Http::HdrType id) const
Definition: HttpHeader.cc:1203
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
Definition: forward.h:23
#define SQUIDSBUFPH
Definition: SBuf.h:32
#define SQUIDSBUFPRINT(s)
Definition: SBuf.h:33
const SBuf Dash
#define NULL
Definition: types.h:166

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors