This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new a82efb7 Issue #1685: Use TS_MILESTONE_UA_BEGIN for cqt* log fields
a82efb7 is described below
commit a82efb7de67772bc690c41d631d201330467c95e
Author: Masaori Koshiba <[email protected]>
AuthorDate: Thu May 25 13:53:53 2017 -0700
Issue #1685: Use TS_MILESTONE_UA_BEGIN for cqt* log fields
- Add functions to marshal milestone in some formats (unix timestamp,
squid, netscape, date, and time)
- Use TS_MILESTONE_UA_BEGIN for cqtd, cqtn, cqtq, cqts, cqth, and cqtt
- Add description of `cqth` in docs
---
doc/admin-guide/logging/formatting.en.rst | 1 +
proxy/logging/Log.cc | 16 ++---
proxy/logging/LogAccess.cc | 62 ++++++++++++++---
proxy/logging/LogAccess.h | 20 ++++--
proxy/logging/LogAccessHttp.cc | 112 ++++++++++++++++++++++++++++++
proxy/logging/LogAccessHttp.h | 10 +++
proxy/logging/LogBuffer.cc | 94 +------------------------
7 files changed, 200 insertions(+), 115 deletions(-)
diff --git a/doc/admin-guide/logging/formatting.en.rst
b/doc/admin-guide/logging/formatting.en.rst
index 4fd1a4c..4e4cc0b 100644
--- a/doc/admin-guide/logging/formatting.en.rst
+++ b/doc/admin-guide/logging/formatting.en.rst
@@ -640,6 +640,7 @@ cqtq Client Request The time at which the client
request was received
millisecond resolution.
cqts Client Request Same as cqtq_, but as an integer without
sub-second resolution.
+cqth Client Request Same as cqts_, but represented in hexadecimal.
cqtt Client Request Client request timestamp in the 24-hour format
``hh:mm:ss`` (two digit hour, minutes, and
seconds - with leading zeroes as necessary).
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index 79b1cdb..a4b0fea 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -388,23 +388,23 @@ Log::init_fields()
global_field_list.add(field, false);
ink_hash_table_insert(field_symbol_hash, "cqth", field);
- field = new LogField("client_req_timestamp_squid", "cqtq", LogField::sINT,
&LogAccess::marshal_client_req_timestamp_sec,
- &LogAccess::unmarshal_int_to_str);
+ field = new LogField("client_req_timestamp_squid", "cqtq", LogField::STRING,
&LogAccess::marshal_client_req_timestamp_squid,
+ (LogField::UnmarshalFunc)&LogAccess::unmarshal_str);
global_field_list.add(field, false);
ink_hash_table_insert(field_symbol_hash, "cqtq", field);
- field = new LogField("client_req_timestamp_netscape", "cqtn",
LogField::sINT, &LogAccess::marshal_client_req_timestamp_sec,
- &LogAccess::unmarshal_int_to_str);
+ field = new LogField("client_req_timestamp_netscape", "cqtn",
LogField::STRING, &LogAccess::marshal_client_req_timestamp_netscape,
+ (LogField::UnmarshalFunc)&LogAccess::unmarshal_str);
global_field_list.add(field, false);
ink_hash_table_insert(field_symbol_hash, "cqtn", field);
- field = new LogField("client_req_timestamp_date", "cqtd", LogField::sINT,
&LogAccess::marshal_client_req_timestamp_sec,
- &LogAccess::unmarshal_int_to_str);
+ field = new LogField("client_req_timestamp_date", "cqtd", LogField::STRING,
&LogAccess::marshal_client_req_timestamp_date,
+ (LogField::UnmarshalFunc)&LogAccess::unmarshal_str);
global_field_list.add(field, false);
ink_hash_table_insert(field_symbol_hash, "cqtd", field);
- field = new LogField("client_req_timestamp_time", "cqtt", LogField::sINT,
&LogAccess::marshal_client_req_timestamp_sec,
- &LogAccess::unmarshal_int_to_str);
+ field = new LogField("client_req_timestamp_time", "cqtt", LogField::STRING,
&LogAccess::marshal_client_req_timestamp_time,
+ (LogField::UnmarshalFunc)&LogAccess::unmarshal_str);
global_field_list.add(field, false);
ink_hash_table_insert(field_symbol_hash, "cqtt", field);
diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc
index 66d2a06..a87025c 100644
--- a/proxy/logging/LogAccess.cc
+++ b/proxy/logging/LogAccess.cc
@@ -213,6 +213,15 @@ LOG_ACCESS_DEFAULT_FIELD(marshal_client_req_uuid,
DEFAULT_STR_FIELD)
/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/
+LOG_ACCESS_DEFAULT_FIELD(marshal_client_req_timestamp_sec, DEFAULT_INT_FIELD)
+LOG_ACCESS_DEFAULT_FIELD(marshal_client_req_timestamp_squid, DEFAULT_STR_FIELD)
+LOG_ACCESS_DEFAULT_FIELD(marshal_client_req_timestamp_netscape,
DEFAULT_STR_FIELD)
+LOG_ACCESS_DEFAULT_FIELD(marshal_client_req_timestamp_date, DEFAULT_STR_FIELD)
+LOG_ACCESS_DEFAULT_FIELD(marshal_client_req_timestamp_time, DEFAULT_STR_FIELD)
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
LOG_ACCESS_DEFAULT_FIELD(marshal_proxy_resp_content_type, DEFAULT_STR_FIELD)
/*-------------------------------------------------------------------------
@@ -454,14 +463,6 @@ LOG_ACCESS_DEFAULT_FIELD(marshal_proxy_host_port,
DEFAULT_INT_FIELD)
-------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------
- LogAccess::marshal_client_req_timestamp_sec
-
- This does nothing because the timestamp is already in the LogEntryHeader.
- -------------------------------------------------------------------------*/
-
-LOG_ACCESS_DEFAULT_FIELD(marshal_client_req_timestamp_sec, DEFAULT_INT_FIELD)
-
-/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/
int
@@ -530,6 +531,51 @@ LogAccess::marshal_milestone(TSMilestonesType ms, char
*buf)
-------------------------------------------------------------------------*/
int
+LogAccess::marshal_milestone_fmt_sec(TSMilestonesType ms, char *buf)
+{
+ DEFAULT_INT_FIELD;
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+int
+LogAccess::marshal_milestone_fmt_squid(TSMilestonesType ms, char *buf)
+{
+ DEFAULT_STR_FIELD;
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+int
+LogAccess::marshal_milestone_fmt_netscape(TSMilestonesType ms, char *buf)
+{
+ DEFAULT_STR_FIELD;
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+int
+LogAccess::marshal_milestone_fmt_date(TSMilestonesType ms, char *buf)
+{
+ DEFAULT_STR_FIELD;
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+int
+LogAccess::marshal_milestone_fmt_time(TSMilestonesType ms, char *buf)
+{
+ DEFAULT_STR_FIELD;
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+int
LogAccess::marshal_milestone_diff(TSMilestonesType ms1, TSMilestonesType ms2,
char *buf)
{
DEFAULT_INT_FIELD;
diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h
index 698395f..0a845a7 100644
--- a/proxy/logging/LogAccess.h
+++ b/proxy/logging/LogAccess.h
@@ -167,12 +167,15 @@ public:
//
// client -> proxy fields
//
- inkcoreapi virtual int marshal_client_host_ip(char *); // STR
- inkcoreapi virtual int marshal_host_interface_ip(char *); // STR
- inkcoreapi virtual int marshal_client_host_port(char *); // INT
- inkcoreapi virtual int marshal_client_auth_user_name(char *); // STR
- int marshal_client_req_timestamp_sec(char *); // INT
-
+ inkcoreapi virtual int marshal_client_host_ip(char *); // STR
+ inkcoreapi virtual int marshal_host_interface_ip(char *); // STR
+ inkcoreapi virtual int marshal_client_host_port(char *); // INT
+ inkcoreapi virtual int marshal_client_auth_user_name(char *); // STR
+ inkcoreapi virtual int marshal_client_req_timestamp_sec(char *); // INT
+ inkcoreapi virtual int marshal_client_req_timestamp_squid(char *); // STR
+ inkcoreapi virtual int marshal_client_req_timestamp_netscape(char *); // STR
+ inkcoreapi virtual int marshal_client_req_timestamp_date(char *); // STR
+ inkcoreapi virtual int marshal_client_req_timestamp_time(char *); // STR
inkcoreapi virtual int marshal_client_req_text(char *); // STR
inkcoreapi virtual int marshal_client_req_http_method(char *); // STR
inkcoreapi virtual int marshal_client_req_url(char *); // STR
@@ -302,6 +305,11 @@ public:
// milestones access
//
inkcoreapi virtual int marshal_milestone(TSMilestonesType ms, char *buf);
+ inkcoreapi virtual int marshal_milestone_fmt_sec(TSMilestonesType ms, char
*buf);
+ inkcoreapi virtual int marshal_milestone_fmt_squid(TSMilestonesType ms, char
*buf);
+ inkcoreapi virtual int marshal_milestone_fmt_netscape(TSMilestonesType ms,
char *buf);
+ inkcoreapi virtual int marshal_milestone_fmt_date(TSMilestonesType ms, char
*buf);
+ inkcoreapi virtual int marshal_milestone_fmt_time(TSMilestonesType ms, char
*buf);
inkcoreapi virtual int marshal_milestone_diff(TSMilestonesType ms1,
TSMilestonesType ms2, char *buf);
//
diff --git a/proxy/logging/LogAccessHttp.cc b/proxy/logging/LogAccessHttp.cc
index 7100c81..6cdccd2 100644
--- a/proxy/logging/LogAccessHttp.cc
+++ b/proxy/logging/LogAccessHttp.cc
@@ -423,6 +423,48 @@ LogAccessHttp::marshal_client_req_text(char *buf)
-------------------------------------------------------------------------*/
int
+LogAccessHttp::marshal_client_req_timestamp_sec(char *buf)
+{
+ return marshal_milestone_fmt_sec(TS_MILESTONE_UA_BEGIN, buf);
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+int
+LogAccessHttp::marshal_client_req_timestamp_squid(char *buf)
+{
+ return marshal_milestone_fmt_squid(TS_MILESTONE_UA_BEGIN, buf);
+}
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+int
+LogAccessHttp::marshal_client_req_timestamp_netscape(char *buf)
+{
+ return marshal_milestone_fmt_netscape(TS_MILESTONE_UA_BEGIN, buf);
+}
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+int
+LogAccessHttp::marshal_client_req_timestamp_date(char *buf)
+{
+ return marshal_milestone_fmt_date(TS_MILESTONE_UA_BEGIN, buf);
+}
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+int
+LogAccessHttp::marshal_client_req_timestamp_time(char *buf)
+{
+ return marshal_milestone_fmt_time(TS_MILESTONE_UA_BEGIN, buf);
+}
+
+/*-------------------------------------------------------------------------
+ -------------------------------------------------------------------------*/
+
+int
LogAccessHttp::marshal_client_req_http_method(char *buf)
{
char *str = nullptr;
@@ -1675,6 +1717,76 @@ LogAccessHttp::marshal_milestone(TSMilestonesType ms,
char *buf)
}
int
+LogAccessHttp::marshal_milestone_fmt_sec(TSMilestonesType type, char *buf)
+{
+ if (buf) {
+ struct timeval tp = ink_hrtime_to_timeval(m_http_sm->milestones[type]);
+ marshal_int(buf, tp.tv_sec);
+ }
+ return INK_MIN_ALIGN;
+}
+
+int
+LogAccessHttp::marshal_milestone_fmt_squid(TSMilestonesType type, char *buf)
+{
+ struct timeval tp =
ink_hrtime_to_timeval(m_http_sm->milestones[type]);
+ const unsigned int val_len = 32;
+ char val[val_len] = {0};
+
+ squid_timestamp_to_buf(val, val_len, tp.tv_sec, tp.tv_usec);
+
+ int len = LogAccess::strlen(val);
+
+ if (buf) {
+ marshal_str(buf, val, len);
+ }
+
+ return len;
+}
+
+int
+LogAccessHttp::marshal_milestone_fmt_netscape(TSMilestonesType type, char *buf)
+{
+ struct timeval tp = ink_hrtime_to_timeval(m_http_sm->milestones[type]);
+ char *val = LogUtils::timestamp_to_netscape_str(tp.tv_sec);
+ int len = LogAccess::strlen(val);
+
+ if (buf) {
+ marshal_str(buf, val, len);
+ }
+
+ return len;
+}
+
+int
+LogAccessHttp::marshal_milestone_fmt_date(TSMilestonesType type, char *buf)
+{
+ struct timeval tp = ink_hrtime_to_timeval(m_http_sm->milestones[type]);
+ char *val = LogUtils::timestamp_to_date_str(tp.tv_sec);
+ int len = LogAccess::strlen(val);
+
+ if (buf) {
+ marshal_str(buf, val, len);
+ }
+
+ return len;
+}
+
+int
+LogAccessHttp::marshal_milestone_fmt_time(TSMilestonesType type, char *buf)
+{
+ struct timeval tp = ink_hrtime_to_timeval(m_http_sm->milestones[type]);
+ char *val = LogUtils::timestamp_to_time_str(tp.tv_sec);
+ int len = LogAccess::strlen(val);
+
+ if (buf) {
+ marshal_str(buf, val, len);
+ }
+
+ return len;
+}
+
+int
LogAccessHttp::marshal_milestone_diff(TSMilestonesType ms1, TSMilestonesType
ms2, char *buf)
{
if (buf) {
diff --git a/proxy/logging/LogAccessHttp.h b/proxy/logging/LogAccessHttp.h
index 879032a..4668c38 100644
--- a/proxy/logging/LogAccessHttp.h
+++ b/proxy/logging/LogAccessHttp.h
@@ -76,6 +76,11 @@ public:
virtual int marshal_client_req_tcp_reused(char *); // INT
virtual int marshal_client_req_is_ssl(char *); // INT
virtual int marshal_client_req_ssl_reused(char *); // INT
+ virtual int marshal_client_req_timestamp_sec(char *); // INT
+ virtual int marshal_client_req_timestamp_squid(char *); // STR
+ virtual int marshal_client_req_timestamp_netscape(char *); // STR
+ virtual int marshal_client_req_timestamp_date(char *); // STR
+ virtual int marshal_client_req_timestamp_time(char *); // STR
virtual int marshal_client_security_protocol(char *); // STR
virtual int marshal_client_security_cipher_suite(char *); // STR
virtual int marshal_client_finish_status_code(char *); // INT
@@ -159,6 +164,11 @@ public:
virtual int marshal_http_header_field_escapify(LogField::Container
container, char *field, char *buf);
virtual int marshal_milestone(TSMilestonesType ms, char *buf);
+ virtual int marshal_milestone_fmt_sec(TSMilestonesType ms, char *buf);
+ virtual int marshal_milestone_fmt_squid(TSMilestonesType ms, char *buf);
+ virtual int marshal_milestone_fmt_netscape(TSMilestonesType ms, char *buf);
+ virtual int marshal_milestone_fmt_date(TSMilestonesType ms, char *buf);
+ virtual int marshal_milestone_fmt_time(TSMilestonesType ms, char *buf);
virtual int marshal_milestone_diff(TSMilestonesType ms1, TSMilestonesType
ms2, char *buf);
virtual void set_client_req_url(char *, int); // STR
diff --git a/proxy/logging/LogBuffer.cc b/proxy/logging/LogBuffer.cc
index 05ee7fb..192a085 100644
--- a/proxy/logging/LogBuffer.cc
+++ b/proxy/logging/LogBuffer.cc
@@ -511,99 +511,7 @@ LogBuffer::resolve_custom_entry(LogFieldList *fieldlist,
char *printf_str, char
++markCount;
if (field != nullptr) {
char *to = &write_to[bytes_written];
-
- // for timestamps that are not aggregates, we take the
- // value from the function argument; otherwise we use the
- // unmarshaling function
- bool non_aggregate_timestamp = false;
-
- if (field->aggregate() == LogField::NO_AGGREGATE) {
- const char *sym = field->symbol();
-
- if (strcmp(sym, "cqts") == 0) {
- char *ptr = (char *)×tamp;
- res = LogAccess::unmarshal_int_to_str(&ptr, to, write_to_len
- bytes_written);
- if (buffer_version > 1) {
- // space was reserved in read buffer; remove it
- read_from += INK_MIN_ALIGN;
- }
-
- non_aggregate_timestamp = true;
-
- } else if (strcmp(sym, "cqth") == 0) {
- char *ptr = (char *)×tamp;
- res = LogAccess::unmarshal_int_to_str_hex(&ptr, to,
write_to_len - bytes_written);
- if (buffer_version > 1) {
- // space was reserved in read buffer; remove it
- read_from += INK_MIN_ALIGN;
- }
-
- non_aggregate_timestamp = true;
-
- } else if (strcmp(sym, "cqtq") == 0) {
- // From lib/ts
- res = squid_timestamp_to_buf(to, write_to_len - bytes_written,
timestamp, timestamp_usec);
- if (res < 0) {
- res = -1;
- }
-
- if (buffer_version > 1) {
- // space was reserved in read buffer; remove it
- read_from += INK_MIN_ALIGN;
- }
-
- non_aggregate_timestamp = true;
-
- } else if (strcmp(sym, "cqtn") == 0) {
- char *str = LogUtils::timestamp_to_netscape_str(timestamp);
- res = (int)::strlen(str);
- if (res < write_to_len - bytes_written) {
- memcpy(to, str, res);
- } else {
- res = -1;
- }
- if (buffer_version > 1) {
- // space was reserved in read buffer; remove it
- read_from += INK_MIN_ALIGN;
- }
-
- non_aggregate_timestamp = true;
-
- } else if (strcmp(sym, "cqtd") == 0) {
- char *str = LogUtils::timestamp_to_date_str(timestamp);
- res = (int)::strlen(str);
- if (res < write_to_len - bytes_written) {
- memcpy(to, str, res);
- } else {
- res = -1;
- }
- if (buffer_version > 1) {
- // space was reserved in read buffer; remove it
- read_from += INK_MIN_ALIGN;
- }
-
- non_aggregate_timestamp = true;
-
- } else if (strcmp(sym, "cqtt") == 0) {
- char *str = LogUtils::timestamp_to_time_str(timestamp);
- res = (int)::strlen(str);
- if (res < write_to_len - bytes_written) {
- memcpy(to, str, res);
- } else {
- res = -1;
- }
- if (buffer_version > 1) {
- // space was reserved in read buffer; remove it
- read_from += INK_MIN_ALIGN;
- }
-
- non_aggregate_timestamp = true;
- }
- }
-
- if (!non_aggregate_timestamp) {
- res = field->unmarshal(&read_from, to, write_to_len - bytes_written);
- }
+ res = field->unmarshal(&read_from, to, write_to_len -
bytes_written);
if (res < 0) {
Note("%s", buffer_size_exceeded_msg);
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].