]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/log/FormatHttpdCombined.cc
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
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.
9 /* DEBUG: section 46 Access Log - Apache combined format */
12 #include "AccessLogEntry.h"
13 #include "format/Quoting.h"
14 #include "format/Token.h"
16 #include "HttpRequest.h"
18 #include "log/Formats.h"
19 #include "SquidConfig.h"
20 #include "SquidTime.h"
23 Log::Format::HttpdCombined(const AccessLogEntry::Pointer
&al
, Logfile
* logfile
)
25 const char *user_ident
= ::Format::QuoteUrlEncodeUsername(al
->cache
.rfc931
);
26 const char *user_auth
= NULL
;
27 const char *referer
= NULL
;
28 const char *agent
= NULL
;
32 if (al
->request
->auth_user_request
!= NULL
)
33 user_auth
= ::Format::QuoteUrlEncodeUsername(al
->request
->auth_user_request
->username());
35 referer
= al
->request
->header
.getStr(Http::HdrType::REFERER
);
36 agent
= al
->request
->header
.getStr(Http::HdrType::USER_AGENT
);
39 if (!referer
|| *referer
== '\0')
42 if (!agent
|| *agent
== '\0')
45 char clientip
[MAX_IPSTRLEN
];
46 al
->getLogClientIp(clientip
, MAX_IPSTRLEN
);
49 if (al
->_private
.method_str
)
50 method
.assign(al
->_private
.method_str
);
52 method
= al
->http
.method
.image();
54 logfilePrintf(logfile
, "%s %s %s [%s] \"" SQUIDSBUFPH
" %s %s/%d.%d\" %d %" PRId64
" \"%s\" \"%s\" %s:%s%s",
56 user_ident
? user_ident
: dash_str
,
57 user_auth
? user_auth
: dash_str
,
58 Time::FormatHttpd(squid_curtime
),
59 SQUIDSBUFPRINT(method
),
61 AnyP::ProtocolType_str
[al
->http
.version
.protocol
],
62 al
->http
.version
.major
, al
->http
.version
.minor
,
64 al
->http
.clientReplySz
.messageTotal(),
67 al
->cache
.code
.c_str(),
68 hier_code_str
[al
->hier
.code
],
69 (Config
.onoff
.log_mime_hdrs
?"":"\n"));
71 safe_free(user_ident
);
74 if (Config
.onoff
.log_mime_hdrs
) {
75 char *ereq
= ::Format::QuoteMimeBlob(al
->headers
.request
);
76 char *erep
= ::Format::QuoteMimeBlob(al
->headers
.reply
);
77 logfilePrintf(logfile
, " [%s] [%s]\n", ereq
, erep
);