FormatHttpdCombined.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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
21void
23{
24 const char *user_ident = ::Format::QuoteUrlEncodeUsername(al->getClientIdent());
25 const char *user_auth = nullptr;
26 const char *referer = nullptr;
27 const char *agent = nullptr;
28
29 if (al->request) {
30#if USE_AUTH
31 if (al->request->auth_user_request != nullptr)
33#endif
36 }
37
38 if (!referer || *referer == '\0')
39 referer = "-";
40
41 if (!agent || *agent == '\0')
42 agent = "-";
43
44 char clientip[MAX_IPSTRLEN];
45 al->getLogClientIp(clientip, MAX_IPSTRLEN);
46
47 const SBuf method(al->getLogMethod());
48
49 logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " " SQUIDSBUFPH " %s/%d.%d\" %d %" PRId64 " \"%s\" \"%s\" %s:%s%s",
50 clientip,
51 user_ident ? user_ident : dash_str,
52 user_auth ? user_auth : dash_str,
54 SQUIDSBUFPRINT(method),
58 al->http.code,
60 referer,
61 agent,
62 al->cache.code.c_str(),
64 (Config.onoff.log_mime_hdrs?"":"\n"));
65
66 safe_free(user_ident);
67 safe_free(user_auth);
68
70 char *ereq = ::Format::QuoteMimeBlob(al->headers.request);
71 MemBuf mb;
72 mb.init();
73 al->packReplyHeaders(mb);
74 auto erep = ::Format::QuoteMimeBlob(mb.content());
75 logfilePrintf(logfile, " [%s] [%s]\n", ereq, erep);
76 safe_free(ereq);
77 safe_free(erep);
78 }
79}
80
time_t squid_curtime
Definition: stub_libtime.cc:20
#define SQUIDSBUFPH
Definition: SBuf.h:31
#define SQUIDSBUFPRINT(s)
Definition: SBuf.h:32
class SquidConfig Config
Definition: SquidConfig.cc:12
MessageSizes clientReplySz
counters for the response sent to client
AnyP::ProtocolVersion version
void getLogClientIp(char *buf, size_t bufsz) const
SBuf getLogMethod() const
Fetch the transaction method string (ICP opcode, HTCP opcode or HTTP method)
void packReplyHeaders(MemBuf &mb) const
dump all reply headers (for sending or risky logging)
class AccessLogEntry::CacheDetails cache
const char * getClientIdent() const
Fetch the client IDENT string, or nil if none is available.
HierarchyLogEntry hier
class AccessLogEntry::Headers headers
class AccessLogEntry::HttpDetails http
HttpRequest * request
unsigned int major
major version number
ProtocolType protocol
which protocol this version is for
unsigned int minor
minor version number
char const * username() const
Definition: UserRequest.cc:32
const char * getStr(Http::HdrType id) const
Definition: HttpHeader.cc:1160
Auth::UserRequest::Pointer auth_user_request
Definition: HttpRequest.h:127
HttpHeader header
Definition: Message.h:74
const char * c_str() const
compute the status access.log field
Definition: LogTags.cc:66
Definition: File.h:39
Definition: MemBuf.h:24
void init(mb_size_t szInit, mb_size_t szMax)
Definition: MemBuf.cc:93
char * content()
start of the added data
Definition: MemBuf.h:41
uint64_t messageTotal() const
total message size
Definition: MessageSizes.h:27
Definition: SBuf.h:94
struct SquidConfig::@111 onoff
int log_mime_hdrs
Definition: SquidConfig.h:284
static FILE * logfile
const char * dash_str
const char * hier_code_str[]
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
Definition: forward.h:25
void logfilePrintf(Logfile *lf, const char *fmt,...)
Definition: File.cc:114
const char * ProtocolType_str[]
char * QuoteMimeBlob(const char *header)
Definition: Quoting.cc:43
char * QuoteUrlEncodeUsername(const char *name)
Definition: Quoting.cc:31
void HttpdCombined(const AccessLogEntryPointer &al, Logfile *logfile)
Log with Apache httpd combined format.
const char * FormatHttpd(time_t)
Definition: gadgets.cc:116
#define PRId64
Definition: types.h:110
#define safe_free(x)
Definition: xalloc.h:73

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors