You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2018/05/29 21:17:09 UTC
[trafficserver] branch 8.0.x updated: Adds log field for "reason
phrase" returned with status codes
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/8.0.x by this push:
new 9af85fa Adds log field for "reason phrase" returned with status codes
9af85fa is described below
commit 9af85fa579ad77febdaf7f98467c5a26b834e790
Author: Randall Meyer <ra...@yahoo.com>
AuthorDate: Wed Apr 25 17:26:30 2018 -0700
Adds log field for "reason phrase" returned with status codes
reason sometimes has more detail about why a request failed than the
status code or the result code (crc)
`prrp`: HTTP response reason phrase sent to client
(cherry picked from commit 21953ef5ff01bd050a3b3c43e2a5fdd6156a045d)
---
doc/admin-guide/logging/formatting.en.rst | 3 +++
proxy/logging/Log.cc | 5 +++++
proxy/logging/LogAccess.cc | 5 +++++
proxy/logging/LogAccess.h | 1 +
proxy/logging/LogAccessHttp.cc | 16 ++++++++++++++++
proxy/logging/LogAccessHttp.h | 3 +++
proxy/logging/LogAccessTest.cc | 14 ++++++++++++++
proxy/logging/LogAccessTest.h | 1 +
8 files changed, 48 insertions(+)
diff --git a/doc/admin-guide/logging/formatting.en.rst b/doc/admin-guide/logging/formatting.en.rst
index 85eed8a..6ac7b7f 100644
--- a/doc/admin-guide/logging/formatting.en.rst
+++ b/doc/admin-guide/logging/formatting.en.rst
@@ -585,6 +585,7 @@ Status Codes
.. _pfsc:
.. _pssc:
.. _sssc:
+.. _prrp:
These log fields provide a variety of status codes, some numeric and some as
strings, relating to client, proxy, and origin transactions.
@@ -601,6 +602,8 @@ pfsc Proxy Request Finish status code specifying whether the proxy
request from |TS| to the origin server was
successfully completed (``FIN``), interrupted
(``INTR``), or timed out (``TIMEOUT``).
+prrp Proxy Response HTTP response reason phrase sent by |TS| proxy to the
+ client.
pssc Proxy Response HTTP response status code sent by |TS| proxy to the
client.
sssc Origin Response HTTP response status code sent by the origin server
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index ce98bf4..9120998 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -554,6 +554,11 @@ Log::init_fields()
global_field_list.add(field, false);
ink_hash_table_insert(field_symbol_hash, "psct", field);
+ field = new LogField("proxy_resp_reason_phrase", "prrp", LogField::STRING, &LogAccess::marshal_proxy_resp_reason_phrase,
+ (LogField::UnmarshalFunc)&LogAccess::unmarshal_str);
+ global_field_list.add(field, false);
+ ink_hash_table_insert(field_symbol_hash, "prrp", field);
+
field = new LogField("proxy_resp_squid_len", "psql", LogField::sINT, &LogAccess::marshal_proxy_resp_squid_len,
&LogAccess::unmarshal_int_to_str);
global_field_list.add(field, false);
diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc
index f484ac3..96f1ba6 100644
--- a/proxy/logging/LogAccess.cc
+++ b/proxy/logging/LogAccess.cc
@@ -232,6 +232,11 @@ LOG_ACCESS_DEFAULT_FIELD(marshal_proxy_resp_content_type, DEFAULT_STR_FIELD)
/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/
+LOG_ACCESS_DEFAULT_FIELD(marshal_proxy_resp_reason_phrase, DEFAULT_STR_FIELD)
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
LOG_ACCESS_DEFAULT_FIELD(marshal_proxy_resp_squid_len, DEFAULT_INT_FIELD)
LOG_ACCESS_DEFAULT_FIELD(marshal_client_req_squid_len, DEFAULT_INT_FIELD)
LOG_ACCESS_DEFAULT_FIELD(marshal_proxy_req_squid_len, DEFAULT_INT_FIELD)
diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h
index 6f86882..ac0e15f 100644
--- a/proxy/logging/LogAccess.h
+++ b/proxy/logging/LogAccess.h
@@ -203,6 +203,7 @@ public:
// proxy -> client fields
//
inkcoreapi virtual int marshal_proxy_resp_content_type(char *); // STR
+ inkcoreapi virtual int marshal_proxy_resp_reason_phrase(char *); // STR
inkcoreapi virtual int marshal_proxy_resp_squid_len(char *); // INT
inkcoreapi virtual int marshal_proxy_resp_content_len(char *); // INT
inkcoreapi virtual int marshal_proxy_resp_status_code(char *); // INT
diff --git a/proxy/logging/LogAccessHttp.cc b/proxy/logging/LogAccessHttp.cc
index 889ab1d..4040edb 100644
--- a/proxy/logging/LogAccessHttp.cc
+++ b/proxy/logging/LogAccessHttp.cc
@@ -70,6 +70,8 @@ LogAccessHttp::LogAccessHttp(HttpSM *sm)
m_client_req_url_path_len(0),
m_proxy_resp_content_type_str(nullptr),
m_proxy_resp_content_type_len(0),
+ m_proxy_resp_reason_phrase_str(nullptr),
+ m_proxy_resp_reason_phrase_len(0),
m_cache_lookup_url_canon_str(nullptr),
m_cache_lookup_url_canon_len(0)
{
@@ -135,6 +137,7 @@ LogAccessHttp::init()
LogUtils::remove_content_type_attributes(m_proxy_resp_content_type_str, &m_proxy_resp_content_type_len);
}
}
+ m_proxy_resp_reason_phrase_str = (char *)m_proxy_response->reason_get(&m_proxy_resp_reason_phrase_len);
}
if (hdr->server_request.valid()) {
m_proxy_request = &(hdr->server_request);
@@ -875,6 +878,19 @@ LogAccessHttp::marshal_proxy_resp_content_type(char *buf)
}
/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+int
+LogAccessHttp::marshal_proxy_resp_reason_phrase(char *buf)
+{
+ int len = round_strlen(m_proxy_resp_reason_phrase_len + 1);
+ if (buf) {
+ marshal_mem(buf, m_proxy_resp_reason_phrase_str, m_proxy_resp_reason_phrase_len, len);
+ }
+ return len;
+}
+
+/*-------------------------------------------------------------------------
Squid returns the content-length + header length as the total length.
-------------------------------------------------------------------------*/
diff --git a/proxy/logging/LogAccessHttp.h b/proxy/logging/LogAccessHttp.h
index 8ba4824..18e16b6 100644
--- a/proxy/logging/LogAccessHttp.h
+++ b/proxy/logging/LogAccessHttp.h
@@ -89,6 +89,7 @@ public:
// proxy -> client fields
//
int marshal_proxy_resp_content_type(char *) override; // STR
+ int marshal_proxy_resp_reason_phrase(char *) override; // STR
int marshal_proxy_resp_header_len(char *) override; // INT
int marshal_proxy_resp_content_len(char *) override; // INT
int marshal_proxy_resp_squid_len(char *) override; // INT
@@ -208,6 +209,8 @@ private:
int m_client_req_url_path_len;
char *m_proxy_resp_content_type_str;
int m_proxy_resp_content_type_len;
+ char *m_proxy_resp_reason_phrase_str;
+ int m_proxy_resp_reason_phrase_len;
char *m_cache_lookup_url_canon_str;
int m_cache_lookup_url_canon_len;
diff --git a/proxy/logging/LogAccessTest.cc b/proxy/logging/LogAccessTest.cc
index 8d43e33..9e37ba1 100644
--- a/proxy/logging/LogAccessTest.cc
+++ b/proxy/logging/LogAccessTest.cc
@@ -192,6 +192,20 @@ LogAccessTest::marshal_proxy_resp_content_type(char *buf)
-------------------------------------------------------------------------*/
int
+LogAccessTest::marshal_proxy_resp_reason_phrase(char *buf)
+{
+ static char const *str = "Unknown reason";
+ int len = LogAccess::strlen(str);
+ if (buf) {
+ marshal_str(buf, str, len);
+ }
+ return len;
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+int
LogAccessTest::marshal_proxy_resp_squid_len(char *buf)
{
if (buf) {
diff --git a/proxy/logging/LogAccessTest.h b/proxy/logging/LogAccessTest.h
index cb8938c..32540bf 100644
--- a/proxy/logging/LogAccessTest.h
+++ b/proxy/logging/LogAccessTest.h
@@ -61,6 +61,7 @@ public:
// proxy -> client fields
//
virtual int marshal_proxy_resp_content_type(char *); // STR
+ virtual int marshal_proxy_resp_reason_phrase(char *); // STR
virtual int marshal_proxy_resp_squid_len(char *); // INT
virtual int marshal_proxy_resp_content_len(char *); // INT
virtual int marshal_proxy_resp_status_code(char *); // INT
--
To stop receiving notification emails like this one, please contact
zwoop@apache.org.