]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/log/FormatHttpdCommon.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 common 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::HttpdCommon(const AccessLogEntry::Pointer
&al
, Logfile
* logfile
)
25 const char *user_auth
= NULL
;
27 if (al
->request
&& al
->request
->auth_user_request
!= NULL
)
28 user_auth
= ::Format::QuoteUrlEncodeUsername(al
->request
->auth_user_request
->username());
30 const char *user_ident
= ::Format::QuoteUrlEncodeUsername(al
->cache
.rfc931
);
32 char clientip
[MAX_IPSTRLEN
];
33 al
->getLogClientIp(clientip
, MAX_IPSTRLEN
);
36 if (al
->_private
.method_str
)
37 method
.assign(al
->_private
.method_str
);
39 method
= al
->http
.method
.image();
41 logfilePrintf(logfile
, "%s %s %s [%s] \"" SQUIDSBUFPH
" %s %s/%d.%d\" %d %" PRId64
" %s:%s%s",
43 user_ident
? user_ident
: dash_str
,
44 user_auth
? user_auth
: dash_str
,
45 Time::FormatHttpd(squid_curtime
),
46 SQUIDSBUFPRINT(method
),
48 AnyP::ProtocolType_str
[al
->http
.version
.protocol
],
49 al
->http
.version
.major
, al
->http
.version
.minor
,
51 al
->http
.clientReplySz
.messageTotal(),
52 al
->cache
.code
.c_str(),
53 hier_code_str
[al
->hier
.code
],
54 (Config
.onoff
.log_mime_hdrs
?"":"\n"));
57 safe_free(user_ident
);
59 if (Config
.onoff
.log_mime_hdrs
) {
60 char *ereq
= ::Format::QuoteMimeBlob(al
->headers
.request
);
61 char *erep
= ::Format::QuoteMimeBlob(al
->headers
.reply
);
62 logfilePrintf(logfile
, " [%s] [%s]\n", ereq
, erep
);