]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/log/FormatSquidNative.cc
2 * Copyright (C) 1996-2014 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 - Squid 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::SquidNative(const AccessLogEntry::Pointer
&al
, Logfile
* logfile
)
25 char hierHost
[MAX_IPSTRLEN
];
27 const char *user
= NULL
;
30 if (al
->request
&& al
->request
->auth_user_request
!= NULL
)
31 user
= ::Format::QuoteUrlEncodeUsername(al
->request
->auth_user_request
->username());
35 user
= ::Format::QuoteUrlEncodeUsername(al
->cache
.extuser
);
39 user
= ::Format::QuoteUrlEncodeUsername(al
->cache
.ssluser
);
43 user
= ::Format::QuoteUrlEncodeUsername(al
->cache
.rfc931
);
48 char clientip
[MAX_IPSTRLEN
];
49 al
->getLogClientIp(clientip
, MAX_IPSTRLEN
);
52 if (al
->_private
.method_str
)
53 method
.assign(al
->_private
.method_str
);
55 method
= al
->http
.method
.image();
57 logfilePrintf(logfile
, "%9ld.%03d %6ld %s %s%s/%03d %" PRId64
" " SQUIDSBUFPH
" %s %s %s%s/%s %s%s",
58 (long int) current_time
.tv_sec
,
59 (int) current_time
.tv_usec
/ 1000,
60 tvToMsec(al
->cache
.trTime
),
62 LogTags_str
[al
->cache
.code
],
65 al
->http
.clientReplySz
.messageTotal(),
66 SQUIDSBUFPRINT(method
),
68 user
? user
: dash_str
,
69 al
->hier
.ping
.timedout
? "TIMEOUT_" : "",
70 hier_code_str
[al
->hier
.code
],
71 al
->hier
.tcpServer
!= NULL
? al
->hier
.tcpServer
->remote
.toStr(hierHost
, sizeof(hierHost
)) : "-",
72 al
->http
.content_type
,
73 (Config
.onoff
.log_mime_hdrs
?"":"\n"));
77 if (Config
.onoff
.log_mime_hdrs
) {
78 char *ereq
= ::Format::QuoteMimeBlob(al
->headers
.request
);
79 char *erep
= ::Format::QuoteMimeBlob(al
->headers
.reply
);
80 logfilePrintf(logfile
, " [%s] [%s]\n", ereq
, erep
);