]>
Commit | Line | Data |
---|---|---|
20efa1c2 | 1 | /* |
bbc27441 | 2 | * Copyright (C) 1996-2014 The Squid Software Foundation and contributors |
20efa1c2 | 3 | * |
bbc27441 AJ |
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. | |
20efa1c2 AJ |
7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 46 Access Log - Apache combined format */ |
10 | ||
f7f3304a | 11 | #include "squid.h" |
20efa1c2 | 12 | #include "AccessLogEntry.h" |
38e16f92 | 13 | #include "format/Quoting.h" |
602d9612 | 14 | #include "format/Token.h" |
582c2af2 | 15 | #include "globals.h" |
20efa1c2 AJ |
16 | #include "HttpRequest.h" |
17 | #include "log/File.h" | |
18 | #include "log/Formats.h" | |
4d5904f7 | 19 | #include "SquidConfig.h" |
20efa1c2 AJ |
20 | #include "SquidTime.h" |
21 | ||
22 | void | |
41ebd397 | 23 | Log::Format::HttpdCombined(const AccessLogEntry::Pointer &al, Logfile * logfile) |
20efa1c2 | 24 | { |
38e16f92 | 25 | const char *user_ident = ::Format::QuoteUrlEncodeUsername(al->cache.rfc931); |
c0e8c76f | 26 | const char *user_auth = NULL; |
773003d3 AJ |
27 | const char *referer = NULL; |
28 | const char *agent = NULL; | |
29 | ||
41ebd397 | 30 | if (al->request) { |
c0e8c76f AJ |
31 | #if USE_AUTH |
32 | if (al->request->auth_user_request != NULL) | |
33 | user_auth = ::Format::QuoteUrlEncodeUsername(al->request->auth_user_request->username()); | |
34 | #endif | |
773003d3 AJ |
35 | referer = al->request->header.getStr(HDR_REFERER); |
36 | agent = al->request->header.getStr(HDR_USER_AGENT); | |
37 | } | |
38 | ||
20efa1c2 AJ |
39 | if (!referer || *referer == '\0') |
40 | referer = "-"; | |
41 | ||
20efa1c2 AJ |
42 | if (!agent || *agent == '\0') |
43 | agent = "-"; | |
44 | ||
d4204018 AJ |
45 | char clientip[MAX_IPSTRLEN]; |
46 | al->getLogClientIp(clientip, MAX_IPSTRLEN); | |
47 | ||
7f06a3d8 AJ |
48 | static SBuf method; |
49 | if (al->_private.method_str) | |
50 | method.assign(al->_private.method_str); | |
51 | else | |
52 | method = al->http.method.image(); | |
53 | ||
54 | logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " \"%s\" \"%s\" %s%s:%s%s", | |
d4204018 | 55 | clientip, |
20efa1c2 AJ |
56 | user_ident ? user_ident : dash_str, |
57 | user_auth ? user_auth : dash_str, | |
58 | Time::FormatHttpd(squid_curtime), | |
7f06a3d8 | 59 | SQUIDSBUFPRINT(method), |
20efa1c2 | 60 | al->url, |
c9fd01b4 | 61 | AnyP::ProtocolType_str[al->http.version.protocol], |
20efa1c2 AJ |
62 | al->http.version.major, al->http.version.minor, |
63 | al->http.code, | |
cc0ca3b9 | 64 | al->http.clientReplySz.messageTotal(), |
20efa1c2 AJ |
65 | referer, |
66 | agent, | |
02c8dde5 | 67 | LogTags_str[al->cache.code], |
20efa1c2 AJ |
68 | al->http.statusSfx(), |
69 | hier_code_str[al->hier.code], | |
70 | (Config.onoff.log_mime_hdrs?"":"\n")); | |
71 | ||
72 | safe_free(user_ident); | |
73 | safe_free(user_auth); | |
74 | ||
75 | if (Config.onoff.log_mime_hdrs) { | |
38e16f92 AJ |
76 | char *ereq = ::Format::QuoteMimeBlob(al->headers.request); |
77 | char *erep = ::Format::QuoteMimeBlob(al->headers.reply); | |
20efa1c2 AJ |
78 | logfilePrintf(logfile, " [%s] [%s]\n", ereq, erep); |
79 | safe_free(ereq); | |
80 | safe_free(erep); | |
81 | } | |
82 | } | |
f53969cc | 83 |