FormatHttpdCombined.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 - Apache combined format */
10 
11 #include "squid.h"
12 #include "AccessLogEntry.h"
13 #include "format/Quoting.h"
14 #include "format/Token.h"
15 #include "globals.h"
16 #include "HttpRequest.h"
17 #include "log/File.h"
18 #include "log/Formats.h"
19 #include "SquidConfig.h"
20 #include "SquidTime.h"
21 
22 void
24 {
25  const char *user_ident = ::Format::QuoteUrlEncodeUsername(al->getClientIdent());
26  const char *user_auth = NULL;
27  const char *referer = NULL;
28  const char *agent = NULL;
29 
30  if (al->request) {
31 #if USE_AUTH
32  if (al->request->auth_user_request != NULL)
34 #endif
37  }
38 
39  if (!referer || *referer == '\0')
40  referer = "-";
41 
42  if (!agent || *agent == '\0')
43  agent = "-";
44 
45  char clientip[MAX_IPSTRLEN];
46  al->getLogClientIp(clientip, MAX_IPSTRLEN);
47 
48  const SBuf method(al->getLogMethod());
49 
50  logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " " SQUIDSBUFPH " %s/%d.%d\" %d %" PRId64 " \"%s\" \"%s\" %s:%s%s",
51  clientip,
52  user_ident ? user_ident : dash_str,
53  user_auth ? user_auth : dash_str,
56  SQUIDSBUFPRINT(al->url),
59  al->http.code,
61  referer,
62  agent,
63  al->cache.code.c_str(),
64  hier_code_str[al->hier.code],
65  (Config.onoff.log_mime_hdrs?"":"\n"));
66 
67  safe_free(user_ident);
68  safe_free(user_auth);
69 
71  char *ereq = ::Format::QuoteMimeBlob(al->headers.request);
72  char *erep = ::Format::QuoteMimeBlob(al->headers.reply);
73  logfilePrintf(logfile, " [%s] [%s]\n", ereq, erep);
74  safe_free(ereq);
75  safe_free(erep);
76  }
77 }
78 
void HttpdCombined(const AccessLogEntryPointer &al, Logfile *logfile)
Log with Apache httpd combined format.
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
#define PRId64
Definition: types.h:110
#define safe_free(x)
Definition: xalloc.h:73
MessageSizes clientReplySz
counters for the response sent to client
char * QuoteMimeBlob(const char *header)
Definition: Quoting.cc:43
SBuf getLogMethod() const
Fetch the transaction method string (ICP opcode, HTCP opcode or HTTP method)
uint64_t messageTotal() const
total message size
Definition: MessageSizes.h:27
time_t squid_curtime
Definition: stub_time.cc:17
unsigned int major
major version number
char * QuoteUrlEncodeUsername(const char *name)
Definition: Quoting.cc:31
const char * c_str() const
compute the status access.log field
Definition: LogTags.cc:47
class AccessLogEntry::Headers headers
HttpRequest * request
class AccessLogEntry::HttpDetails http
int log_mime_hdrs
Definition: SquidConfig.h:282
class AccessLogEntry::CacheDetails cache
struct SquidConfig::@112 onoff
HttpHeader header
Definition: Message.h:74
static FILE * logfile
const char * FormatHttpd(time_t t)
Definition: stub_time.cc:25
char const * username() const
Definition: UserRequest.cc:32
size_t HttpReply *STUB StoreEntry const KeyScope scope const HttpRequestMethod & method
Definition: stub_store.cc:126
Auth::UserRequest::Pointer auth_user_request
Definition: HttpRequest.h:115
const char * ProtocolType_str[]
const char * hier_code_str[]
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
AnyP::ProtocolVersion version
unsigned int minor
minor version number
#define SQUIDSBUFPH
Definition: SBuf.h:32
ProtocolType protocol
which protocol this version is for
#define SQUIDSBUFPRINT(s)
Definition: SBuf.h:33
HierarchyLogEntry hier
class SquidConfig Config
Definition: SquidConfig.cc:12
#define NULL
Definition: types.h:166
const char * getClientIdent() const
Fetch the client IDENT string, or nil if none is available.
const char * dash_str

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors