]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/log/FormatHttpdCombined.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / log / FormatHttpdCombined.cc
index 50fb3d646ab8ca3b3a565467a80c60e9f0bbb1f6..b63dc62132b7e15a8a82779e750627837a965230 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * DEBUG: section 46    Access Log - Apache combined format
  * AUTHOR: Amos Jeffries
  *
  *
  */
 
-#include "config.h"
+#include "squid.h"
 #include "AccessLogEntry.h"
-#include "format/Token.h"
 #include "format/Quoting.h"
+#include "format/Token.h"
+#include "globals.h"
 #include "HttpRequest.h"
 #include "log/File.h"
 #include "log/Formats.h"
+#include "SquidConfig.h"
 #include "SquidTime.h"
 
 void
-Log::Format::HttpdCombined(AccessLogEntry * al, Logfile * logfile)
+Log::Format::HttpdCombined(const AccessLogEntry::Pointer &al, Logfile * logfile)
 {
     const char *user_ident = ::Format::QuoteUrlEncodeUsername(al->cache.rfc931);
+    const char *user_auth = NULL;
+    const char *referer = NULL;
+    const char *agent = NULL;
 
-    const char *user_auth = ::Format::QuoteUrlEncodeUsername(al->cache.authuser);
+    if (al->request) {
+#if USE_AUTH
+        if (al->request->auth_user_request != NULL)
+            user_auth = ::Format::QuoteUrlEncodeUsername(al->request->auth_user_request->username());
+#endif
+        referer = al->request->header.getStr(HDR_REFERER);
+        agent = al->request->header.getStr(HDR_USER_AGENT);
+    }
 
-    const char *referer = al->request->header.getStr(HDR_REFERER);
     if (!referer || *referer == '\0')
         referer = "-";
 
-    const char *agent = al->request->header.getStr(HDR_USER_AGENT);
     if (!agent || *agent == '\0')
         agent = "-";
 
     char clientip[MAX_IPSTRLEN];
     al->getLogClientIp(clientip, MAX_IPSTRLEN);
 
-    logfilePrintf(logfile, "%s %s %s [%s] \"%s %s %s/%d.%d\" %d %"PRId64" \"%s\" \"%s\" %s%s:%s%s",
+    logfilePrintf(logfile, "%s %s %s [%s] \"%s %s %s/%d.%d\" %d %" PRId64 " \"%s\" \"%s\" %s%s:%s%s",
                   clientip,
                   user_ident ? user_ident : dash_str,
                   user_auth ? user_auth : dash_str,
@@ -72,7 +80,7 @@ Log::Format::HttpdCombined(AccessLogEntry * al, Logfile * logfile)
                   al->cache.replySize,
                   referer,
                   agent,
-                  ::Format::log_tags[al->cache.code],
+                  LogTags_str[al->cache.code],
                   al->http.statusSfx(),
                   hier_code_str[al->hier.code],
                   (Config.onoff.log_mime_hdrs?"":"\n"));