You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ig...@apache.org on 2013/08/09 01:09:13 UTC
[01/13] git commit: transform libloader,
stats_over_http to new logging non-API - fix typo
Updated Branches:
refs/heads/consistent-gzip-error-msgs 891ada6c7 -> fda89b48d
transform libloader, stats_over_http to new logging non-API - fix typo
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/4f27dcad
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/4f27dcad
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/4f27dcad
Branch: refs/heads/consistent-gzip-error-msgs
Commit: 4f27dcadaf0bdc02a4de818c08daf06f211ed23e
Parents: 891ada6
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 22:07:49 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 22:07:49 2013 +0200
----------------------------------------------------------------------
plugins/regex_remap/regex_remap.cc | 58 +++++++++++++-------------
plugins/stats_over_http/stats_over_http.c | 31 +++++++-------
2 files changed, 46 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4f27dcad/plugins/regex_remap/regex_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/regex_remap/regex_remap.cc b/plugins/regex_remap/regex_remap.cc
index 8b637f6..327e611 100644
--- a/plugins/regex_remap/regex_remap.cc
+++ b/plugins/regex_remap/regex_remap.cc
@@ -47,7 +47,8 @@
#include "ink_atomic.h"
#include "ink_time.h"
-static const char* PLUGIN_NAME = "regex_remap";
+#define PLUGIN_NAME "regex_remap"
+#include <ts/debug.h>
// Constants
static const int OVECCOUNT = 30; // We support $0 - $9 x2 ints, and this needs to be 1.5x that
@@ -121,13 +122,13 @@ class RemapRegex
_num_subs(-1), _rex(NULL), _extra(NULL), _order(-1), _simple(false),
_active_timeout(-1), _no_activity_timeout(-1), _connect_timeout(-1), _dns_timeout(-1)
{
- TSDebug(PLUGIN_NAME, "Calling constructor");
+ TSLogDebug("Calling constructor");
_status = static_cast<TSHttpStatus>(0);
if (!reg.empty()) {
if (reg == ".") {
- TSDebug(PLUGIN_NAME, "Rule is simple, and fast!");
+ TSLogDebug("Rule is simple, and fast!");
_simple = true;
}
_rex_string = TSstrdup(reg.c_str());
@@ -158,7 +159,7 @@ class RemapRegex
++start;
pos1 = opt.find_first_of("=", start);
if (pos1 == std::string::npos) {
- TSError("Malformed options: %s", opt.c_str());
+ TSLogError("Malformed options: %s", opt.c_str());
break;
}
++pos1;
@@ -178,7 +179,7 @@ class RemapRegex
} else if (opt.compare(start, 11, "dns_timeout") == 0) {
_dns_timeout = atoi(opt_val.c_str());
} else {
- TSError("Unknown options: %s", opt.c_str());
+ TSLogError("Unknown options: %s", opt.c_str());
}
start = opt.find_first_of("@", pos2);
}
@@ -186,7 +187,7 @@ class RemapRegex
~RemapRegex()
{
- TSDebug(PLUGIN_NAME, "Calling destructor");
+ TSLogDebug("Calling destructor");
if (_rex_string)
TSfree(_rex_string);
if (_subst)
@@ -280,7 +281,7 @@ class RemapRegex
if (ix > -1) {
if ((ix < 10) && (ix > ccount)) {
- TSDebug(PLUGIN_NAME, "Trying to use unavailable substitution, check the regex!");
+ TSLogDebug("Trying to use unavailable substitution, check the regex!");
return -1; // No substitutions available other than $0
}
@@ -554,7 +555,7 @@ TSRemapInit(TSRemapInterface* api_info, char *errbuf, int errbuf_size)
}
setup_memory_allocation();
- TSDebug(PLUGIN_NAME, "plugin is successfully initialized");
+ TSLogInfo("plugin is successfully initialized");
return TS_SUCCESS;
}
@@ -575,7 +576,7 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED
*ih = (void*)ri;
if (ri == NULL) {
- TSError("Unable to create remap instance");
+ TSLogError("Unable to create remap instance");
return TS_ERROR;
}
@@ -607,10 +608,10 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED
f.open((ri->filename).c_str(), std::ios::in);
if (!f.is_open()) { // Try with the default path instead
- TSError("unable to open %s", (ri->filename).c_str());
+ TSLogError("unable to open %s", (ri->filename).c_str());
return TS_ERROR;
}
- TSDebug(PLUGIN_NAME, "loading regular expression maps from %s", (ri->filename).c_str());
+ TSLogDebug("loading regular expression maps from %s", (ri->filename).c_str());
while (!f.eof()) {
std::string line, regex, subst, options;
@@ -647,12 +648,12 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED
if (regex.empty()) {
// No regex found on this line
- TSError("no regexp found in %s: line %d", (ri->filename).c_str(), lineno);
+ TSLogError("no regexp found in %s: line %d", (ri->filename).c_str(), lineno);
continue;
}
if (subst.empty() && options.empty()) {
// No substitution found on this line (and no options)
- TSError("no substitution string found in %s: line %d", (ri->filename).c_str(), lineno);
+ TSLogError("no substitution string found in %s: line %d", (ri->filename).c_str(), lineno);
continue;
}
@@ -660,16 +661,15 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED
RemapRegex* cur = new RemapRegex(regex, subst, options);
if (cur == NULL) {
- TSError("can't create a new regex remap rule");
+ TSLogError("can't create a new regex remap rule");
continue;
}
if (cur->compile(&error, &erroffset) < 0) {
- TSError("PCRE failed in %s (line %d) at offset %d: %s", (ri->filename).c_str(), lineno, erroffset, error);
+ TSLogError("PCRE failed in %s (line %d) at offset %d: %s", (ri->filename).c_str(), lineno, erroffset, error);
delete(cur);
} else {
- TSDebug(PLUGIN_NAME, "added regex=%s with substitution=%s and options `%s'",
- regex.c_str(), subst.c_str(), options.c_str());
+ TSLogDebug("added regex=%s with substitution=%s and options `%s'", regex.c_str(), subst.c_str(), options.c_str());
cur->set_order(++count);
if (ri->first == NULL)
ri->first = cur;
@@ -683,7 +683,7 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED
// Make sure we got something...
if (ri->first == NULL) {
- TSError("Got no regular expressions from the maps");
+ TSLogError("Got no regular expressions from the maps");
return TS_ERROR;
}
@@ -743,7 +743,7 @@ TSRemapStatus
TSRemapDoRemap(void* ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
{
if (NULL == ih) {
- TSDebug(PLUGIN_NAME, "Falling back to default URL on regex remap without rules");
+ TSLogDebug("Falling back to default URL on regex remap without rules");
return TSREMAP_NO_REMAP;
}
@@ -796,7 +796,7 @@ TSRemapDoRemap(void* ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
match_len += (req_url.query_len + 1);
}
match_buf[match_len] = '\0'; // NULL terminate the match string
- TSDebug(PLUGIN_NAME, "Target match string is `%s'", match_buf);
+ TSLogDebug("Target match string is `%s'", match_buf);
// Apply the regular expressions, in order. First one wins.
while (re) {
@@ -806,19 +806,19 @@ TSRemapDoRemap(void* ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
// Set timeouts
if (re->active_timeout_option() > (-1)) {
- TSDebug(PLUGIN_NAME, "Setting active timeout to %d", re->active_timeout_option());
+ TSLogDebug("Setting active timeout to %d", re->active_timeout_option());
TSHttpTxnActiveTimeoutSet(txnp, re->active_timeout_option());
}
if (re->no_activity_timeout_option() > (-1)) {
- TSDebug(PLUGIN_NAME, "Setting no activity timeout to %d", re->no_activity_timeout_option());
+ TSLogDebug("Setting no activity timeout to %d", re->no_activity_timeout_option());
TSHttpTxnNoActivityTimeoutSet(txnp, re->no_activity_timeout_option());
}
if (re->connect_timeout_option() > (-1)) {
- TSDebug(PLUGIN_NAME, "Setting connect timeout to %d", re->connect_timeout_option());
+ TSLogDebug("Setting connect timeout to %d", re->connect_timeout_option());
TSHttpTxnConnectTimeoutSet(txnp, re->connect_timeout_option());
}
if (re->dns_timeout_option() > (-1)) {
- TSDebug(PLUGIN_NAME, "Setting DNS timeout to %d", re->dns_timeout_option());
+ TSLogDebug("Setting DNS timeout to %d", re->dns_timeout_option());
TSHttpTxnDNSTimeoutSet(txnp, re->dns_timeout_option());
}
@@ -834,9 +834,9 @@ TSRemapDoRemap(void* ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
dest = (char*)alloca(new_len+8);
dest_len = re->substitute(dest, match_buf, ovector, lengths, rri, &req_url);
- TSDebug(PLUGIN_NAME, "New URL is estimated to be %d bytes long, or less", new_len);
- TSDebug(PLUGIN_NAME, "New URL is %s (length %d)", dest, dest_len);
- TSDebug(PLUGIN_NAME, " matched rule %d [%s]", re->order(), re->regex());
+ TSLogDebug("New URL is estimated to be %d bytes long, or less", new_len);
+ TSLogDebug("New URL is %s (length %d)", dest, dest_len);
+ TSLogDebug(" matched rule %d [%s]", re->order(), re->regex());
// Check for a quick response, if the status option is set
if (re->status_option() > 0) {
@@ -847,7 +847,7 @@ TSRemapDoRemap(void* ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
break;
}
- TSDebug(PLUGIN_NAME, "Redirecting URL, status=%d", re->status_option());
+ TSLogDebug("Redirecting URL, status=%d", re->status_option());
TSHttpTxnSetHttpRetStatus(txnp, re->status_option());
rri->redirect = 1;
}
@@ -859,7 +859,7 @@ TSRemapDoRemap(void* ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
// Setup the new URL
if (TS_PARSE_ERROR == TSUrlParse(rri->requestBufp, rri->requestUrl, &start, start + dest_len)) {
TSHttpTxnSetHttpRetStatus(txnp, TS_HTTP_STATUS_INTERNAL_SERVER_ERROR);
- TSError("can't parse substituted URL string");
+ TSLogError("can't parse substituted URL string");
}
}
break;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4f27dcad/plugins/stats_over_http/stats_over_http.c
----------------------------------------------------------------------
diff --git a/plugins/stats_over_http/stats_over_http.c b/plugins/stats_over_http/stats_over_http.c
index 89a13af..5cfb8db 100644
--- a/plugins/stats_over_http/stats_over_http.c
+++ b/plugins/stats_over_http/stats_over_http.c
@@ -39,6 +39,9 @@
static const char* url_path = "_stats";
static int url_path_len;
+#define PLUGIN_NAME "stats_ver_http"
+#include <ts/debug.h>
+
typedef struct stats_state_t
{
TSVConn net_vc;
@@ -102,20 +105,20 @@ stats_add_resp_header(stats_state * my_state)
static void
stats_process_read(TSCont contp, TSEvent event, stats_state * my_state)
{
- TSDebug("istats", "stats_process_read(%d)", event);
+ TSLogDebug("event: %d", event);
if (event == TS_EVENT_VCONN_READ_READY) {
my_state->output_bytes = stats_add_resp_header(my_state);
TSVConnShutdown(my_state->net_vc, 1, 0);
my_state->write_vio = TSVConnWrite(my_state->net_vc, contp, my_state->resp_reader, INT64_MAX);
} else if (event == TS_EVENT_ERROR) {
- TSError("stats_process_read: Received TS_EVENT_ERROR\n");
+ TSLogError("Received TS_EVENT_ERROR");
} else if (event == TS_EVENT_VCONN_EOS) {
/* client may end the connection, simply return */
return;
} else if (event == TS_EVENT_NET_ACCEPT_FAILED) {
- TSError("stats_process_read: Received TS_EVENT_NET_ACCEPT_FAILED\n");
+ TSLogError("Received TS_EVENT_NET_ACCEPT_FAILED");
} else {
- printf("Unexpected Event %d\n", event);
+ TSLogError("Unexpected Event %d", event);
TSReleaseAssert(!"Unexpected Event");
}
}
@@ -143,7 +146,7 @@ json_out_stat(TSRecordType rec_type ATS_UNUSED, void *edata, int registered ATS_
case TS_RECORDDATATYPE_STRING:
APPEND_STAT(name, "%s", datum->rec_string); break;
default:
- TSDebug("istats", "unknown type for %s: %d", name, data_type);
+ TSLogDebug("unknown type for %s: %d", name, data_type);
break;
}
}
@@ -166,7 +169,7 @@ stats_process_write(TSCont contp, TSEvent event, stats_state * my_state)
{
if (event == TS_EVENT_VCONN_WRITE_READY) {
if (my_state->body_written == 0) {
- TSDebug("istats", "plugin adding response body");
+ TSLogDebug("plugin adding response body");
my_state->body_written = 1;
json_out_stats(my_state);
TSVIONBytesSet(my_state->write_vio, my_state->output_bytes);
@@ -175,7 +178,7 @@ stats_process_write(TSCont contp, TSEvent event, stats_state * my_state)
} else if (TS_EVENT_VCONN_WRITE_COMPLETE) {
stats_cleanup(contp, my_state);
} else if (event == TS_EVENT_ERROR) {
- TSError("stats_process_write: Received TS_EVENT_ERROR\n");
+ TSLogError("Received TS_EVENT_ERROR");
} else {
TSReleaseAssert(!"Unexpected Event");
}
@@ -208,7 +211,7 @@ stats_origin(TSCont contp ATS_UNUSED, TSEvent event ATS_UNUSED, void *edata)
TSMLoc hdr_loc = NULL, url_loc = NULL;
TSEvent reenable = TS_EVENT_HTTP_CONTINUE;
- TSDebug("istats", "in the read stuff");
+ TSLogDebug("in the read stuff");
if (TSHttpTxnClientReqGet(txnp, &reqp, &hdr_loc) != TS_SUCCESS)
goto cleanup;
@@ -218,7 +221,7 @@ stats_origin(TSCont contp ATS_UNUSED, TSEvent event ATS_UNUSED, void *edata)
int path_len = 0;
const char* path = TSUrlPathGet(reqp,url_loc,&path_len);
- TSDebug("istats","Path: %.*s",path_len,path);
+ TSLogDebug("Path: %.*s",path_len,path);
if (! (path_len != 0 && path_len == url_path_len && !memcmp(path,url_path,url_path_len)) ) {
goto notforme;
@@ -227,7 +230,7 @@ stats_origin(TSCont contp ATS_UNUSED, TSEvent event ATS_UNUSED, void *edata)
TSSkipRemappingSet(txnp,1); //not strictly necessary, but speed is everything these days
/* This is us -- register our intercept */
- TSDebug("istats", "Intercepting request");
+ TSLogDebug("Intercepting request");
icontp = TSContCreate(stats_dostuff, TSMutexCreate());
my_state = (stats_state *) TSmalloc(sizeof(*my_state));
@@ -254,12 +257,12 @@ TSPluginInit(int argc, const char *argv[])
{
TSPluginRegistrationInfo info;
- info.plugin_name = "stats";
+ info.plugin_name = "stats_over_http";
info.vendor_name = "Apache Software Foundation";
- info.support_email = "jesus@omniti.com";
+ info.support_email = "dev@trafficserver.apache.org";
if (TSPluginRegister(TS_SDK_VERSION_2_0, &info) != TS_SUCCESS)
- TSError("Plugin registration failed. \n");
+ TSLogError("Plugin registration failed. \n");
if (argc > 1) {
url_path = TSstrdup(argv[1] + ('/' == argv[1][0] ? 1 : 0)); /* Skip leading / */
@@ -269,5 +272,5 @@ TSPluginInit(int argc, const char *argv[])
/* Create a continuation with a mutex as there is a shared global structure
containing the headers to add */
TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, TSContCreate(stats_origin, NULL));
- TSDebug("istats", "stats module registered");
+ TSLogInfo("stats module registered");
}
[07/13] git commit: transform geoip_acl to new logging non-API
Posted by ig...@apache.org.
transform geoip_acl to new logging non-API
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e62f7d06
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e62f7d06
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e62f7d06
Branch: refs/heads/consistent-gzip-error-msgs
Commit: e62f7d06ff3be6c45b046d4b4284547344d9a3dc
Parents: 7a13335
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 23:18:04 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 23:18:04 2013 +0200
----------------------------------------------------------------------
plugins/experimental/geoip_acl/acl.cc | 24 ++++++++++++------------
plugins/experimental/geoip_acl/geoip_acl.cc | 10 +++++-----
plugins/experimental/geoip_acl/lulu.h | 3 ++-
3 files changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e62f7d06/plugins/experimental/geoip_acl/acl.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/geoip_acl/acl.cc b/plugins/experimental/geoip_acl/acl.cc
index ad917d5..6067dc3 100644
--- a/plugins/experimental/geoip_acl/acl.cc
+++ b/plugins/experimental/geoip_acl/acl.cc
@@ -41,9 +41,9 @@ Acl::read_html(const char* fn)
if (f.is_open()) {
_html.append(std::istreambuf_iterator<char>(f), std::istreambuf_iterator<char>());
f.close();
- TSDebug(PLUGIN_NAME, "Loaded HTML from %s", fn);
+ TSLogDebug("Loaded HTML from %s", fn);
} else {
- TSError("Unable to open HTML file %s", fn);
+ TSLogError("Unable to open HTML file %s", fn);
}
}
@@ -75,7 +75,7 @@ RegexAcl::parse_line(const char* filename, const std::string& line, int lineno)
else if (tmp == "deny")
_acl->set_allow(false);
else {
- TSError("Bad action on in %s:line %d: %s", filename, lineno, tmp.c_str());
+ TSLogError("Bad action on in %s:line %d: %s", filename, lineno, tmp.c_str());
return false;
}
// The rest are "tokens"
@@ -85,7 +85,7 @@ RegexAcl::parse_line(const char* filename, const std::string& line, int lineno)
_acl->add_token(tmp);
}
compile(regex, filename, lineno);
- TSDebug(PLUGIN_NAME, "Added regex rule for /%s/", regex.c_str());
+ TSLogDebug("Added regex rule for /%s/", regex.c_str());
return true;
}
}
@@ -106,11 +106,11 @@ RegexAcl::compile(const std::string& str, const char* filename, int lineno)
if (NULL != _rex) {
_extra = pcre_study(_rex, 0, &error);
if ((NULL == _extra) && error && (*error != 0)) {
- TSError("Failed to study regular expression in %s:line %d at offset %d: %s\n", filename, lineno, erroffset, error);
+ TSLogError("Failed to study regular expression in %s:line %d at offset %d: %s\n", filename, lineno, erroffset, error);
return false;
}
} else {
- TSError("Failed to compile regular expression in %s:line %d: %s\n", filename, lineno, error);
+ TSLogError("Failed to compile regular expression in %s:line %d: %s\n", filename, lineno, error);
return false;
}
@@ -146,9 +146,9 @@ CountryAcl::add_token(const std::string& str)
if (iso > 0 && iso < NUM_ISO_CODES) {
_iso_country_codes[iso] = true;
- TSDebug(PLUGIN_NAME, "Added %s(%d) to remap rule, ACL=%d", str.c_str(), iso, _allow);
+ TSLogDebug("Added %s(%d) to remap rule, ACL=%d", str.c_str(), iso, _allow);
} else {
- TSError("Tried setting an ISO code (%d) outside the supported range", iso);
+ TSLogError("Tried setting an ISO code (%d) outside the supported range", iso);
}
}
@@ -177,9 +177,9 @@ CountryAcl::read_regex(const char* fn)
}
}
f.close();
- TSDebug(PLUGIN_NAME, "Loaded regex rules from %s", fn);
+ TSLogDebug("Loaded regex rules from %s", fn);
} else {
- TSError("Unable to open regex file %s", fn);
+ TSLogError("Unable to open regex file %s", fn);
}
}
@@ -196,7 +196,7 @@ CountryAcl::eval(TSRemapRequestInfo *rri, TSHttpTxn txnp) const
do {
if (acl->match(path, path_len)) {
- TSDebug(PLUGIN_NAME, "Path = %.*s matched /%s/", path_len, path, acl->get_regex().c_str());
+ TSLogDebug("Path = %.*s matched /%s/", path_len, path, acl->get_regex().c_str());
return acl->eval(rri, txnp);
}
} while ((acl = acl->next()));
@@ -219,7 +219,7 @@ CountryAcl::eval(TSRemapRequestInfo *rri, TSHttpTxn txnp) const
iso = GeoIP_id_by_ipnum(gGI, ip);
if (TSIsDebugTagSet(PLUGIN_NAME)) {
const char* c = GeoIP_country_code_by_ipnum(gGI, ip);
- TSDebug(PLUGIN_NAME, "eval(): IP=%u seems to come from ISO=%d / %s", ip, iso, c);
+ TSLogDebug("eval(): IP=%u seems to come from ISO=%d / %s", ip, iso, c);
}
}
#endif
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e62f7d06/plugins/experimental/geoip_acl/geoip_acl.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/geoip_acl/geoip_acl.cc b/plugins/experimental/geoip_acl/geoip_acl.cc
index 3249ea4..4abf683 100644
--- a/plugins/experimental/geoip_acl/geoip_acl.cc
+++ b/plugins/experimental/geoip_acl/geoip_acl.cc
@@ -52,7 +52,7 @@ TSRemapInit(TSRemapInterface* api_info, char *errbuf, int errbuf_size)
gGI = GeoIP_new(GEOIP_MMAP_CACHE);
#endif
- TSDebug(PLUGIN_NAME, "remap plugin is successfully initialized");
+ TSLogDebug("remap plugin is successfully initialized");
return TS_SUCCESS; /* success */
}
@@ -61,13 +61,13 @@ TSReturnCode
TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf */, int /* errbuf_size */)
{
if (argc < 3) {
- TSError("Unable to create remap instance, need more parameters");
+ TSLogError("Unable to create remap instance, need more parameters");
return TS_ERROR;
} else {
Acl* a = NULL;
if (!strncmp(argv[2], "country", 11)) {
- TSDebug(PLUGIN_NAME, "creating an ACL rule with ISO country codes");
+ TSLogDebug("creating an ACL rule with ISO country codes");
a = new CountryAcl();
}
@@ -75,7 +75,7 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf */, int /*
a->process_args(argc, argv);
*ih = static_cast<void*>(a);
} else {
- TSError("Unable to create remap instance, no supported ACL specified as first parameter");
+ TSLogError("Unable to create remap instance, no supported ACL specified as first parameter");
return TS_ERROR;
}
}
@@ -99,7 +99,7 @@ TSRemapStatus
TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
{
if (NULL == ih) {
- TSDebug(PLUGIN_NAME, "No ACLs configured, this is probably a plugin bug");
+ TSLogDebug("No ACLs configured, this is probably a plugin bug");
} else {
Acl* a = static_cast<Acl*>(ih);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e62f7d06/plugins/experimental/geoip_acl/lulu.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/geoip_acl/lulu.h b/plugins/experimental/geoip_acl/lulu.h
index acb154f..319000e 100644
--- a/plugins/experimental/geoip_acl/lulu.h
+++ b/plugins/experimental/geoip_acl/lulu.h
@@ -47,7 +47,8 @@
#endif
// Used for Debug etc.
-static const char* PLUGIN_NAME = "geoip_acl";
+#define PLUGIN_NAME "geoip_acl"
+#include <ts/debug.h>
#endif // __LULU_H__
[11/13] git commit: transform tcp_info to new logging non-API
Posted by ig...@apache.org.
transform tcp_info to new logging non-API
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/1f440b8e
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/1f440b8e
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/1f440b8e
Branch: refs/heads/consistent-gzip-error-msgs
Commit: 1f440b8e39f7c235155525721c82f74ff40f41d0
Parents: e68e0c8
Author: Igor Galić <i....@brainsware.org>
Authored: Fri Aug 9 00:08:22 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Fri Aug 9 00:08:22 2013 +0200
----------------------------------------------------------------------
plugins/experimental/tcp_info/tcp_info.cc | 45 ++++++++++++++------------
1 file changed, 24 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1f440b8e/plugins/experimental/tcp_info/tcp_info.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/tcp_info/tcp_info.cc b/plugins/experimental/tcp_info/tcp_info.cc
index 8a9d98b..1958ff4 100644
--- a/plugins/experimental/tcp_info/tcp_info.cc
+++ b/plugins/experimental/tcp_info/tcp_info.cc
@@ -39,6 +39,9 @@
#include <sys/time.h>
#include <arpa/inet.h>
+#define PLUGIN_NAME "tcp_info"
+#include <ts/debug.h>
+
struct Config {
int sample;
const char* log_file;
@@ -66,7 +69,7 @@ load_config() {
snprintf(config_file, sizeof(config_file), "%s/%s/%s", install_dir, "conf", "tcp_info.config");
file = fopen(config_file, "r");
}
- TSDebug("tcp_info", "config file name: %s", config_file);
+ TSLogDebug("config file name: %s", config_file);
assert(file != NULL);
// read and parse the lines
@@ -83,8 +86,8 @@ load_config() {
}
if (value != NULL) {
- TSDebug("tcp_info", "config key: %s", line);
- TSDebug("tcp_info", "config value: %s", value);
+ TSLogDebug("config key: %s", line);
+ TSLogDebug("config value: %s", value);
if (strcmp(line, "sample") == 0) {
config.sample = atoi(value);
} else if (strcmp(line, "log_file") == 0) {
@@ -97,10 +100,10 @@ load_config() {
}
}
- TSDebug("tcp_info", "sample: %d", config.sample);
- TSDebug("tcp_info", "log filename: %s", config.log_file);
- TSDebug("tcp_info", "log_level: %d", config.log_level);
- TSDebug("tcp_info", "hook: %d", config.hook);
+ TSLogDebug("sample: %d", config.sample);
+ TSLogDebug("log filename: %s", config.log_file);
+ TSLogDebug("log_level: %d", config.log_level);
+ TSLogDebug("hook: %d", config.hook);
config.log_fd = open(config.log_file, O_APPEND | O_CREAT | O_RDWR, 0666);
assert(config.log_fd > 0);
@@ -169,8 +172,8 @@ log_tcp_info(const char* event_name, const char* client_ip, const char* server_i
ssize_t wrote = write(config.log_fd, buffer, bytes);
assert(wrote == bytes);
- TSDebug("tcp_info", "wrote: %d bytes to file: %s", bytes, config.log_file);
- TSDebug("tcp_info", "logging: %s", buffer);
+ TSLogDebug("wrote: %d bytes to file: %s", bytes, config.log_file);
+ TSLogDebug("logging: %s", buffer);
}
@@ -203,14 +206,14 @@ tcp_info_hook(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata)
return 0;
}
- TSDebug("tcp_info", "tcp_info_hook called, event: %s", event_name);
+ TSLogDebug("tcp_info_hook called, event: %s", event_name);
struct tcp_info tcp_info;
int tcp_info_len = sizeof(tcp_info);
int fd;
if (TSHttpSsnClientFdGet(ssnp, &fd) != TS_SUCCESS) {
- TSDebug("tcp_info", "error getting the client socket fd");
+ TSLogDebug("error getting the client socket fd");
goto done;
}
@@ -222,11 +225,11 @@ tcp_info_hook(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata)
int random = 0;
if (config.sample < 1000) {
random = rand() % 1000;
- TSDebug("tcp_info", "random: %d, config.sample: %d", random, config.sample);
+ TSLogDebug("random: %d, config.sample: %d", random, config.sample);
}
if (random < config.sample) {
- TSDebug("tcp_info", "got the tcp_info struture and now logging");
+ TSLogDebug("got the tcp_info struture and now logging");
// get the client address
const struct sockaddr *client_addr = TSHttpSsnClientAddrGet(ssnp);
@@ -246,10 +249,10 @@ tcp_info_hook(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata)
log_tcp_info(event_name, client_str, server_str, tcp_info);
}
} else {
- TSDebug("tcp_info", "tcp_info length is the wrong size");
+ TSLogDebug("tcp_info length is the wrong size");
}
} else {
- TSDebug("tcp_info", "error calling getsockopt()");
+ TSLogDebug("error calling getsockopt()");
}
done:
@@ -271,7 +274,7 @@ TSPluginInit(int, const char *[]) // int argc, const char *argv[]
info.support_email = (char*)"dev@trafficserver.apache.org";
if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS)
- TSError("Plugin registration failed. \n");
+ TSLogError("Plugin registration failed.");
// load the configuration file
load_config();
@@ -280,20 +283,20 @@ TSPluginInit(int, const char *[]) // int argc, const char *argv[]
// TODO: need another hook before the socket is closed, keeping it in for now because it will be easier to change if or when another hook is added to ATS
if ((config.hook & 1) != 0) {
TSHttpHookAdd(TS_HTTP_SSN_START_HOOK, TSContCreate(tcp_info_hook, NULL));
- TSDebug("tcp_info", "added hook to the start of the TCP connection");
+ TSLogDebug("added hook to the start of the TCP connection");
}
if ((config.hook & 2) != 0) {
TSHttpHookAdd(TS_HTTP_TXN_START_HOOK, TSContCreate(tcp_info_hook, NULL));
- TSDebug("tcp_info", "added hook to the close of the transaction");
+ TSLogDebug("added hook to the close of the transaction");
}
if ((config.hook & 4) != 0) {
TSHttpHookAdd(TS_HTTP_SEND_RESPONSE_HDR_HOOK, TSContCreate(tcp_info_hook, NULL));
- TSDebug("tcp_info", "added hook to the sending of the headers");
+ TSLogDebug("added hook to the sending of the headers");
}
if ((config.hook & 8) != 0) {
TSHttpHookAdd(TS_HTTP_SSN_CLOSE_HOOK, TSContCreate(tcp_info_hook, NULL));
- TSDebug("tcp_info", "added hook to the close of the TCP connection");
+ TSLogDebug("added hook to the close of the TCP connection");
}
- TSDebug("tcp_info", "tcp info module registered");
+ TSLogDebug("tcp info module registered");
}
[06/13] git commit: transform custom_redirect to new logging non-API
Posted by ig...@apache.org.
transform custom_redirect to new logging non-API
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/7a13335d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/7a13335d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/7a13335d
Branch: refs/heads/consistent-gzip-error-msgs
Commit: 7a13335d3f2cd1f3a412506e58a233d8fb67ba3e
Parents: da637dd
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 23:08:02 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 23:08:02 2013 +0200
----------------------------------------------------------------------
.../custom_redirect/custom_redirect.cc | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7a13335d/plugins/experimental/custom_redirect/custom_redirect.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/custom_redirect/custom_redirect.cc b/plugins/experimental/custom_redirect/custom_redirect.cc
index 6baf1a6..92c66b8 100644
--- a/plugins/experimental/custom_redirect/custom_redirect.cc
+++ b/plugins/experimental/custom_redirect/custom_redirect.cc
@@ -34,6 +34,9 @@
#include <string.h>
#include <stdlib.h>
+#define PLUGIN_NAME "custom_redirect"
+#include <ts/debug.h>
+
static char* redirect_url_header = NULL;
static int redirect_url_header_len = 0;
static int return_code = TS_HTTP_STATUS_NONE;
@@ -51,15 +54,15 @@ handle_response (TSHttpTxn txnp, TSCont /* contp ATS_UNUSED */)
int redirect_url_length;
if (TSHttpTxnServerRespGet (txnp, &resp_bufp, &resp_loc) != TS_SUCCESS) {
- TSError ("couldn't retrieve server response header\n");
+ TSLogError ("couldn't retrieve server response header");
}
else {
if ( (status = TSHttpHdrStatusGet (resp_bufp, resp_loc)) == TS_HTTP_STATUS_NONE ) {
- TSError ("couldn't retrieve status from client response header\n");
+ TSLogError ("couldn't retrieve status from client response header");
}
else {
if(TSHttpTxnClientReqGet (txnp, &req_bufp, &req_loc) != TS_SUCCESS) {
- TSError ("couldn't retrieve server response header\n");
+ TSLogError ("couldn't retrieve server response header");
}
else {
int method_len;
@@ -96,7 +99,7 @@ plugin_main_handler (TSCont contp, TSEvent event, void *edata)
case TS_EVENT_HTTP_READ_RESPONSE_HDR:
{
TSHttpTxn txnp = (TSHttpTxn) edata;
- TSDebug( "[custom_redirect1]", "MAIN_HANDLER::TS_HTTP_READ_RESPONSE_HDR_HOOK" );
+ TSLogDebug("MAIN_HANDLER::TS_HTTP_READ_RESPONSE_HDR_HOOK" );
handle_response(txnp, contp);
break;
}
@@ -104,7 +107,7 @@ plugin_main_handler (TSCont contp, TSEvent event, void *edata)
default:
{
- TSDebug( "[custom_redirect]", "default event");
+ TSLogDebug("default event");
break;
}
}
@@ -161,10 +164,10 @@ TSPluginInit (int argc, const char *argv[])
}
/*
if (TSPluginRegister (TS_SDK_VERSION_5_2 , &info) != TS_SUCCESS) {
- TSError ("[custom_redirect] Plugin registration failed.");
+ TSLogError ("Plugin registration failed.");
}
*/
- TSError("[custom_redirect] Plugin registered successfully.");
+ TSLogError("Plugin registered successfully.");
TSCont mainCont = TSContCreate(plugin_main_handler, NULL);
TSHttpHookAdd (TS_HTTP_READ_RESPONSE_HDR_HOOK, mainCont);
}
[13/13] git commit: transform esi to new logging non-API
Posted by ig...@apache.org.
transform esi to new logging non-API
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/fda89b48
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/fda89b48
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/fda89b48
Branch: refs/heads/consistent-gzip-error-msgs
Commit: fda89b48d452ae42b25801aea3749e85a58ed0c9
Parents: ea58dc2
Author: Igor Galić <i....@brainsware.org>
Authored: Fri Aug 9 01:04:09 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Fri Aug 9 01:04:09 2013 +0200
----------------------------------------------------------------------
plugins/experimental/esi/combo_handler.cc | 167 ++++++++++++-------------
plugins/experimental/esi/esi.cc | 151 +++++++++++-----------
2 files changed, 153 insertions(+), 165 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fda89b48/plugins/experimental/esi/combo_handler.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/combo_handler.cc b/plugins/experimental/esi/combo_handler.cc
index 47f0095..5b25712 100644
--- a/plugins/experimental/esi/combo_handler.cc
+++ b/plugins/experimental/esi/combo_handler.cc
@@ -38,7 +38,8 @@
using namespace std;
using namespace EsiLib;
-#define DEBUG_TAG "combo_handler"
+#define PLUGIN_NAME "combo_handler"
+#include <ts/debug.h>
#define MAX_FILE_COUNT 30
#define MAX_QUERY_LENGTH 3000
@@ -50,14 +51,6 @@ static string SIG_KEY_NAME;
static string COMBO_HANDLER_PATH;
static int COMBO_HANDLER_PATH_SIZE;
-#define LOG_ERROR(fmt, args...) do { \
- TSError("[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
- TSDebug(DEBUG_TAG, "[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
- } while (0)
-
-#define LOG_DEBUG(fmt, args...) do { \
- TSDebug(DEBUG_TAG, "[%s:%d] [%s] DEBUG: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
- } while (0)
typedef list<string> StringList;
@@ -124,7 +117,7 @@ bool
InterceptData::init(TSVConn vconn)
{
if (initialized) {
- LOG_ERROR("InterceptData already initialized!");
+ TSLogError("InterceptData already initialized!");
return false;
}
@@ -141,7 +134,7 @@ InterceptData::init(TSVConn vconn)
fetcher = new HttpDataFetcherImpl(contp, creq.client_addr, "combohandler_fetcher");
initialized = true;
- LOG_DEBUG("InterceptData initialized!");
+ TSLogDebug("InterceptData initialized!");
return true;
}
@@ -210,30 +203,30 @@ TSPluginInit(int argc, const char *argv[])
COMBO_HANDLER_PATH = DEFAULT_COMBO_HANDLER_PATH;
}
COMBO_HANDLER_PATH_SIZE = static_cast<int>(COMBO_HANDLER_PATH.size());
- LOG_DEBUG("Combo handler path is [%s]", COMBO_HANDLER_PATH.c_str());
+ TSLogDebug("Combo handler path is [%s]", COMBO_HANDLER_PATH.c_str());
SIG_KEY_NAME = ((argc > 2) && (strcmp(argv[2], "-") != 0)) ? argv[2] : "";
- LOG_DEBUG("Signature key is [%s]", SIG_KEY_NAME.c_str());
+ TSLogDebug("Signature key is [%s]", SIG_KEY_NAME.c_str());
TSReleaseAssert(pthread_key_create(&threadKey, NULL) == 0);
TSCont rrh_contp = TSContCreate(handleReadRequestHeader, NULL);
if (!rrh_contp) {
- LOG_ERROR("Could not create read request header continuation");
+ TSLogError("Could not create read request header continuation");
return;
}
TSHttpHookAdd(TS_HTTP_OS_DNS_HOOK, rrh_contp);
- if (TSHttpArgIndexReserve(DEBUG_TAG, "will save plugin-enable flag here", &arg_idx) != TS_SUCCESS) {
- LOG_ERROR("failed to reserve private data slot");
+ if (TSHttpArgIndexReserve(PLUGIN_NAME, "will save plugin-enable flag here", &arg_idx) != TS_SUCCESS) {
+ TSLogError("failed to reserve private data slot");
return;
} else {
- LOG_DEBUG("arg_idx: %d", arg_idx);
+ TSLogDebug("arg_idx: %d", arg_idx);
}
Utils::init(&TSDebug, &TSError);
- LOG_DEBUG("Plugin started");
+ TSLogDebug("Plugin started");
}
/*
@@ -252,18 +245,18 @@ handleReadRequestHeader(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edat
TSHttpTxn txnp = static_cast<TSHttpTxn>(edata);
if (event != TS_EVENT_HTTP_OS_DNS) {
- LOG_ERROR("unknown event for this plugin %d", event);
+ TSLogError("unknown event for this plugin %d", event);
return 0;
}
if (1 != reinterpret_cast<intptr_t>(TSHttpTxnArgGet(txnp, arg_idx))) {
- LOG_DEBUG("combo is disabled for this channel");
+ TSLogDebug("combo is disabled for this channel");
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
return 0;
}
- LOG_DEBUG("combo is enabled for this channel");
- LOG_DEBUG("handling TS_EVENT_HTTP_OS_DNS event...");
+ TSLogDebug("combo is enabled for this channel");
+ TSLogDebug("handling TS_EVENT_HTTP_OS_DNS event...");
TSEvent reenable_to_event = TS_EVENT_HTTP_CONTINUE;
TSMBuffer bufp;
@@ -275,7 +268,7 @@ handleReadRequestHeader(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edat
if (isComboHandlerRequest(bufp, hdr_loc, url_loc)) {
TSCont contp = TSContCreate(handleServerEvent, TSMutexCreate());
if (!contp) {
- LOG_ERROR("[%s] Could not create intercept request", __FUNCTION__);
+ TSLogError("Could not create intercept request");
reenable_to_event = TS_EVENT_HTTP_ERROR;
} else {
TSHttpTxnServerIntercept(contp, txnp);
@@ -285,16 +278,16 @@ handleReadRequestHeader(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edat
TSHttpTxnReqCacheableSet(txnp, 1);
TSHttpTxnRespCacheableSet(txnp, 1);
getClientRequest(txnp, bufp, hdr_loc, url_loc, int_data->creq);
- LOG_DEBUG("Setup server intercept to handle client request");
+ TSLogDebug("Setup server intercept to handle client request");
}
}
TSHandleMLocRelease(bufp, hdr_loc, url_loc);
} else {
- LOG_ERROR("Could not get request URL");
+ TSLogError("Could not get request URL");
}
TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
} else {
- LOG_ERROR("Could not get client request");
+ TSLogError("Could not get client request");
}
TSHttpTxnReenable(txnp, reenable_to_event);
@@ -309,10 +302,10 @@ isComboHandlerRequest(TSMBuffer bufp, TSMLoc hdr_loc, TSMLoc url_loc)
const char *method = TSHttpHdrMethodGet(bufp, hdr_loc, &method_len);
if (!method) {
- LOG_ERROR("Could not obtain method!");
+ TSLogError("Could not obtain method!");
} else {
if ((method_len != TS_HTTP_LEN_GET) || (strncasecmp(method, TS_HTTP_METHOD_GET, TS_HTTP_LEN_GET) != 0)) {
- LOG_DEBUG("Unsupported method [%.*s]", method_len, method);
+ TSLogDebug("Unsupported method [%.*s]", method_len, method);
} else {
retval = true;
}
@@ -321,12 +314,12 @@ isComboHandlerRequest(TSMBuffer bufp, TSMLoc hdr_loc, TSMLoc url_loc)
int path_len;
const char *path = TSUrlPathGet(bufp, url_loc, &path_len);
if (!path) {
- LOG_ERROR("Could not get path from request URL");
+ TSLogError("Could not get path from request URL");
retval = false;
} else {
retval = (path_len == COMBO_HANDLER_PATH_SIZE) &&
(strncasecmp(path, COMBO_HANDLER_PATH.c_str(), COMBO_HANDLER_PATH_SIZE) == 0);
- LOG_DEBUG("Path [%.*s] is %s combo handler path", path_len, path, (retval ? "a" : "not a"));
+ TSLogDebug("Path [%.*s] is %s combo handler path", path_len, path, (retval ? "a" : "not a"));
}
}
}
@@ -336,7 +329,7 @@ isComboHandlerRequest(TSMBuffer bufp, TSMLoc hdr_loc, TSMLoc url_loc)
static bool
getDefaultBucket(TSHttpTxn /* txnp ATS_UNUSED */, TSMBuffer bufp, TSMLoc hdr_obj, ClientRequest &creq)
{
- LOG_DEBUG("In getDefaultBucket");
+ TSLogDebug("In getDefaultBucket");
TSMLoc field_loc;
const char* host;
int host_len = 0;
@@ -344,18 +337,18 @@ getDefaultBucket(TSHttpTxn /* txnp ATS_UNUSED */, TSMBuffer bufp, TSMLoc hdr_obj
field_loc = TSMimeHdrFieldFind(bufp, hdr_obj, TS_MIME_FIELD_HOST, -1);
if (field_loc == TS_NULL_MLOC) {
- LOG_ERROR("Host field not found.");
+ TSLogError("Host field not found.");
return false;
}
host = TSMimeHdrFieldValueStringGet(bufp, hdr_obj, field_loc, 0, &host_len);
if (!host || host_len <= 0) {
- LOG_ERROR("Error Extracting Host Header");
+ TSLogError("Error Extracting Host Header");
TSHandleMLocRelease (bufp, hdr_obj, field_loc);
return false;
}
- LOG_DEBUG("host: %.*s", host_len, host);
+ TSLogDebug("host: %.*s", host_len, host);
creq.defaultBucket = string(host, host_len);
defaultBucketFound = true;
@@ -373,7 +366,7 @@ getDefaultBucket(TSHttpTxn /* txnp ATS_UNUSED */, TSMBuffer bufp, TSMLoc hdr_obj
TSHandleMLocRelease (bufp, hdr_obj, field_loc);
- LOG_DEBUG("defaultBucket: %s", creq.defaultBucket.data());
+ TSLogDebug("defaultBucket: %s", creq.defaultBucket.data());
return defaultBucketFound;
}
@@ -384,18 +377,18 @@ getClientRequest(TSHttpTxn txnp, TSMBuffer bufp, TSMLoc hdr_loc, TSMLoc url_loc,
const char *query = TSUrlHttpQueryGet(bufp, url_loc, &query_len);
if (!query) {
- LOG_ERROR("Could not get query from request URL");
+ TSLogError("Could not get query from request URL");
creq.status = TS_HTTP_STATUS_BAD_REQUEST;
return;
} else {
if (!getDefaultBucket(txnp, bufp, hdr_loc, creq))
{
- LOG_ERROR("failed getting Default Bucket for the request");
+ TSLogError("failed getting Default Bucket for the request");
return;
}
if (query_len > MAX_QUERY_LENGTH) {
creq.status = TS_HTTP_STATUS_BAD_REQUEST;
- LOG_ERROR("querystring too long");
+ TSLogError("querystring too long");
return;
}
parseQueryParameters(query, query_len, creq);
@@ -426,20 +419,20 @@ parseQueryParameters(const char *query, int query_len, ClientRequest &creq)
if ((param_len >= 4) && (strncmp(param, "sig=", 4) == 0)) {
if (SIG_KEY_NAME.size()) {
if (!param_start_pos) {
- LOG_DEBUG("Signature cannot be the first parameter in query [%.*s]", query_len, query);
+ TSLogDebug("Signature cannot be the first parameter in query [%.*s]", query_len, query);
} else if (param_len == 4) {
- LOG_DEBUG("Signature empty in query [%.*s]", query_len, query);
+ TSLogDebug("Signature empty in query [%.*s]", query_len, query);
} else {
// TODO - really verify the signature
- LOG_DEBUG("Verified signature successfully");
+ TSLogDebug("Verified signature successfully");
sig_verified = true;
}
if (!sig_verified) {
- LOG_DEBUG("Signature [%.*s] on query [%.*s] is invalid", param_len - 4, param + 4,
+ TSLogDebug("Signature [%.*s] on query [%.*s] is invalid", param_len - 4, param + 4,
param_start_pos, query);
}
} else {
- LOG_DEBUG("Verification not configured; ignoring signature...");
+ TSLogDebug("Verification not configured; ignoring signature...");
}
break; // nothing useful after the signature
}
@@ -459,13 +452,13 @@ parseQueryParameters(const char *query, int query_len, ClientRequest &creq)
}
}
}
- LOG_DEBUG("Common prefix is [%.*s], common prefix path is [%.*s]", common_prefix_size, common_prefix,
+ TSLogDebug("Common prefix is [%.*s], common prefix path is [%.*s]", common_prefix_size, common_prefix,
common_prefix_path_size, common_prefix_path);
}
else {
if (common_prefix_path_size) {
if (colon_pos >= param_start_pos) { // we have a colon in this param as well?
- LOG_ERROR("Ambiguous 'bucket': [%.*s] specified in common prefix and [%.*s] specified in "
+ TSLogError("Ambiguous 'bucket': [%.*s] specified in common prefix and [%.*s] specified in "
"current parameter [%.*s]", common_prefix_path_size, common_prefix_path,
colon_pos - param_start_pos, param, param_len, param);
creq.file_urls.clear();
@@ -475,7 +468,7 @@ parseQueryParameters(const char *query, int query_len, ClientRequest &creq)
}
else if (colon_pos >= param_start_pos) { // we have a colon
if ((colon_pos == param_start_pos) || (colon_pos == (i - 1))) {
- LOG_ERROR("Colon-separated path [%.*s] has empty part(s)", param_len, param);
+ TSLogError("Colon-separated path [%.*s] has empty part(s)", param_len, param);
creq.file_urls.clear();
break;
}
@@ -494,7 +487,7 @@ parseQueryParameters(const char *query, int query_len, ClientRequest &creq)
}
file_url.append(param, param_len);
creq.file_urls.push_back(file_url);
- LOG_DEBUG("Added file path [%s]", file_url.c_str());
+ TSLogDebug("Added file path [%s]", file_url.c_str());
file_url.resize(file_base_url_size);
}
}
@@ -506,14 +499,14 @@ parseQueryParameters(const char *query, int query_len, ClientRequest &creq)
if (!creq.file_urls.size()) {
creq.status = TS_HTTP_STATUS_BAD_REQUEST;
} else if (SIG_KEY_NAME.size() && !sig_verified) {
- LOG_DEBUG("Invalid/empty signature found; Need valid signature");
+ TSLogDebug("Invalid/empty signature found; Need valid signature");
creq.status = TS_HTTP_STATUS_FORBIDDEN;
creq.file_urls.clear();
}
if (creq.file_urls.size() > MAX_FILE_COUNT) {
creq.status = TS_HTTP_STATUS_BAD_REQUEST;
- LOG_ERROR("too many files in url");
+ TSLogError("too many files in URL");
creq.file_urls.clear();
}
@@ -537,7 +530,7 @@ checkGzipAcceptance(TSMBuffer bufp, TSMLoc hdr_loc, ClientRequest &creq)
creq.gzip_accepted = true;
}
} else {
- LOG_DEBUG("Error while getting value # %d of header [%.*s]", i, TS_MIME_LEN_ACCEPT_ENCODING,
+ TSLogDebug("Error while getting value # %d of header [%.*s]", i, TS_MIME_LEN_ACCEPT_ENCODING,
TS_MIME_FIELD_ACCEPT_ENCODING);
}
if (creq.gzip_accepted) {
@@ -546,7 +539,7 @@ checkGzipAcceptance(TSMBuffer bufp, TSMLoc hdr_loc, ClientRequest &creq)
}
TSHandleMLocRelease(bufp, hdr_loc, field_loc);
}
- LOG_DEBUG("Client %s gzip encoding", (creq.gzip_accepted ? "accepts" : "does not accept"));
+ TSLogDebug("Client %s gzip encoding", (creq.gzip_accepted ? "accepts" : "does not accept"));
}
static int
@@ -557,68 +550,68 @@ handleServerEvent(TSCont contp, TSEvent event, void *edata)
switch (event) {
case TS_EVENT_NET_ACCEPT_FAILED:
- LOG_DEBUG("Received net accept failed event; going to abort continuation");
+ TSLogDebug("Received net accept failed event; going to abort continuation");
int_data->read_complete = int_data->write_complete = true;
break;
case TS_EVENT_NET_ACCEPT:
- LOG_DEBUG("Received net accept event");
+ TSLogDebug("Received net accept event");
if (!initRequestProcessing(*int_data, edata, write_response)) {
- LOG_ERROR("Could not initialize request processing");
+ TSLogError("Could not initialize request processing");
return 0;
}
break;
case TS_EVENT_VCONN_READ_READY:
- LOG_DEBUG("Received read ready event");
+ TSLogDebug("Received read ready event");
if (!readInterceptRequest(*int_data)) {
- LOG_ERROR("Error while reading from input vio");
+ TSLogError("Error while reading from input vio");
return 0;
}
break;
case TS_EVENT_VCONN_READ_COMPLETE:
case TS_EVENT_VCONN_EOS:
- LOG_DEBUG("Received read complete/eos event %d", event);
+ TSLogDebug("Received read complete/eos event %d", event);
int_data->read_complete = true;
break;
case TS_EVENT_VCONN_WRITE_READY:
- LOG_DEBUG("Received write ready event");
+ TSLogDebug("Received write ready event");
break;
case TS_EVENT_VCONN_WRITE_COMPLETE:
- LOG_DEBUG("Received write complete event");
+ TSLogDebug("Received write complete event");
int_data->write_complete = true;
break;
case TS_EVENT_ERROR:
- LOG_ERROR("Received error event!");
+ TSLogError("Received error event!");
break;
default:
if (int_data->fetcher && int_data->fetcher->isFetchEvent(event)) {
if (!int_data->fetcher->handleFetchEvent(event, edata)) {
- LOG_ERROR("Couldn't handle fetch request event %d", event);
+ TSLogError("Couldn't handle fetch request event %d", event);
}
write_response = int_data->fetcher->isFetchComplete();
} else {
- LOG_DEBUG("Unexpected event %d", event);
+ TSLogDebug("Unexpected event %d", event);
}
break;
}
if (write_response) {
if (!writeResponse(*int_data)) {
- LOG_ERROR("Couldn't write response");
+ TSLogError("Couldn't write response");
int_data->write_complete = true;
} else {
- LOG_DEBUG("Wrote response successfully");
+ TSLogDebug("Wrote response successfully");
}
}
if (int_data->read_complete && int_data->write_complete) {
- LOG_DEBUG("Completed request processing. Shutting down...");
+ TSLogDebug("Completed request processing. Shutting down...");
delete int_data;
TSContDestroy(contp);
}
@@ -631,7 +624,7 @@ initRequestProcessing(InterceptData &int_data, void *edata, bool &write_response
{
TSAssert(int_data.initialized == false);
if (!int_data.init(static_cast<TSVConn>(edata))) {
- LOG_ERROR("Could not initialize intercept data!");
+ TSLogError("Could not initialize intercept data!");
return false;
}
@@ -639,13 +632,13 @@ initRequestProcessing(InterceptData &int_data, void *edata, bool &write_response
for (StringList::iterator iter = int_data.creq.file_urls.begin();
iter != int_data.creq.file_urls.end(); ++iter) {
if (!int_data.fetcher->addFetchRequest(*iter)) {
- LOG_ERROR("Couldn't add fetch request for URL [%s]", iter->c_str());
+ TSLogError("Couldn't add fetch request for URL [%s]", iter->c_str());
} else {
- LOG_DEBUG("Added fetch request for URL [%s]", iter->c_str());
+ TSLogDebug("Added fetch request for URL [%s]", iter->c_str());
}
}
} else {
- LOG_DEBUG("Client request status [%d] not ok; Not fetching URLs", int_data.creq.status);
+ TSLogDebug("Client request status [%d] not ok; Not fetching URLs", int_data.creq.status);
write_response = true;
}
return true;
@@ -657,7 +650,7 @@ readInterceptRequest(InterceptData &int_data)
TSAssert(!int_data.read_complete);
int avail = TSIOBufferReaderAvail(int_data.input.reader);
if (avail == TS_ERROR) {
- LOG_ERROR("Error while getting number of bytes available");
+ TSLogError("Error while getting number of bytes available");
return false;
}
@@ -677,7 +670,7 @@ readInterceptRequest(InterceptData &int_data)
block = TSIOBufferBlockNext(block);
}
}
- LOG_DEBUG("Consumed %d bytes from input vio", consumed);
+ TSLogDebug("Consumed %d bytes from input vio", consumed);
TSIOBufferReaderConsume(int_data.input.reader, consumed);
@@ -685,7 +678,7 @@ readInterceptRequest(InterceptData &int_data)
TSVIONDoneSet(int_data.input.vio, TSVIONDoneGet(int_data.input.vio) + consumed);
if (!int_data.read_complete) {
- LOG_DEBUG("Re-enabling input VIO as request header not completely read yet");
+ TSLogDebug("Re-enabling input VIO as request header not completely read yet");
TSVIOReenable(int_data.input.vio);
}
return true;
@@ -710,46 +703,46 @@ writeResponse(InterceptData &int_data)
int n_bytes_written = 0;
if (int_data.creq.status != TS_HTTP_STATUS_OK) {
if (!writeErrorResponse(int_data, n_bytes_written)) {
- LOG_ERROR("Couldn't write response error");
+ TSLogError("Couldn't write response error");
return false;
}
} else {
n_bytes_written = OK_REPLY_LINE.size();
if (TSIOBufferWrite(int_data.output.buffer, OK_REPLY_LINE.data(), n_bytes_written) == TS_ERROR) {
- LOG_ERROR("Error while writing reply line");
+ TSLogError("Error while writing reply line");
return false;
}
if (!writeStandardHeaderFields(int_data, n_bytes_written)) {
- LOG_ERROR("Could not write standard header fields");
+ TSLogError("Could not write standard header fields");
return false;
}
if (resp_header_fields.size()) {
if (TSIOBufferWrite(int_data.output.buffer, resp_header_fields.data(),
resp_header_fields.size()) == TS_ERROR) {
- LOG_ERROR("Error while writing additional response header fields");
+ TSLogError("Error while writing additional response header fields");
return false;
}
n_bytes_written += resp_header_fields.size();
}
if (TSIOBufferWrite(int_data.output.buffer, "\r\n", 2) == TS_ERROR) {
- LOG_ERROR("Error while writing header terminator");
+ TSLogError("Error while writing header terminator");
return false;
}
n_bytes_written += 2;
for (ByteBlockList::iterator iter = body_blocks.begin(); iter != body_blocks.end(); ++iter) {
if (TSIOBufferWrite(int_data.output.buffer, iter->data, iter->data_len) == TS_ERROR) {
- LOG_ERROR("Error while writing content");
+ TSLogError("Error while writing content");
return false;
}
n_bytes_written += iter->data_len;
}
}
- LOG_DEBUG("Wrote reply of size %d", n_bytes_written);
+ TSLogDebug("Wrote reply of size %d", n_bytes_written);
TSVIONBytesSet(int_data.output.vio, n_bytes_written);
TSVIOReenable(int_data.output.vio);
@@ -790,7 +783,7 @@ prepareResponse(InterceptData &int_data, ByteBlockList &body_blocks, string &res
TSHandleMLocRelease(resp_data.bufp, resp_data.hdr_loc, field_loc);
}
} else {
- LOG_ERROR("Could not get content for requested URL [%s]", iter->c_str());
+ TSLogError("Could not get content for requested URL [%s]", iter->c_str());
int_data.creq.status = TS_HTTP_STATUS_BAD_REQUEST;
break;
}
@@ -805,13 +798,13 @@ prepareResponse(InterceptData &int_data, ByteBlockList &body_blocks, string &res
resp_header_fields.append(line_buf, line_size);
}
}
- LOG_DEBUG("Prepared response header field\n%s", resp_header_fields.c_str());
+ TSLogDebug("Prepared response header field\n%s", resp_header_fields.c_str());
}
}
if ((int_data.creq.status == TS_HTTP_STATUS_OK) && int_data.creq.gzip_accepted) {
if (!gzip(body_blocks, int_data.gzipped_data)) {
- LOG_ERROR("Could not gzip content!");
+ TSLogError("Could not gzip content!");
int_data.creq.status = TS_HTTP_STATUS_INTERNAL_SERVER_ERROR;
} else {
body_blocks.clear();
@@ -860,7 +853,7 @@ writeStandardHeaderFields(InterceptData &int_data, int &n_bytes_written)
{
if (TSIOBufferWrite(int_data.output.buffer, INVARIANT_FIELD_LINES,
INVARIANT_FIELD_LINES_SIZE) == TS_ERROR) {
- LOG_ERROR("Error while writing invariant fields");
+ TSLogError("Error while writing invariant fields");
return false;
}
n_bytes_written += INVARIANT_FIELD_LINES_SIZE;
@@ -869,7 +862,7 @@ writeStandardHeaderFields(InterceptData &int_data, int &n_bytes_written)
int last_modified_line_size = strftime(last_modified_line, 128, "Last-Modified: %a, %d %b %Y %T GMT\r\n",
gmtime(&time_now));
if (TSIOBufferWrite(int_data.output.buffer, last_modified_line, last_modified_line_size) == TS_ERROR) {
- LOG_ERROR("Error while writing last-modified fields");
+ TSLogError("Error while writing last-modified fields");
return false;
}
n_bytes_written += last_modified_line_size;
@@ -892,7 +885,7 @@ writeErrorResponse(InterceptData &int_data, int &n_bytes_written)
break;
}
if (TSIOBufferWrite(int_data.output.buffer, response->data(), response->size()) == TS_ERROR) {
- LOG_ERROR("Error while writing error response");
+ TSLogError("Error while writing error response");
return false;
}
n_bytes_written += response->size();
@@ -922,7 +915,7 @@ TSRemapInit(TSRemapInterface* api_info, char *errbuf, int errbuf_size)
return TS_ERROR;
}
- TSDebug(DEBUG_TAG, "%s plugin's remap part is initialized", DEBUG_TAG);
+ TSLogDebug("remap part initialized");
return TS_SUCCESS;
}
@@ -933,7 +926,7 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* errbuf,
{
*ih = NULL;
- TSDebug(DEBUG_TAG, "%s Remap Instance for '%s' created", DEBUG_TAG, argv[0]);
+ TSLogDebug("Remap Instance for '%s' created", argv[0]);
return TS_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fda89b48/plugins/experimental/esi/esi.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/esi.cc b/plugins/experimental/esi/esi.cc
index 994f5f0..8f695d1 100644
--- a/plugins/experimental/esi/esi.cc
+++ b/plugins/experimental/esi/esi.cc
@@ -62,7 +62,7 @@ struct OptionInfo
static HandlerManager *gHandlerManager = NULL;
-#define DEBUG_TAG "plugin_esi"
+#define PLUGIN_NAME "plugin_esi"
#define PROCESSOR_DEBUG_TAG "plugin_esi_processor"
#define GZIP_DEBUG_TAG "plugin_esi_gzip"
#define PARSER_DEBUG_TAG "plugin_esi_parser"
@@ -71,6 +71,8 @@ static HandlerManager *gHandlerManager = NULL;
#define HANDLER_MGR_DEBUG_TAG "plugin_esi_handler_mgr"
#define EXPR_DEBUG_TAG VARS_DEBUG_TAG
+#include <ts/debug.h>
+
#define MIME_FIELD_XESI "X-Esi"
#define MIME_FIELD_XESI_LEN 5
@@ -181,10 +183,9 @@ ContData::checkXformStatus() {
int retval = TSVConnClosedGet(contp);
if ((retval == TS_ERROR) || retval) {
if (retval == TS_ERROR) {
- TSDebug(debug_tag, "[%s] Error while getting close status of transformation at state %d",
- __FUNCTION__, curr_state);
+ TSLogDebug("Error while getting close status of transformation at state %d", curr_state);
} else {
- TSDebug(debug_tag, "[%s] Vconn closed", __FUNCTION__);
+ TSLogDebug("Vconn closed");
}
xform_closed = true;
}
@@ -195,12 +196,12 @@ bool
ContData::init()
{
if (initialized) {
- TSError("[%s] ContData already initialized!", __FUNCTION__);
+ TSLogError("ContData already initialized!");
return false;
}
string tmp_tag;
- createDebugTag(DEBUG_TAG, contp, tmp_tag);
+ createDebugTag(PLUGIN_NAME, contp, tmp_tag);
memcpy(debug_tag, tmp_tag.c_str(), tmp_tag.length() + 1);
checkXformStatus();
@@ -211,7 +212,7 @@ ContData::init()
// Get upstream VIO
input_vio = TSVConnWriteVIOGet(contp);
if (!input_vio) {
- TSError("[%s] Error while getting input vio", __FUNCTION__);
+ TSLogError("Error while getting input vio");
goto lReturn;
}
input_reader = TSVIOReaderGet(input_vio);
@@ -220,7 +221,7 @@ ContData::init()
TSVConn output_conn;
output_conn = TSTransformOutputVConnGet(contp);
if(!output_conn) {
- TSError("[%s] Error while getting transform VC", __FUNCTION__);
+ TSLogError("Error while getting transform VC");
goto lReturn;
}
output_buffer = TSIOBufferCreate();
@@ -245,13 +246,11 @@ ContData::init()
esi_gzip = new EsiGzip(createDebugTag(GZIP_DEBUG_TAG, contp, gzip_tag), &TSDebug, &TSError);
- TSDebug(debug_tag, "[%s] Set input data type to [%s]", __FUNCTION__,
- DATA_TYPE_NAMES_[input_type]);
+ TSLogDebug("Set input data type to [%s]", DATA_TYPE_NAMES_[input_type]);
retval = true;
} else {
- TSDebug(debug_tag, "[%s] Transformation closed during initialization; Returning false",
- __FUNCTION__);
+ TSLogDebug("Transformation closed during initialization; Returning false");
}
lReturn:
@@ -264,7 +263,7 @@ ContData::getClientState() {
TSMBuffer req_bufp;
TSMLoc req_hdr_loc;
if (TSHttpTxnClientReqGet(txnp, &req_bufp, &req_hdr_loc) != TS_SUCCESS) {
- TSError("[%s] Error while retrieving client request", __FUNCTION__);
+ TSLogError("Error while retrieving client request");
return;
}
@@ -281,7 +280,7 @@ ContData::getClientState() {
TSMBuffer bufp;
TSMLoc url_loc;
if(TSHttpTxnPristineUrlGet(txnp, &bufp, &url_loc) != TS_SUCCESS) {
- TSError("[%s] Error while retrieving hdr url", __FUNCTION__);
+ TSLogError("Error while retrieving hdr url");
return;
}
if (url_loc) {
@@ -290,7 +289,7 @@ ContData::getClientState() {
}
int length;
request_url = TSUrlStringGet(bufp, url_loc, &length);
- TSDebug(DEBUG_TAG, "[%s] Got request URL [%s]", __FUNCTION__, request_url ? request_url : "(null)");
+ TSLogDebug("Got request URL [%s]", request_url ? request_url : "(null)");
int query_len;
const char *query = TSUrlHttpQueryGet(bufp, url_loc, &query_len);
if (query) {
@@ -354,10 +353,10 @@ ContData::getClientState() {
if (gzip_output) {
if (option_info->disable_gzip_output) {
- TSDebug(DEBUG_TAG, "[%s] disable gzip output", __FUNCTION__);
+ TSLogDebug("disable gzip output");
gzip_output = false;
} else {
- TSDebug(DEBUG_TAG, "[%s] Client accepts gzip encoding; will compress output", __FUNCTION__);
+ TSLogDebug("Client accepts gzip encoding; will compress output");
}
}
@@ -374,17 +373,17 @@ ContData::fillPostHeader(TSMBuffer bufp, TSMLoc hdr_loc) {
for (int i = 0; i < n_mime_headers; ++i) {
field_loc = TSMimeHdrFieldGet(bufp, hdr_loc, i);
if (!field_loc) {
- TSDebug(DEBUG_TAG, "[%s] Error while obtaining header field #%d", __FUNCTION__, i);
+ TSLogDebug("Error while obtaining header field #%d", i);
continue;
}
name = TSMimeHdrFieldNameGet(bufp, hdr_loc, field_loc, &name_len);
if (name) {
if (Utils::areEqual(name, name_len, TS_MIME_FIELD_TRANSFER_ENCODING, TS_MIME_LEN_TRANSFER_ENCODING)) {
- TSDebug(DEBUG_TAG, "[%s] Not retaining transfer encoding header", __FUNCTION__);
+ TSLogDebug("Not retaining transfer encoding header");
} else if (Utils::areEqual(name, name_len, MIME_FIELD_XESI, MIME_FIELD_XESI_LEN)) {
- TSDebug(DEBUG_TAG, "[%s] Not retaining 'X-Esi' header", __FUNCTION__);
+ TSLogDebug("Not retaining 'X-Esi' header");
} else if (Utils::areEqual(name, name_len, TS_MIME_FIELD_CONTENT_LENGTH, TS_MIME_LEN_CONTENT_LENGTH)) {
- TSDebug(DEBUG_TAG, "[%s] Not retaining 'Content-length' header", __FUNCTION__);
+ TSLogDebug("Not retaining 'Content-length' header");
} else {
header.assign(name, name_len);
header.append(": ");
@@ -392,17 +391,17 @@ ContData::fillPostHeader(TSMBuffer bufp, TSMLoc hdr_loc) {
for (int j = 0; j < n_field_values; ++j) {
value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, j, &value_len);
if ( NULL == value || !value_len ) {
- TSDebug(DEBUG_TAG, "[%s] Error while getting value #%d of header [%.*s]",
- __FUNCTION__, j, name_len, name);
+ TSLogDebug("Error while getting value #%d of header [%.*s]",
+ j, name_len, name);
} else {
if (Utils::areEqual(name, name_len, TS_MIME_FIELD_VARY, TS_MIME_LEN_VARY) &&
Utils::areEqual(value, value_len, TS_MIME_FIELD_ACCEPT_ENCODING,
TS_MIME_LEN_ACCEPT_ENCODING)) {
- TSDebug(DEBUG_TAG, "[%s] Not retaining 'vary: accept-encoding' header", __FUNCTION__);
+ TSLogDebug("Not retaining 'vary: accept-encoding' header");
} else if (Utils::areEqual(name, name_len, TS_MIME_FIELD_CONTENT_ENCODING,
TS_MIME_LEN_CONTENT_ENCODING) &&
Utils::areEqual(value, value_len, TS_HTTP_VALUE_GZIP, TS_HTTP_LEN_GZIP)) {
- TSDebug(DEBUG_TAG, "[%s] Not retaining 'content-encoding: gzip' header", __FUNCTION__);
+ TSLogDebug("Not retaining 'content-encoding: gzip' header");
} else {
if (header[header.size() - 2] != ':') {
header.append(", ");
@@ -411,8 +410,8 @@ ContData::fillPostHeader(TSMBuffer bufp, TSMLoc hdr_loc) {
checkForCacheHeader(name, name_len, value, value_len,
os_response_cacheable);
if (!os_response_cacheable) {
- TSDebug(DEBUG_TAG, "[%s] Header [%.*s] with value [%.*s] is a no-cache header",
- __FUNCTION__, name_len, name, value_len, value);
+ TSLogDebug("Header [%.*s] with value [%.*s] is a no-cache header",
+ name_len, name, value_len, value);
break;
}
}
@@ -494,7 +493,7 @@ ContData::~ContData()
}
static int removeCacheHandler(TSCont contp, TSEvent /* event ATS_UNUSED */, void * /* edata ATS_UNUSED */) {
- //TSDebug(DEBUG_TAG, "[%s] event: %d", __FUNCTION__, (int)event);
+ //TSLogDebug("event: %d", (int)event);
TSContDestroy(contp);
//just ignore cache remove message
return 0;
@@ -698,8 +697,8 @@ transformData(TSCont contp)
if (process_input_complete) {
TSDebug(cont_data->debug_tag, "[%s] Completed reading input...", __FUNCTION__);
if (cont_data->input_type == DATA_TYPE_PACKED_ESI) {
- TSDebug(DEBUG_TAG, "[%s] Going to use packed node list of size %d",
- __FUNCTION__, (int) cont_data->packed_node_list.size());
+ TSLogDebug("Going to use packed node list of size %d",
+ (int) cont_data->packed_node_list.size());
if (cont_data->esi_proc->usePackedNodeList(cont_data->packed_node_list) == EsiProcessor::UNPACK_FAILURE) {
removeCacheKey(cont_data->txnp);
@@ -1081,7 +1080,7 @@ modifyResponseHeader(TSCont contp, TSEvent event, void *edata) {
for (int i = 0; i < n_mime_headers; ++i) {
field_loc = TSMimeHdrFieldGet(bufp, hdr_loc, i);
if (!field_loc) {
- TSDebug(DEBUG_TAG, "[%s] Error while obtaining header field #%d", __FUNCTION__, i);
+ TSLogDebug("Error while obtaining header field #%d", i);
continue;
}
name = TSMimeHdrFieldNameGet(bufp, hdr_loc, field_loc, &name_len);
@@ -1117,8 +1116,8 @@ modifyResponseHeader(TSCont contp, TSEvent event, void *edata) {
for (int j = 0; j < n_field_values; ++j) {
value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, j, &value_len);
if ( NULL == value || !value_len ) {
- TSDebug(DEBUG_TAG, "[%s] Error while getting value #%d of header [%.*s]",
- __FUNCTION__, j, name_len, name);
+ TSLogDebug("Error while getting value #%d of header [%.*s]",
+ j, name_len, name);
} else {
if (!mod_data->option_info->packed_node_support || mod_data->cache_txn) {
bool response_cacheable, is_cache_header;
@@ -1131,7 +1130,7 @@ modifyResponseHeader(TSCont contp, TSEvent event, void *edata) {
} // end for
}
if (destroy_header) {
- TSDebug(DEBUG_TAG, "[%s] Removing header with name [%.*s]", __FUNCTION__, name_len, name);
+ TSLogDebug("Removing header with name [%.*s]", name_len, name);
TSMimeHdrFieldDestroy(bufp, hdr_loc, field_loc);
--n_mime_headers;
--i;
@@ -1167,10 +1166,10 @@ modifyResponseHeader(TSCont contp, TSEvent event, void *edata) {
}
TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
- TSDebug(DEBUG_TAG, "[%s] Inspected client-bound headers", __FUNCTION__);
+ TSLogDebug("Inspected client-bound headers");
retval = 1;
} else {
- TSError("[%s] Error while getting response from txn", __FUNCTION__);
+ TSLogError("Error while getting response from txn");
}
lReturn:
@@ -1204,8 +1203,7 @@ checkHeaderValue(TSMBuffer bufp, TSMLoc hdr_loc, const char *name, int name_len,
retval = true;
}
} else {
- TSDebug(DEBUG_TAG, "[%s] Error while getting value # %d of header [%.*s]", __FUNCTION__,
- i, name_len, name);
+ TSLogDebug("Error while getting value # %d of header [%.*s]", i, name_len, name);
}
if (retval) {
break;
@@ -1236,7 +1234,7 @@ maskOsCacheHeaders(TSHttpTxn txnp) {
for (int i = 0; i < n_mime_headers; ++i) {
field_loc = TSMimeHdrFieldGet(bufp, hdr_loc, i);
if (!field_loc) {
- TSDebug(DEBUG_TAG, "[%s] Error while obtaining header field #%d", __FUNCTION__, i);
+ TSLogDebug("Error while obtaining header field #%d", i);
continue;
}
name = TSMimeHdrFieldNameGet(bufp, hdr_loc, field_loc, &name_len);
@@ -1246,16 +1244,16 @@ maskOsCacheHeaders(TSHttpTxn txnp) {
for (int j = 0; j < n_field_values; ++j) {
value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, j, &value_len);
if ( NULL == value || !value_len ) {
- TSDebug(DEBUG_TAG, "[%s] Error while getting value #%d of header [%.*s]",
- __FUNCTION__, j, name_len, name);
+ TSLogDebug("Error while getting value #%d of header [%.*s]",
+ j, name_len, name);
} else {
is_cache_header = checkForCacheHeader(name, name_len, value, value_len, os_response_cacheable);
if (!os_response_cacheable) {
break;
}
if (is_cache_header) {
- TSDebug(DEBUG_TAG, "[%s] Masking OS cache header [%.*s] with value [%.*s]. ",
- __FUNCTION__, name_len, name, value_len, value);
+ TSLogDebug("Masking OS cache header [%.*s] with value [%.*s]. ",
+ name_len, name, value_len, value);
mask_header = true;
}
} // end if got value string
@@ -1289,7 +1287,7 @@ isTxnTransformable(TSHttpTxn txnp, bool is_cache_txn, bool * intercept_header, b
bool retval = false;
if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
- TSError("[%s] Couldn't get txn header", __FUNCTION__);
+ TSLogError("Couldn't get txn header");
return false;
}
@@ -1297,7 +1295,7 @@ isTxnTransformable(TSHttpTxn txnp, bool is_cache_txn, bool * intercept_header, b
const char *method;
method = TSHttpHdrMethodGet(bufp, hdr_loc, &method_len);
if (method == NULL) {
- TSError("[%s] Couldn't get method", __FUNCTION__);
+ TSLogError("Couldn't get method");
TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
return false;
}
@@ -1308,7 +1306,7 @@ isTxnTransformable(TSHttpTxn txnp, bool is_cache_txn, bool * intercept_header, b
else if (!(((method_len >= TS_HTTP_LEN_POST && memcmp(method, TS_HTTP_METHOD_POST, TS_HTTP_LEN_POST) == 0)) ||
((method_len >= TS_HTTP_LEN_GET && memcmp(method, TS_HTTP_METHOD_GET, TS_HTTP_LEN_GET) == 0))))
{
- TSDebug(DEBUG_TAG, "[%s] method %.*s will be ignored", __FUNCTION__, method_len, method);
+ TSLogDebug("method %.*s will be ignored", method_len, method);
TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
return false;
}
@@ -1317,7 +1315,7 @@ isTxnTransformable(TSHttpTxn txnp, bool is_cache_txn, bool * intercept_header, b
header_obtained = is_cache_txn ? TSHttpTxnCachedRespGet(txnp, &bufp, &hdr_loc) :
TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc);
if (header_obtained != TS_SUCCESS) {
- TSError("[%s] Couldn't get txn header", __FUNCTION__);
+ TSLogError("Couldn't get txn header");
return false;
}
@@ -1325,11 +1323,10 @@ isTxnTransformable(TSHttpTxn txnp, bool is_cache_txn, bool * intercept_header, b
*intercept_header = checkHeaderValue(bufp, hdr_loc, SERVER_INTERCEPT_HEADER, SERVER_INTERCEPT_HEADER_LEN);
if (*intercept_header) {
if (is_cache_txn) {
- TSDebug(DEBUG_TAG, "[%s] Packed ESI document found in cache; will process", __FUNCTION__);
+ TSLogDebug("Packed ESI document found in cache; will process");
retval = true;
} else {
- TSDebug(DEBUG_TAG, "[%s] Found Intercept header in server response; document not processable",
- __FUNCTION__);
+ TSLogDebug("Found Intercept header in server response; document not processable");
}
break; // found internal header; no other detection required
}
@@ -1341,17 +1338,17 @@ isTxnTransformable(TSHttpTxn txnp, bool is_cache_txn, bool * intercept_header, b
break;
}
if (resp_status != TS_HTTP_STATUS_OK) {
- TSDebug(DEBUG_TAG, "[%s] Not handling non-OK response status %d", __FUNCTION__, resp_status);
+ TSLogDebug("Not handling non-OK response status %d", resp_status);
break;
}
if (!checkHeaderValue(bufp, hdr_loc, TS_MIME_FIELD_CONTENT_TYPE, TS_MIME_LEN_CONTENT_TYPE,
"text/", 5, true)) {
- TSDebug(DEBUG_TAG, "[%s] Not text content", __FUNCTION__);
+ TSLogDebug("Not text content");
break;
}
if (!checkHeaderValue(bufp, hdr_loc, MIME_FIELD_XESI, MIME_FIELD_XESI_LEN)) {
- TSDebug(DEBUG_TAG, "[%s] ESI header [%s] not found", __FUNCTION__, MIME_FIELD_XESI);
+ TSLogDebug("ESI header [%s] not found", MIME_FIELD_XESI);
break;
}
@@ -1377,18 +1374,18 @@ isCacheObjTransformable(TSHttpTxn txnp, bool * intercept_header, bool * head_onl
}
*/
- TSDebug(DEBUG_TAG, "[%s] doc found in cache, will add transformation", __FUNCTION__);
+ TSLogDebug("doc found in cache, will add transformation");
return isTxnTransformable(txnp, true, intercept_header, head_only);
}
- TSDebug(DEBUG_TAG, "[%s] cache object's status is %d; not transformable",
- __FUNCTION__, obj_status);
+ TSLogDebug("cache object's status is %d; not transformable",
+ obj_status);
return false;
}
static bool
isInterceptRequest(TSHttpTxn txnp) {
if (TSHttpIsInternalRequest(txnp) != TS_SUCCESS) {
- TSDebug(DEBUG_TAG, "[%s] Skipping external request", __FUNCTION__);
+ TSLogDebug("Skipping external request");
return false;
}
@@ -1408,10 +1405,10 @@ isInterceptRequest(TSHttpTxn txnp) {
} else {
if ((method_len != TS_HTTP_LEN_POST) ||
(strncasecmp(method, TS_HTTP_METHOD_POST, TS_HTTP_LEN_POST))) {
- TSDebug(DEBUG_TAG, "[%s] Method [%.*s] invalid, [%s] expected", __FUNCTION__, method_len, method,
+ TSLogDebug("Method [%.*s] invalid, [%s] expected", method_len, method,
TS_HTTP_METHOD_POST);
} else {
- TSDebug(DEBUG_TAG, "[%s] Valid server intercept method found", __FUNCTION__);
+ TSLogDebug("Valid server intercept method found");
valid_request = true;
}
}
@@ -1510,7 +1507,7 @@ addTransform(TSHttpTxn txnp, const bool processing_os_response,
TSHttpTxnUntransformedRespCache(txnp, 1);
}
- TSDebug(DEBUG_TAG, "[%s] Added transformation (0x%p)", __FUNCTION__, contp);
+ TSLogDebug("Added transformation (0x%p)", contp);
return true;
lFail:
@@ -1534,15 +1531,15 @@ globalHookHandler(TSCont contp, TSEvent event, void *edata) {
switch (event) {
case TS_EVENT_HTTP_READ_REQUEST_HDR:
- TSDebug(DEBUG_TAG, "[%s] handling read request header event...", __FUNCTION__);
+ TSLogDebug("handling read request header event...");
if (intercept_req) {
if (!setupServerIntercept(txnp)) {
- TSError("[%s] Could not setup server intercept", __FUNCTION__);
+ TSLogError("Could not setup server intercept");
} else {
- TSDebug(DEBUG_TAG, "[%s] Setup server intercept", __FUNCTION__);
+ TSLogDebug("Setup server intercept");
}
} else {
- TSDebug(DEBUG_TAG, "[%s] Not setting up intercept", __FUNCTION__);
+ TSLogDebug("Not setting up intercept");
}
break;
@@ -1551,13 +1548,12 @@ globalHookHandler(TSCont contp, TSEvent event, void *edata) {
if (!intercept_req) {
if (event == TS_EVENT_HTTP_READ_RESPONSE_HDR) {
bool mask_cache_headers = false;
- TSDebug(DEBUG_TAG, "[%s] handling read response header event...", __FUNCTION__);
+ TSLogDebug("handling read response header event...");
if (isCacheObjTransformable(txnp, &intercept_header, &head_only)) {
// transformable cache object will definitely have a
// transformation already as cache_lookup_complete would
// have been processed before this
- TSDebug(DEBUG_TAG, "[%s] xform should already have been added on cache lookup. Not adding now",
- __FUNCTION__);
+ TSLogDebug("xform should already have been added on cache lookup. Not adding now");
mask_cache_headers = true;
} else if (isTxnTransformable(txnp, false, &intercept_header, &head_only)) {
addTransform(txnp, true, intercept_header, head_only, pOptionInfo);
@@ -1571,7 +1567,7 @@ globalHookHandler(TSCont contp, TSEvent event, void *edata) {
maskOsCacheHeaders(txnp);
}
} else {
- TSDebug(DEBUG_TAG, "[%s] handling cache lookup complete event...", __FUNCTION__);
+ TSLogDebug("handling cache lookup complete event...");
if (isCacheObjTransformable(txnp, &intercept_header, &head_only)) {
// we make the assumption above that a transformable cache
// object would already have a tranformation. We should revisit
@@ -1584,7 +1580,7 @@ globalHookHandler(TSCont contp, TSEvent event, void *edata) {
break;
default:
- TSDebug(DEBUG_TAG, "[%s] Don't know how to handle event type %d", __FUNCTION__, event);
+ TSLogDebug("Don't know how to handle event type %d", event);
break;
}
@@ -1603,7 +1599,7 @@ loadHandlerConf(const char *file_name, Utils::KeyValueMap &handler_conf) {
}
TSfclose(conf_file);
Utils::parseKeyValueConfig(conf_lines, handler_conf);
- TSDebug(DEBUG_TAG, "[%s] Loaded handler conf file [%s]", __FUNCTION__, file_name);
+ TSLogDebug("Loaded handler conf file [%s]", file_name);
} else {
TSError("[%s] Failed to open handler config file [%s]", __FUNCTION__, file_name);
}
@@ -1669,8 +1665,7 @@ static int esiPluginInit(int argc, const char *argv[], struct OptionInfo *pOptio
if (threadKey == 0) {
bKeySet = true;
if ((result=pthread_key_create(&threadKey, NULL)) != 0) {
- TSError("[%s] Could not create key", __FUNCTION__);
- TSDebug(DEBUG_TAG, "[%s] Could not create key", __FUNCTION__);
+ TSLogError("Could not create key");
}
}
else {
@@ -1678,9 +1673,9 @@ static int esiPluginInit(int argc, const char *argv[], struct OptionInfo *pOptio
}
if (result == 0) {
- TSDebug(DEBUG_TAG, "[%s] Plugin started%s, " \
+ TSLogDebug("Plugin started%s, " \
"packed-node-support: %d, private-response: %d, " \
- "disable-gzip-output: %d, first-byte-flush: %d ", __FUNCTION__, bKeySet ? " and key is set" : "",
+ "disable-gzip-output: %d, first-byte-flush: %d ", bKeySet ? " and key is set" : "",
pOptionInfo->packed_node_support, pOptionInfo->private_response,
pOptionInfo->disable_gzip_output, pOptionInfo->first_byte_flush);
}
@@ -1729,7 +1724,7 @@ TSRemapInit(TSRemapInterface* api_info, char *errbuf, int errbuf_size)
return TS_ERROR;
}
- TSDebug(DEBUG_TAG, "esi remap plugin is successfully initialized");
+ TSLogDebug("esi remap plugin is successfully initialized");
return TS_SUCCESS;
}
@@ -1791,12 +1786,12 @@ TSRemapDoRemap(void* ih, TSHttpTxn txnp, TSRemapRequestInfo * /* rri ATS_UNUSED
if (isInterceptRequest(txnp)) {
if (!setupServerIntercept(txnp)) {
- TSError("[%s] Could not setup server intercept", __FUNCTION__);
+ TSLogError("Could not setup server intercept");
} else {
- TSDebug(DEBUG_TAG, "[%s] Setup server intercept", __FUNCTION__);
+ TSLogDebug("Setup server intercept");
}
} else {
- TSDebug(DEBUG_TAG, "[%s] Not setting up intercept", __FUNCTION__);
+ TSLogDebug("Not setting up intercept");
}
}
[05/13] git commit: transform channel_stats to new logging non-API
Posted by ig...@apache.org.
transform channel_stats to new logging non-API
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/da637dda
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/da637dda
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/da637dda
Branch: refs/heads/consistent-gzip-error-msgs
Commit: da637ddaeb6eee1668ba4ab8c31b63139c5166de
Parents: c10d8da
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 23:03:32 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 23:03:32 2013 +0200
----------------------------------------------------------------------
.../experimental/channel_stats/channel_stats.cc | 102 +++++++++----------
.../experimental/channel_stats/debug_macros.h | 36 +------
2 files changed, 52 insertions(+), 86 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/da637dda/plugins/experimental/channel_stats/channel_stats.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/channel_stats/channel_stats.cc b/plugins/experimental/channel_stats/channel_stats.cc
index 5766bd0..c36caba 100644
--- a/plugins/experimental/channel_stats/channel_stats.cc
+++ b/plugins/experimental/channel_stats/channel_stats.cc
@@ -38,11 +38,11 @@
#include <ts/experimental.h>
#endif
-#include "debug_macros.h"
-
#define PLUGIN_NAME "channel_stats"
#define PLUGIN_VERSION "0.2"
+#include "debug_macros.h"
+
#define MAX_SPEED 999999999
/* limit the number of channels (items) to avoid potential attack,
@@ -73,10 +73,10 @@ struct channel_stat {
}
inline void debug_channel() {
- debug("response.bytes.content: %" PRIu64 "", response_bytes_content);
- debug("response.count.2xx: %" PRIu64 "", response_count_2xx);
- debug("response.count.5xx: %" PRIu64 "", response_count_5xx);
- debug("speed.ua.bytes_per_sec_64k: %" PRIu64 "", speed_ua_bytes_per_sec_64k);
+ TSLogDebug("response.bytes.content: %" PRIu64 "", response_bytes_content);
+ TSLogDebug("response.count.2xx: %" PRIu64 "", response_count_2xx);
+ TSLogDebug("response.count.5xx: %" PRIu64 "", response_count_5xx);
+ TSLogDebug("speed.ua.bytes_per_sec_64k: %" PRIu64 "", speed_ua_bytes_per_sec_64k);
}
uint64_t response_bytes_content;
@@ -243,16 +243,16 @@ get_api_params(TSMBuffer bufp,
if (query_len == 0)
return;
tmp_query = TSstrndup(query, query_len);
- debug_api("querystring: %s", tmp_query);
+ TSLogDebug("querystring: %s", tmp_query);
if (has_query_param(tmp_query, "global", 1)) {
- debug_api("found 'global' param");
+ TSLogDebug("found 'global' param");
*show_global = 1;
}
*channel = (char *) TSmalloc(query_len);
if (get_query_param(tmp_query, "channel=", *channel, query_len)) {
- debug_api("found 'channel' param: %s", *channel);
+ TSLogDebug("found 'channel' param: %s", *channel);
}
std::stringstream ss;
@@ -262,7 +262,7 @@ get_api_params(TSMBuffer bufp,
ss.str(tmp_topn);
ss >> *topn;
}
- debug_api("found 'topn' param: %d", *topn);
+ TSLogDebug("found 'topn' param: %d", *topn);
}
TSfree(tmp_query);
@@ -288,13 +288,13 @@ handle_read_req(TSCont /* contp ATS_UNUSED */, TSHttpTxn txnp)
intercept_state *api_state;
if (TSHttpTxnClientReqGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
- error("couldn't retrieve client's request");
+ TSLogError("couldn't retrieve client's request");
goto cleanup;
}
method = TSHttpHdrMethodGet(bufp, hdr_loc, &method_length);
if (0 != strncmp(method, TS_HTTP_METHOD_GET, method_length)) {
- debug("do not count %.*s method", method_length, method);
+ TSLogDebug("do not count %.*s method", method_length, method);
goto cleanup;
}
@@ -308,7 +308,7 @@ handle_read_req(TSCont /* contp ATS_UNUSED */, TSHttpTxn txnp)
}
// register our intercept
- debug_api("Intercepting request");
+ TSLogDebug("Intercepting request");
api_state = (intercept_state *) TSmalloc(sizeof(*api_state));
memset(api_state, 0, sizeof(*api_state));
get_api_params(bufp, url_loc,
@@ -322,12 +322,12 @@ handle_read_req(TSCont /* contp ATS_UNUSED */, TSHttpTxn txnp)
if (!is_private_ip(client_addr4->sin_addr.s_addr)) {
client_ip = (char *) TSmalloc(INET_ADDRSTRLEN);
inet_ntop(AF_INET, &client_addr4->sin_addr, client_ip, INET_ADDRSTRLEN);
- debug_api("%s is not a private IP, request denied", client_ip);
+ TSLogDebug("%s is not a private IP, request denied", client_ip);
api_state->deny = 1;
TSfree(client_ip);
}
} else {
- debug_api("not IPv4, request denied"); // TODO check AF_INET6's private IP?
+ TSLogDebug("not IPv4, request denied"); // TODO check AF_INET6's private IP?
api_state->deny = 1;
}
@@ -357,13 +357,13 @@ get_pristine_host(TSHttpTxn txnp, TSMBuffer bufp, std::string &host)
int pristine_port;
if (TSHttpTxnPristineUrlGet(txnp, &bufp, &purl_loc) != TS_SUCCESS) {
- debug("couldn't retrieve pristine url");
+ TSLogDebug("couldn't retrieve pristine url");
return false;
}
pristine_host = TSUrlHostGet(bufp, purl_loc, &pristine_host_len);
if (pristine_host_len == 0) {
- debug("couldn't retrieve pristine host");
+ TSLogDebug("couldn't retrieve pristine host");
return false;
}
@@ -376,9 +376,9 @@ get_pristine_host(TSHttpTxn txnp, TSMBuffer bufp, std::string &host)
host.append(buf);
}
- debug("pristine host: %.*s", pristine_host_len, pristine_host);
- debug("pristine port: %d", pristine_port);
- debug("host to lookup: %s", host.c_str());
+ TSLogDebug("pristine host: %.*s", pristine_host_len, pristine_host);
+ TSLogDebug("pristine port: %d", pristine_port);
+ TSLogDebug("host to lookup: %s", host.c_str());
return true;
}
@@ -398,11 +398,11 @@ get_channel_stat(const std::string &host,
if (status_code_type != 2) {
// if request's host isn't in your remap.config, response code will be 404
// we should not count that channel in this situation
- debug("not 2xx response, do not create stat for this channel now");
+ TSLogDebug("not 2xx response, do not create stat for this channel now");
return false;
}
if (channel_stats.size() >= MAX_MAP_SIZE) {
- warning("channel_stats map exceeds max size");
+ TSLogWarning("channel_stats map exceeds max size");
return false;
}
@@ -413,9 +413,9 @@ get_channel_stat(const std::string &host,
TSMutexUnlock(stats_map_mutex);
if (insert_ret.second == true) {
// insert successfully
- debug("******** new channel(#%zu) ********", channel_stats.size());
+ TSLogDebug("******** new channel(#%zu) ********", channel_stats.size());
} else {
- warning("stat of this channel already existed");
+ TSLogWarning("stat of this channel already existed");
delete stat;
stat = insert_ret.first->second;
}
@@ -443,7 +443,7 @@ get_txn_user_speed(TSHttpTxn txnp, uint64_t body_bytes)
if (start_time != 0 && end_time != 0 && end_time >= start_time) {
interval_time = end_time - start_time;
} else {
- warning("invalid time, start: %" PRId64", end: %" PRId64"", start_time, end_time);
+ TSLogWarning("invalid time, start: %" PRId64", end: %" PRId64"", start_time, end_time);
return 0;
}
@@ -452,11 +452,11 @@ get_txn_user_speed(TSHttpTxn txnp, uint64_t body_bytes)
else
user_speed = (uint64_t)((float)body_bytes / interval_time * HRTIME_SECOND);
- debug("start time: %" PRId64 "", start_time);
- debug("end time: %" PRId64 "", end_time);
- debug("interval time: %" PRId64 "", interval_time);
- debug("interval seconds: %.5f", interval_time / (float)HRTIME_SECOND);
- debug("speed bytes per second: %" PRIu64 "", user_speed);
+ TSLogDebug("start time: %" PRId64 "", start_time);
+ TSLogDebug("end time: %" PRId64 "", end_time);
+ TSLogDebug("interval time: %" PRId64 "", interval_time);
+ TSLogDebug("interval seconds: %.5f", interval_time / (float)HRTIME_SECOND);
+ TSLogDebug("speed bytes per second: %" PRIu64 "", user_speed);
return user_speed;
}
@@ -474,7 +474,7 @@ handle_txn_close(TSCont /* contp ATS_UNUSED */, TSHttpTxn txnp)
std::string host;
if (TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
- debug("couldn't retrieve final response");
+ TSLogDebug("couldn't retrieve final response");
return;
}
@@ -486,8 +486,8 @@ handle_txn_close(TSCont /* contp ATS_UNUSED */, TSHttpTxn txnp)
if (status_code_type == 2)
__sync_fetch_and_add(&global_response_count_2xx_get, 1);
- debug("body bytes: %" PRIu64 "", body_bytes);
- debug("2xx req count: %" PRIu64 "", global_response_count_2xx_get);
+ TSLogDebug("body bytes: %" PRIu64 "", body_bytes);
+ TSLogDebug("2xx req count: %" PRIu64 "", global_response_count_2xx_get);
if (!get_pristine_host(txnp, bufp, host))
goto cleanup;
@@ -514,7 +514,7 @@ handle_event(TSCont contp, TSEvent event, void *edata) {
switch (event) {
case TS_EVENT_HTTP_READ_REQUEST_HDR: // for global contp
- debug("---------- new request ----------");
+ TSLogDebug("---------- new request ----------");
handle_read_req(contp, txnp);
break;
case TS_EVENT_HTTP_TXN_CLOSE: // for txn contp
@@ -522,7 +522,7 @@ handle_event(TSCont contp, TSEvent event, void *edata) {
TSContDestroy(contp);
break;
default:
- error("unknown event for this plugin");
+ TSLogError("unknown event for this plugin");
}
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
@@ -583,20 +583,20 @@ stats_add_resp_header(intercept_state * api_state)
static void
stats_process_read(TSCont contp, TSEvent event, intercept_state * api_state)
{
- debug_api("stats_process_read(%d)", event);
+ TSLogDebug("stats_process_read(%d)", event);
if (event == TS_EVENT_VCONN_READ_READY) {
api_state->output_bytes = stats_add_resp_header(api_state);
TSVConnShutdown(api_state->net_vc, 1, 0);
api_state->write_vio = TSVConnWrite(api_state->net_vc, contp, api_state->resp_reader, INT64_MAX);
} else if (event == TS_EVENT_ERROR) {
- error_api("stats_process_read: Received TS_EVENT_ERROR\n");
+ TSLogError("Received TS_EVENT_ERROR");
} else if (event == TS_EVENT_VCONN_EOS) {
// client may end the connection, simply return
return;
} else if (event == TS_EVENT_NET_ACCEPT_FAILED) {
- error_api("stats_process_read: Received TS_EVENT_NET_ACCEPT_FAILED\n");
+ TSLogError("Received TS_EVENT_NET_ACCEPT_FAILED");
} else {
- error_api("Unexpected Event %d\n", event);
+ TSLogError("Unexpected Event %d", event);
// TSReleaseAssert(!"Unexpected Event");
}
}
@@ -633,7 +633,7 @@ json_out_stat(TSRecordType /* rec_type ATS_UNUSED */, void *edata, int /* regist
case TS_RECORDDATATYPE_STRING:
APPEND_STAT(name, "%s", datum->rec_string); break;
default:
- debug_api("unknown type for %s: %d", name, data_type);
+ TSLogDebug("unknown type for %s: %d", name, data_type);
break;
}
}
@@ -672,7 +672,7 @@ json_out_channel_stats(intercept_state * api_state) {
typedef std::vector<data_pair> stats_vec_t;
smap_iterator it;
- debug("appending channel stats");
+ TSLogDebug("appending channel stats");
if (api_state->topn > -1 ||
(api_state->channel && strlen(api_state->channel) > 0)) {
@@ -755,7 +755,7 @@ stats_process_write(TSCont contp, TSEvent event, intercept_state * api_state)
{
if (event == TS_EVENT_VCONN_WRITE_READY) {
if (api_state->body_written == 0) {
- debug_api("plugin adding response body");
+ TSLogDebug("plugin adding response body");
api_state->body_written = 1;
if (!api_state->deny)
json_out_stats(api_state);
@@ -767,9 +767,9 @@ stats_process_write(TSCont contp, TSEvent event, intercept_state * api_state)
} else if (TS_EVENT_VCONN_WRITE_COMPLETE) {
stats_cleanup(contp, api_state);
} else if (event == TS_EVENT_ERROR) {
- error_api("stats_process_write: Received TS_EVENT_ERROR\n");
+ TSLogError("Received TS_EVENT_ERROR");
} else {
- error_api("Unexpected Event %d\n", event);
+ TSLogError("Unexpected Event %d", event);
// TSReleaseAssert(!"Unexpected Event");
}
}
@@ -786,7 +786,7 @@ api_handle_event(TSCont contp, TSEvent event, void *edata)
} else if (edata == api_state->write_vio) {
stats_process_write(contp, event, api_state);
} else {
- error_api("Unexpected Event %d\n", event);
+ TSLogError("Unexpected Event %d", event);
// TSReleaseAssert(!"Unexpected Event");
}
return 0;
@@ -798,23 +798,23 @@ void
TSPluginInit(int argc, const char *argv[])
{
if (argc > 2) {
- fatal("plugin does not accept more than 1 argument");
+ TSLogFatal("plugin does not accept more than 1 argument");
} else if (argc == 2) {
api_path = std::string(argv[1]);
- debug_api("stats api path: %s", api_path.c_str());
+ TSLogDebug("stats api path: %s", api_path.c_str());
}
TSPluginRegistrationInfo info;
info.plugin_name = (char *)PLUGIN_NAME;
- info.vendor_name = (char *)"wkl";
- info.support_email = (char *)"conanmind@gmail.com";
+ info.vendor_name = (char *)"Apache Software Foundation";
+ info.support_email = (char *)"dev@trafficerver.apache.org";
if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) {
- fatal("plugin registration failed.");
+ TSLogFatal("plugin registration failed.");
}
- info("%s(%s) plugin starting...", PLUGIN_NAME, PLUGIN_VERSION);
+ TSLogInfo("plugin v%s starting...", PLUGIN_VERSION);
stats_map_mutex = TSMutexCreate();
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/da637dda/plugins/experimental/channel_stats/debug_macros.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/channel_stats/debug_macros.h b/plugins/experimental/channel_stats/debug_macros.h
index 90d9f9d..7664c20 100644
--- a/plugins/experimental/channel_stats/debug_macros.h
+++ b/plugins/experimental/channel_stats/debug_macros.h
@@ -22,41 +22,7 @@
#include "ink_defs.h"
#define TAG PLUGIN_NAME
-#define API_TAG PLUGIN_NAME ".api"
-
-#define debug_tag(tag, fmt, ...) do { \
- if (unlikely(TSIsDebugTagSet(tag))) { \
- TSDebug(tag, fmt, ##__VA_ARGS__); \
- } \
-} while(0)
-
-#define debug(fmt, ...) \
- debug_tag(TAG, "DEBUG: [%s:%d] [%s] " fmt, __FILE__, __LINE__, __FUNCTION__ , ##__VA_ARGS__);
-
-#define info(fmt, ...) \
- debug_tag(TAG, "INFO: " fmt, ##__VA_ARGS__);
-
-#define warning(fmt, ...) \
- debug_tag(TAG, "WARNING: " fmt, ##__VA_ARGS__);
-
-#define error(fmt, ...) do { \
- TSError("[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##__VA_ARGS__); \
- debug_tag(TAG, "[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##__VA_ARGS__); \
-} while (0)
-
-#define fatal(fmt, ...) do { \
- TSError("[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##__VA_ARGS__); \
- debug_tag(TAG, "[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##__VA_ARGS__); \
- exit(-1); \
-} while (0)
-
-#define debug_api(fmt, ...) \
- debug_tag(API_TAG, "DEBUG: [%s:%d] [%s] " fmt, __FILE__, __LINE__, __FUNCTION__ , ##__VA_ARGS__);
-
-#define error_api(fmt, ...) do { \
- TSError("[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##__VA_ARGS__); \
- debug_tag(API_TAG, "ERROR: [%s:%d] [%s] " fmt, __FILE__, __LINE__, __FUNCTION__ , ##__VA_ARGS__); \
-} while (0)
+#include <ts/debug.h>
#define HRTIME_FOREVER (10*HRTIME_DECADE)
#define HRTIME_DECADE (10*HRTIME_YEAR)
[02/13] git commit: transform authproxy to new logging non-API - fix
typo
Posted by ig...@apache.org.
transform authproxy to new logging non-API - fix typo
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/64741444
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/64741444
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/64741444
Branch: refs/heads/consistent-gzip-error-msgs
Commit: 64741444f0610c4f3420fd9d04c9acc843d4120b
Parents: 4f27dca
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 22:15:16 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 22:15:16 2013 +0200
----------------------------------------------------------------------
plugins/experimental/authproxy/authproxy.cc | 42 ++++++++++++------------
plugins/experimental/authproxy/utils.cc | 8 ++---
plugins/experimental/authproxy/utils.h | 4 +--
3 files changed, 26 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/64741444/plugins/experimental/authproxy/authproxy.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/authproxy/authproxy.cc b/plugins/experimental/authproxy/authproxy.cc
index c4c939d..224b89a 100644
--- a/plugins/experimental/authproxy/authproxy.cc
+++ b/plugins/experimental/authproxy/authproxy.cc
@@ -401,22 +401,22 @@ StateAuthProxyResolve(AuthRequestContext * auth, void *)
);
if (HttpGetOriginHost(mbuf, mhdr, hostname, sizeof(hostname))) {
- AuthLogDebug("resolving authorization host %s", hostname);
+ TSLogDebug("resolving authorization host %s", hostname);
lookup = TSHostLookup(auth->cont, hostname, strlen(hostname));
TSHandleMLocRelease(mbuf, TS_NULL_MLOC, mhdr);
} else {
- AuthLogError("failed to extract origin host name from client request");
+ TSLogError("failed to extract origin host name from client request");
TSHandleMLocRelease(mbuf, TS_NULL_MLOC, mhdr);
return TS_EVENT_ERROR;
}
} else {
- AuthLogDebug("resolving authorization proxy host %s", options->hostname);
+ TSLogDebug("resolving authorization proxy host %s", options->hostname);
lookup = TSHostLookup(auth->cont, options->hostname, strlen(options->hostname));
}
if (TSActionDone(lookup)) {
- AuthLogDebug("host lookup was executed in line");
+ TSLogDebug("host lookup was executed in line");
return TS_EVENT_NONE;
}
@@ -439,7 +439,7 @@ StateAuthProxyConnect(AuthRequestContext * auth, void * edata)
dns = (TSHostLookupResult)edata;
if (dns == NULL) {
- AuthLogError("failed to resolve authorization proxy at %s", options->hostname);
+ TSLogError("failed to resolve authorization proxy at %s", options->hostname);
return TS_EVENT_ERROR;
}
@@ -457,7 +457,7 @@ StateAuthProxyConnect(AuthRequestContext * auth, void * edata)
}
auth->is_head = AuthRequestIsHead(auth->txn);
- AuthLogDebug("client request %s a HEAD request", auth->is_head ? "is" : "is not");
+ TSLogDebug("client request %s a HEAD request", auth->is_head ? "is" : "is not");
auth->vconn = TSHttpConnect(&addr.sa);
if (auth->vconn == NULL) {
@@ -484,7 +484,7 @@ StateAuthProxyCompleteHeaders(AuthRequestContext * auth, void * /* edata ATS_UNU
HttpDebugHeader(auth->rheader.buffer, auth->rheader.header);
status = TSHttpHdrStatusGet(auth->rheader.buffer, auth->rheader.header);
- AuthLogDebug("authorization proxy returned status %d", (int)status);
+ TSLogDebug("authorization proxy returned status %d", (int)status);
// Authorize the original request on a 2xx response.
if (status >= 200 && status < 300) {
@@ -496,13 +496,13 @@ StateAuthProxyCompleteHeaders(AuthRequestContext * auth, void * /* edata ATS_UNU
// without writing a transform. Since that's more trouble than I want to
// deal with right now, let's just fail fast ...
if (HttpIsChunkedEncoding(auth->rheader.buffer, auth->rheader.header)) {
- AuthLogDebug("ignoring chunked authorization proxy response");
+ TSLogDebug("ignoring chunked authorization proxy response");
} else {
// OK, we have a non-chunked response. If there's any content, let's go and
// buffer it so that we can send it on to the client.
nbytes = HttpGetContentLength(auth->rheader.buffer, auth->rheader.header);
if (nbytes > 0) {
- AuthLogDebug("content length is %u", nbytes);
+ TSLogDebug("content length is %u", nbytes);
return TS_EVENT_HTTP_CONTINUE;
}
}
@@ -547,7 +547,7 @@ StateAuthProxySendResponse(AuthRequestContext * auth, void * /* edata ATS_UNUSED
HttpSetMimeHeader(mbuf, mhdr, TS_MIME_FIELD_CONTENT_LENGTH, 0u);
}
- AuthLogDebug("sending auth proxy response for status %d", status);
+ TSLogDebug("sending auth proxy response for status %d", status);
TSHttpTxnReenable(auth->txn, TS_EVENT_HTTP_CONTINUE);
TSHandleMLocRelease(mbuf, TS_NULL_MLOC, mhdr);
@@ -561,7 +561,7 @@ StateAuthProxyReadHeaders(AuthRequestContext * auth, void * /* edata ATS_UNUSED
ssize_t consumed = 0;
bool complete = false;
- AuthLogDebug("reading header data, %u bytes available", (unsigned)TSIOBufferReaderAvail(auth->iobuf.reader));
+ TSLogDebug("reading header data, %u bytes available", (unsigned)TSIOBufferReaderAvail(auth->iobuf.reader));
for (blk = TSIOBufferReaderStart(auth->iobuf.reader); blk; blk = TSIOBufferBlockNext(blk)) {
const char * ptr;
@@ -595,7 +595,7 @@ StateAuthProxyReadHeaders(AuthRequestContext * auth, void * /* edata ATS_UNUSED
}
}
- AuthLogDebug("consuming %u bytes, %u remain",
+ TSLogDebug("consuming %u bytes, %u remain",
(unsigned)consumed, (unsigned)TSIOBufferReaderAvail(auth->iobuf.reader));
TSIOBufferReaderConsume(auth->iobuf.reader, consumed);
@@ -625,7 +625,7 @@ StateAuthProxyReadContent(AuthRequestContext * auth, void * /* edata ATS_UNUSED
avail = TSIOBufferReaderAvail(auth->iobuf.reader);
needed = HttpGetContentLength(auth->rheader.buffer, auth->rheader.header);
- AuthLogDebug("we have %u of %u needed bytes", (unsigned)avail, needed);
+ TSLogDebug("we have %u of %u needed bytes", (unsigned)avail, needed);
if (avail >= needed) {
// OK, we have what we need. Let's respond to the client request.
@@ -645,7 +645,7 @@ StateAuthProxyCompleteContent(AuthRequestContext * auth, void * /* edata ATS_UNU
avail = TSIOBufferReaderAvail(auth->iobuf.reader);
needed = HttpGetContentLength(auth->rheader.buffer, auth->rheader.header);
- AuthLogDebug("we have %u of %u needed bytes", (unsigned)avail, needed);
+ TSLogDebug("we have %u of %u needed bytes", (unsigned)avail, needed);
if (avail >= needed) {
// OK, we have what we need. Let's respond to the client request.
@@ -676,7 +676,7 @@ StateAuthorized(AuthRequestContext * auth, void *)
{
const AuthOptions * options = auth->options();
- AuthLogDebug("request authorized");
+ TSLogDebug("request authorized");
// Since the original request might have authentication headers, we may
// need to force ATS to ignore those in order to make it cacheable.
@@ -708,7 +708,7 @@ AuthProxyGlobalHook(TSCont /* cont ATS_UNUSED */, TSEvent event, void * edata)
} ptr;
ptr.edata = edata;
- AuthLogDebug("handling event=%d edata=%p", (int)event, edata);
+ TSLogDebug("handling event=%d edata=%p", (int)event, edata);
switch (event) {
case TS_EVENT_HTTP_OS_DNS:
@@ -719,7 +719,7 @@ AuthProxyGlobalHook(TSCont /* cont ATS_UNUSED */, TSEvent event, void * edata)
// allow that to be cached.
TSHttpTxnReqCacheableSet(ptr.txn, 0);
- AuthLogDebug("re-enabling internal transaction");
+ TSLogDebug("re-enabling internal transaction");
TSHttpTxnReenable(ptr.txn, TS_EVENT_HTTP_CONTINUE);
return TS_EVENT_NONE;
}
@@ -787,7 +787,7 @@ AuthParseOptions(int argc, const char ** argv)
} else if (strcasecmp(optarg, "head") == 0) {
options->transform = AuthWriteHeadRequest;
} else {
- AuthLogError("invalid authorization transform '%s'", optarg);
+ TSLogError("invalid authorization transform '%s'", optarg);
// XXX make this a fatal error?
}
@@ -813,7 +813,7 @@ TSPluginInit(int argc, const char *argv[])
info.support_email = (char *)"jamespeach@me.com";
if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) {
- AuthLogError("plugin registration failed");
+ TSLogError("plugin registration failed");
}
TSReleaseAssert(
@@ -825,7 +825,7 @@ TSPluginInit(int argc, const char *argv[])
AuthOsDnsContinuation = TSContCreate(AuthProxyGlobalHook, NULL);
AuthGlobalOptions = AuthParseOptions(argc, argv);
- AuthLogDebug("using authorization proxy at %s:%d", AuthGlobalOptions->hostname, AuthGlobalOptions->hostport);
+ TSLogDebug("using authorization proxy at %s:%d", AuthGlobalOptions->hostname, AuthGlobalOptions->hostport);
// Catch the DNS hook. This triggers after reading the headers and
// resolving the requested host, but before performing any cache lookups.
@@ -854,7 +854,7 @@ TSRemapNewInstance(int argc, char * argv[], void ** instance, char * /* err ATS_
{
AuthOptions * options;
- AuthLogDebug("using authorization proxy for remapping %s -> %s", argv[0], argv[1]);
+ TSLogDebug("using authorization proxy for remapping %s -> %s", argv[0], argv[1]);
// The first two arguments are the "from" and "to" URL string. We need to
// skip them, but we also require that there be an option to masquerade as
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/64741444/plugins/experimental/authproxy/utils.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/authproxy/utils.cc b/plugins/experimental/authproxy/utils.cc
index 315477d..47f32d3 100644
--- a/plugins/experimental/authproxy/utils.cc
+++ b/plugins/experimental/authproxy/utils.cc
@@ -78,9 +78,7 @@ HttpDebugHeader(TSMBuffer mbuf, TSMLoc mhdr)
avail = TSIOBufferBlockReadAvail(blk, iobuf.reader);
ptr = (const char *)TSIOBufferBlockReadStart(blk, iobuf.reader, &nbytes);
- AuthLogDebug(
- "http request (%u of %u bytes):\n%*.*s",
- (unsigned)nbytes, (unsigned)avail, (int)nbytes, (int)nbytes, ptr);
+ TSLogDebug("http request (%u of %u bytes):\n%*.*s", (unsigned)nbytes, (unsigned)avail, (int)nbytes, (int)nbytes, ptr);
}
void
@@ -188,7 +186,7 @@ HttpGetOriginHost(TSMBuffer mbuf, TSMLoc mhdr, char * name, size_t namelen)
TSHandleMLocRelease(mbuf, mhdr, mloc);
if (host) {
- AuthLogDebug("using origin %.*s from host header", len, host);
+ TSLogDebug("using origin %.*s from host header", len, host);
len = std::min(len, (int)namelen - 1);
memcpy(name, host, len);
name[len] = '\0';
@@ -202,7 +200,7 @@ HttpGetOriginHost(TSMBuffer mbuf, TSMLoc mhdr, char * name, size_t namelen)
TSHandleMLocRelease(mbuf, mhdr, mloc);
if (host) {
- AuthLogDebug("using origin %.*s from request URL", len, host);
+ TSLogDebug("using origin %.*s from request URL", len, host);
len = std::min(len, (int)namelen - 1);
memcpy(name, host, len);
name[len] = '\0';
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/64741444/plugins/experimental/authproxy/utils.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/authproxy/utils.h b/plugins/experimental/authproxy/utils.h
index 0686171..dc73bf7 100644
--- a/plugins/experimental/authproxy/utils.h
+++ b/plugins/experimental/authproxy/utils.h
@@ -20,8 +20,8 @@
#include <netinet/in.h>
#include <memory>
-#define AuthLogDebug(fmt, ...) TSDebug("AuthProxy", "%s: " fmt, __func__, ##__VA_ARGS__)
-#define AuthLogError(fmt, ...) TSError(fmt, ##__VA_ARGS__)
+#define PLUGIN_NAME "authproxy"
+#include <ts/debug.h>
template <typename T>
T * AuthNew() {
[09/13] git commit: transform metalink to new logging non-API
Posted by ig...@apache.org.
transform metalink to new logging non-API
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ff043e16
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ff043e16
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ff043e16
Branch: refs/heads/consistent-gzip-error-msgs
Commit: ff043e169127bdf122c6960416877d587b347b5e
Parents: acc0593
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 23:38:24 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 23:38:24 2013 +0200
----------------------------------------------------------------------
plugins/experimental/metalink/metalink.cc | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ff043e16/plugins/experimental/metalink/metalink.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/metalink.cc b/plugins/experimental/metalink/metalink.cc
index 55e88c8..5f3e7fe 100644
--- a/plugins/experimental/metalink/metalink.cc
+++ b/plugins/experimental/metalink/metalink.cc
@@ -38,6 +38,9 @@
#include "ts/ts.h"
#include "ink_defs.h"
+#define PLUGIN_NAME "metalink"
+#include <ts/debug.h>
+
typedef struct {
TSVConn connp;
TSIOBuffer bufp;
@@ -137,7 +140,7 @@ cache_open_write(TSCont contp, void *edata)
TSIOBufferReader readerp = TSIOBufferReaderAlloc(write_data->bufp);
if (TSHttpTxnClientReqGet(transform_data->txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
- TSError("Couldn't retrieve client request header");
+ TSLogError("Couldn't retrieve client request header");
return 0;
}
@@ -528,7 +531,7 @@ http_send_response_hdr(TSCont contp, void *edata)
data->txnp = (TSHttpTxn) edata;
if (TSHttpTxnClientRespGet(data->txnp, &data->resp_bufp, &data->hdr_loc) != TS_SUCCESS) {
- TSError("Couldn't retrieve client response header");
+ TSLogError("Couldn't retrieve client response header");
TSHttpTxnReenable(data->txnp, TS_EVENT_HTTP_CONTINUE);
TSfree(data);
@@ -649,7 +652,7 @@ handler(TSCont contp, TSEvent event, void *edata)
}
void
-TSPluginInit(int /* argc ATS_UNUSED */, const char */* argv ATS_UNUSED */[])
+TSPluginInit(int /* argc ATS_UNUSED */, const char * /* argv ATS_UNUSED */[])
{
TSPluginRegistrationInfo info;
@@ -658,7 +661,7 @@ TSPluginInit(int /* argc ATS_UNUSED */, const char */* argv ATS_UNUSED */[])
info.support_email = const_cast<char*>("jack@nottheoilrig.com");
if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) {
- TSError("Plugin registration failed");
+ TSLogError("Plugin registration failed");
}
TSCont contp = TSContCreate(handler, NULL);
[03/13] git commit: transform balancer to new logging non-API
Posted by ig...@apache.org.
transform balancer to new logging non-API
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/380aab33
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/380aab33
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/380aab33
Branch: refs/heads/consistent-gzip-error-msgs
Commit: 380aab331a05d429f725e8e8413e9d38177b2c4c
Parents: 6474144
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 22:25:32 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 22:25:32 2013 +0200
----------------------------------------------------------------------
plugins/experimental/balancer/balancer.cc | 48 +++++++++++++-------------
plugins/experimental/balancer/resources.h | 9 +++--
2 files changed, 30 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/380aab33/plugins/experimental/balancer/balancer.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/balancer/balancer.cc b/plugins/experimental/balancer/balancer.cc
index adc91ad..4b2cd2b 100644
--- a/plugins/experimental/balancer/balancer.cc
+++ b/plugins/experimental/balancer/balancer.cc
@@ -89,7 +89,7 @@ public:
char* rotation() const { return _rotation; };
void set_rotation(const std::string& rot) {
if (rot.size() > 255) {
- TSError("Rotation name is too long");
+ TSLogError("Rotation name is too long");
return;
}
_rotation = TSstrdup(rot.c_str());
@@ -148,8 +148,8 @@ public:
hk = hk->next;
}
*p = '\0';
- if (TSIsDebugTagSet("balancer")) {
- TSDebug("balancer", "Making %s hash ID's using %s", secondary ? "secondary" : "primary", buf);
+ if (TSIsDebugTagSet(PLUGIN_NAME)) {
+ TSLogDebug("Making %s hash ID's using %s", secondary ? "secondary" : "primary", buf);
}
ycrMD5_r(buf, key_len, id);
} else {
@@ -159,7 +159,7 @@ public:
*buf = resr.getRRI()->client_ip; // ToDo: this only works for IPv4
- TSDebug("balancer", "Making secondary hash ID's using IP (default) = %s", buf);
+ TSLogDebug("Making secondary hash ID's using IP (default) = %s", buf);
ycrMD5_r(buf, key_len, id);
} else {
// Primary ID defaults to URL (if none of the specified hashes computes)
@@ -167,7 +167,7 @@ public:
memcpy(buf, resr.getRRI()->orig_url, resr.getRRI()->orig_url_size);
buf[resr.getRRI()->orig_url_size] = '\0';
- TSDebug("balancer", "Making primary hash ID's using URL (default) = %s", buf);
+ TSLogDebug("Making primary hash ID's using URL (default) = %s", buf);
ycrMD5_r(buf, key_len, id);
}
}
@@ -208,7 +208,7 @@ tsremap_init(TSREMAP_INTERFACE *api_info, char *errbuf, int errbuf_size)
return -3;
}
- TSDebug("balancer", "plugin is successfully initialized");
+ TSLogInfo("plugin is successfully initialized");
return 0;
}
@@ -224,7 +224,7 @@ tsremap_new_instance(int argc, char *argv[], ihandle *ih, char *errbuf, int errb
*ih = static_cast<ihandle>(ri);
if (ri == NULL) {
- TSError("Unable to create remap instance");
+ TSLogError("Unable to create remap instance");
return -5;
}
@@ -238,7 +238,7 @@ tsremap_new_instance(int argc, char *argv[], ihandle *ih, char *errbuf, int errb
std::string::size_type sep = arg.find_first_of(":");
if (sep == std::string::npos) {
- TSError("Malformed options in balancer: %s", argv[ix]);
+ TSLogError("Malformed options in balancer: %s", argv[ix]);
} else {
std::string arg_val = arg.substr(sep + 1, std::string::npos);
@@ -253,7 +253,7 @@ tsremap_new_instance(int argc, char *argv[], ihandle *ih, char *errbuf, int errb
URLHashKey* hk = new URLHashKey();
if (NULL == hk) {
- TSError("Couldn't create balancer URL hash key");
+ TSLogError("Couldn't create balancer URL hash key");
} else {
ri->append_hash(hk, secondary);
}
@@ -261,7 +261,7 @@ tsremap_new_instance(int argc, char *argv[], ihandle *ih, char *errbuf, int errb
PathHashKey* hk = new PathHashKey();
if (NULL == hk) {
- TSError("Couldn't create balancer path hash key");
+ TSLogError("Couldn't create balancer path hash key");
} else {
ri->append_hash(hk, secondary);
}
@@ -269,7 +269,7 @@ tsremap_new_instance(int argc, char *argv[], ihandle *ih, char *errbuf, int errb
IPHashKey* hk = new IPHashKey();
if (NULL == hk) {
- TSError("Couldn't create balancer IP hash key");
+ TSLogError("Couldn't create balancer IP hash key");
} else {
ri->append_hash(hk, secondary);
}
@@ -278,7 +278,7 @@ tsremap_new_instance(int argc, char *argv[], ihandle *ih, char *errbuf, int errb
std::string::size_type sep2 = arg_val.find_first_of("/");
if (sep2 == std::string::npos) {
- TSError("Malformed hash options in balancer: %s", argv[ix]);
+ TSLogError("Malformed hash options in balancer: %s", argv[ix]);
} else {
std::string arg_val2 = arg_val.substr(sep2 + 1, std::string::npos);
@@ -286,7 +286,7 @@ tsremap_new_instance(int argc, char *argv[], ihandle *ih, char *errbuf, int errb
CookieHashKey* hk = new CookieHashKey(arg_val2);
if (NULL == hk) {
- TSError("Couldn't create balancer cookie hash key");
+ TSLogError("Couldn't create balancer cookie hash key");
} else {
ri->append_hash(hk, secondary);
}
@@ -294,17 +294,17 @@ tsremap_new_instance(int argc, char *argv[], ihandle *ih, char *errbuf, int errb
HeaderHashKey* hk = new HeaderHashKey(arg_val2);
if (NULL == hk) {
- TSError("Couldn't create balancer header hash key");
+ TSLogError("Couldn't create balancer header hash key");
} else {
ri->append_hash(hk, secondary);
}
} else {
- TSError("Unknown balancer hash option: %s", argv[ix]);
+ TSLogError("Unknown balancer hash option: %s", argv[ix]);
}
}
}
} else {
- TSError("Unknown balancer option: %s", argv[ix]);
+ TSLogError("Unknown balancer option: %s", argv[ix]);
}
}
}
@@ -337,7 +337,7 @@ tsremap_remap(ihandle ih, rhandle rh, REMAP_REQUEST_INFO *rri)
char *rot;
if (NULL == ih) {
- TSDebug("balancer", "Falling back to default URL on remap without rules");
+ TSLogDebug("Falling back to default URL on remap without rules");
return 0;
}
balancer = static_cast<BalancerInstance*>(ih);
@@ -382,33 +382,33 @@ tsremap_remap(ihandle ih, rhandle rh, REMAP_REQUEST_INFO *rri)
balancer_info.secondary_id = id2;
balancer_info.secondary_id_len = MD5_DIGEST_LENGTH;
- TSDebug("balancer", "Calling balancer_lookup(\"%s\") with primary and secondary hash", rot);
+ TSLogDebug("Calling balancer_lookup(\"%s\") with primary and secondary hash", rot);
res = balancer_lookup(rot, &balancer_info);
} else {
- TSDebug("balancer", "Calling balancer_lookup(\"%s\") with primary hash", rot);
+ TSLogDebug("Calling balancer_lookup(\"%s\") with primary hash", rot);
res = balancer_lookup(rot, &balancer_info);
}
} else {
- TSDebug("balancer", "Calling balancer_lookup(\"%s\") without hash", rot);
+ TSLogDebug("Calling balancer_lookup(\"%s\") without hash", rot);
res = balancer_lookup(rot, &balancer_info);
}
// Check (and use) the balancer lookup results
if (!res) {
- TSDebug("balancer", "BALANCER has no data for %s, using To-URL (error is %d)", rot, balancer_error);
+ TSLogDebug("BALANCER has no data for %s, using To-URL (error is %d)", rot, balancer_error);
return 0;
} else {
if ((balancer_port > 0) && (balancer_port != rri->remap_to_port)) {
rri->new_port = balancer_port;
- TSDebug("balancer", "Changing request to port %d", balancer_port);
+ TSLogDebug("Changing request to port %d", balancer_port);
}
if (balancer->host_ip()) {
unsigned char *ip = (unsigned char*)res->h_addr;
rri->new_host_size = snprintf(rri->new_host, 16, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
- TSDebug("balancer", "Setting real-host IP to %.*s (IP for %s)", rri->new_host_size, rri->new_host, res->h_name);
+ TSLogDebug("Setting real-host IP to %.*s (IP for %s)", rri->new_host_size, rri->new_host, res->h_name);
} else {
- TSDebug("balancer", "Setting real-host to %s", res->h_name);
+ TSLogDebug("Setting real-host to %s", res->h_name);
rri->new_host_size = strlen(res->h_name);
if (rri->new_host_size > TSREMAP_RRI_MAX_HOST_SIZE)
rri->new_host_size = TSREMAP_RRI_MAX_HOST_SIZE;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/380aab33/plugins/experimental/balancer/resources.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/balancer/resources.h b/plugins/experimental/balancer/resources.h
index 6188951..3f9b1dc 100644
--- a/plugins/experimental/balancer/resources.h
+++ b/plugins/experimental/balancer/resources.h
@@ -33,6 +33,9 @@
#include <ts/ts.h>
+#define PLUGIN_NAME "balancer"
+#include <ts/debug.h>
+
///////////////////////////////////////////////////////////////////////////////
// Class declaration
@@ -46,12 +49,12 @@ public:
~Resources() {
if (_hdrLoc) {
- TSDebug("balancer", "Releasing the client request headers");
+ TSLogDebug("Releasing the client request headers");
TSHandleMLocRelease(_bufp, TS_NULL_MLOC, _hdrLoc);
}
if (_jar) {
- TSDebug("balancer", "Destroying the cookie jar");
+ TSLogDebug("Destroying the cookie jar");
// TODO - destroy cookies
}
}
@@ -72,7 +75,7 @@ public:
memcpy(cookie_hdr, _rri->request_cookie, _rri->request_cookie_size);
cookie_hdr[_rri->request_cookie_size] = '\0';
_jar = // TODO - create cookies
- TSDebug("balancer", "Creating the cookie jar");
+ TSLogDebug("Creating the cookie jar");
}
return _jar;
[12/13] git commit: transform esi to new logging non-API
Posted by ig...@apache.org.
transform esi to new logging non-API
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ea58dc2d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ea58dc2d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ea58dc2d
Branch: refs/heads/consistent-gzip-error-msgs
Commit: ea58dc2d760b307110d814a0d0955e0cb54b60a0
Parents: 1f440b8
Author: Igor Galić <i....@brainsware.org>
Authored: Fri Aug 9 00:23:13 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Fri Aug 9 00:23:13 2013 +0200
----------------------------------------------------------------------
plugins/experimental/spdy/lib/base/logging.h | 16 ++-----------
plugins/experimental/spdy/spdy.cc | 28 +++++++++++------------
plugins/experimental/spdy/stream.cc | 2 +-
3 files changed, 17 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ea58dc2d/plugins/experimental/spdy/lib/base/logging.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/spdy/lib/base/logging.h b/plugins/experimental/spdy/lib/base/logging.h
index a4c065a..32b520a 100644
--- a/plugins/experimental/spdy/lib/base/logging.h
+++ b/plugins/experimental/spdy/lib/base/logging.h
@@ -21,18 +21,8 @@
#include <string>
-extern "C" {
-
-// TS logging APIs don't get format attributes, so make sure we have a
-// compatible forward declaration.
-void TSDebug(const char *, const char *, ...)
- __attribute__((format(printf, 2, 3)));
-
-void TSError(const char *, ...)
- __attribute__((format(printf, 1, 2)));
-
-int TSIsDebugTagSet(const char*);
-}
+#define PLUGIN_NAME "spdy"
+#include <ts/debug.h>
template <typename T> std::string stringof(const T&);
#define cstringof(x) stringof(x).c_str()
@@ -45,8 +35,6 @@ template <typename T> std::string stringof(const T&);
#define debug_protocol(fmt, ...) \
debug_tag("spdy.protocol", "%s:%d " fmt, __func__, __LINE__, ##__VA_ARGS__)
-#define debug_plugin(fmt, ...) \
- debug_tag("spdy.plugin", "%s:%d " fmt, __func__, __LINE__, ##__VA_ARGS__)
#define debug_http(fmt, ...) \
debug_tag("spdy.http", "%s:%d " fmt, __func__, __LINE__, ##__VA_ARGS__)
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ea58dc2d/plugins/experimental/spdy/spdy.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/spdy/spdy.cc b/plugins/experimental/spdy/spdy.cc
index 1a83e2a..91d1876 100644
--- a/plugins/experimental/spdy/spdy.cc
+++ b/plugins/experimental/spdy/spdy.cc
@@ -172,7 +172,7 @@ dispatch_spdy_control_frame(
break;
default:
// SPDY 2.2.1 - MUST ignore unrecognized control frames
- TSError("[spdy] ignoring invalid control frame type %u", header.control.type);
+ TSLogError("ignoring invalid control frame type %u", header.control.type);
}
io->reenable();
@@ -217,14 +217,14 @@ next_frame:
// This should not fail because we only try to consume the header when
// there are enough bytes to read the header. Experimentally, however,
// it does fail. I wonder why.
- TSError("TSIOBufferBlockReadStart failed unexpectedly");
+ TSLogError("TSIOBufferBlockReadStart failed unexpectedly");
return;
}
if (nbytes < spdy::message_header::size) {
// We should never get here, because we check for space before
// entering. Unfortunately this does happen :(
- debug_plugin("short read %" PRId64 " bytes, expected at least %u, real count %zu",
+ TSLogDebug("short read %" PRId64 " bytes, expected at least %u, real count %zu",
nbytes, spdy::message_header::size,
count_bytes_available(io->input.reader));
return;
@@ -235,7 +235,7 @@ next_frame:
if (header.is_control) {
if (header.control.version != spdy::PROTOCOL_VERSION) {
- TSError("[spdy] client is version %u, but we implement version %u",
+ TSLogError("client is version %u, but we implement version %u",
header.control.version, spdy::PROTOCOL_VERSION);
}
} else {
@@ -257,7 +257,7 @@ next_frame:
if (header.is_control) {
dispatch_spdy_control_frame(header, io, ptr);
} else {
- TSError("[spdy] no data frame support yet");
+ TSLogError("no data frame support yet");
}
if (TSIOBufferReaderAvail(io->input.reader) >= spdy::message_header::size) {
@@ -281,14 +281,14 @@ spdy_vconn_io(TSCont contp, TSEvent ev, void * edata)
// Experimentally, we recieve the read or write TSVIO pointer as the
// callback data.
- //debug_plugin("received IO event %s, VIO=%p", cstringof(ev), vio);
+ //TSLogDebug("received IO event %s, VIO=%p", cstringof(ev), vio);
switch (ev) {
case TS_EVENT_VCONN_READ_READY:
case TS_EVENT_VCONN_READ_COMPLETE:
io = spdy_io_control::get(contp);
nbytes = TSIOBufferReaderAvail(io->input.reader);
- debug_plugin("received %d bytes", nbytes);
+ TSLogDebug("received %d bytes", nbytes);
if ((unsigned)nbytes >= spdy::message_header::size) {
consume_spdy_frame(io);
}
@@ -304,7 +304,7 @@ spdy_vconn_io(TSCont contp, TSEvent ev, void * edata)
case TS_EVENT_VCONN_EOS: // fallthru
default:
if (ev != TS_EVENT_VCONN_EOS) {
- debug_plugin("unexpected accept event %s", cstringof(ev));
+ TSLogDebug("unexpected accept event %s", cstringof(ev));
}
io = spdy_io_control::get(contp);
TSVConnClose(io->vconn);
@@ -333,7 +333,7 @@ spdy_accept_io(TSCont contp, TSEvent ev, void * edata)
debug_protocol("accepted new SPDY session %p", io);
break;
default:
- debug_plugin("unexpected accept event %s", cstringof(ev));
+ TSLogDebug("unexpected accept event %s", cstringof(ev));
}
return TS_EVENT_NONE;
@@ -346,10 +346,10 @@ spdy_setup_protocol(TSCont /* contp ATS_UNUSED */, TSEvent ev, void * /* edata A
case TS_EVENT_LIFECYCLE_PORTS_INITIALIZED:
TSReleaseAssert(TSNetAcceptNamedProtocol(TSContCreate(spdy_accept_io, TSMutexCreate()),
TS_NPN_PROTOCOL_SPDY_2) == TS_SUCCESS);
- debug_plugin("registered named protocol endpoint for %s", TS_NPN_PROTOCOL_SPDY_2);
+ TSLogDebug("registered named protocol endpoint for %s", TS_NPN_PROTOCOL_SPDY_2);
break;
default:
- TSError("[spdy] Protocol registration failed");
+ TSLogError("Protocol registration failed");
break;
}
@@ -371,10 +371,10 @@ TSPluginInit(int argc, const char * argv[])
info.support_email = (char *)"jamespeach@me.com";
if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) {
- TSError("[spdy] Plugin registration failed");
+ TSLogError("Plugin registration failed");
}
- debug_plugin("initializing");
+ TSLogDebug("initializing");
for (;;) {
switch (getopt_long(argc, (char * const *)argv, "s", longopts, NULL)) {
@@ -384,7 +384,7 @@ TSPluginInit(int argc, const char * argv[])
case -1:
goto init;
default:
- TSError("[spdy] usage: spdy.so [--system-resolver]");
+ TSLogError("usage: spdy.so [--system-resolver]");
}
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ea58dc2d/plugins/experimental/spdy/stream.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/spdy/stream.cc b/plugins/experimental/spdy/stream.cc
index b5a7474..9735895 100644
--- a/plugins/experimental/spdy/stream.cc
+++ b/plugins/experimental/spdy/stream.cc
@@ -246,7 +246,7 @@ spdy_stream_io(TSCont contp, TSEvent ev, void * edata)
return TS_EVENT_NONE;
default:
- debug_plugin("unexpected stream event %s", cstringof(ev));
+ TSLogDebug("unexpected stream event %s", cstringof(ev));
}
return TS_EVENT_NONE;
[08/13] git commit: transform healthchecks to new logging non-API
Posted by ig...@apache.org.
transform healthchecks to new logging non-API
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/acc0593e
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/acc0593e
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/acc0593e
Branch: refs/heads/consistent-gzip-error-msgs
Commit: acc0593ebd2a3f16936ed9180c6ae2c4677887ed
Parents: e62f7d0
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 23:21:45 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 23:21:45 2013 +0200
----------------------------------------------------------------------
.../experimental/healthchecks/healthchecks.c | 37 +++++++++++---------
1 file changed, 20 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/acc0593e/plugins/experimental/healthchecks/healthchecks.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/healthchecks/healthchecks.c b/plugins/experimental/healthchecks/healthchecks.c
index 3c550b7..8fd9905 100644
--- a/plugins/experimental/healthchecks/healthchecks.c
+++ b/plugins/experimental/healthchecks/healthchecks.c
@@ -37,7 +37,9 @@ limitations under the License.
#include "ts/ts.h"
#include "ink_defs.h"
-static const char PLUGIN_NAME[] = "healthchecks";
+#define PLUGIN_NAME "healthchecks"
+#include <ts/debug.h>
+
static const char SEPARATORS[] = " \t\n";
#define MAX_PATH_LEN 4096
@@ -207,14 +209,14 @@ hc_thread(void *data ATS_UNUSED)
if ((now.tv_sec - last_free.tv_sec) > FREELIST_TIMEOUT) {
HCFileData *fdata = fl, *prev_fdata = fl;
- TSDebug(PLUGIN_NAME, "Checking the freelist");
+ TSLogDebug("Checking the freelist");
memcpy(&last_free, &now, sizeof(struct timeval));
while(fdata) {
if (fdata->remove > now.tv_sec) {
if (prev_fdata)
prev_fdata->_next = fdata->_next;
fdata = fdata->_next;
- TSDebug(PLUGIN_NAME, "Cleaning up entry from frelist");
+ TSLogDebug("Cleaning up entry from frelist");
TSfree(fdata);
} else {
prev_fdata = fdata;
@@ -240,12 +242,12 @@ hc_thread(void *data ATS_UNUSED)
HCFileData *new_data = TSmalloc(sizeof(HCFileData));
if (event->mask & (IN_CLOSE_WRITE)) {
- TSDebug(PLUGIN_NAME, "Modify file event (%d) on %s", event->mask, finfo->fname);
+ TSLogDebug("Modify file event (%d) on %s", event->mask, finfo->fname);
} else if (event->mask & (IN_CREATE|IN_MOVED_TO)) {
- TSDebug(PLUGIN_NAME, "Create file event (%d) on %s", event->mask, finfo->fname);
+ TSLogDebug("Create file event (%d) on %s", event->mask, finfo->fname);
finfo->wd = inotify_add_watch(fd, finfo->fname, IN_DELETE_SELF|IN_CLOSE_WRITE|IN_ATTRIB);
} else if (event->mask & (IN_DELETE_SELF|IN_MOVED_FROM)) {
- TSDebug(PLUGIN_NAME, "Delete file event (%d) on %s", event->mask, finfo->fname);
+ TSLogDebug("Delete file event (%d) on %s", event->mask, finfo->fname);
finfo->wd = inotify_rm_watch(fd, finfo->wd);
}
memset(new_data, 0, sizeof(HCFileData));
@@ -358,7 +360,7 @@ parse_configs(const char* fname)
finfo->data = TSmalloc(sizeof(HCFileData));
memset(finfo->data, 0, sizeof(HCFileData));
reload_status_file(finfo, finfo->data);
- TSDebug(PLUGIN_NAME, "Parsed: %s %s %s %s %s", finfo->path, finfo->fname, mime, ok, miss);
+ TSLogDebug("Parsed: %s %s %s %s %s", finfo->path, finfo->fname, mime, ok, miss);
}
}
fclose(fd);
@@ -399,21 +401,21 @@ hc_process_read(TSCont contp, TSEvent event, HCState *my_state)
{
if (event == TS_EVENT_VCONN_READ_READY) {
if (my_state->data->exists) {
- TSDebug(PLUGIN_NAME, "Setting OK response header");
+ TSLogDebug("Setting OK response header");
my_state->output_bytes = add_data_to_resp(my_state->info->ok, my_state->info->o_len, my_state);
} else {
- TSDebug(PLUGIN_NAME, "Setting MISS response header");
+ TSLogDebug("Setting MISS response header");
my_state->output_bytes = add_data_to_resp(my_state->info->miss, my_state->info->m_len, my_state);
}
TSVConnShutdown(my_state->net_vc, 1, 0);
my_state->write_vio = TSVConnWrite(my_state->net_vc, contp, my_state->resp_reader, INT64_MAX);
} else if (event == TS_EVENT_ERROR) {
- TSError("hc_process_read: Received TS_EVENT_ERROR\n");
+ TSLogError("Received TS_EVENT_ERROR");
} else if (event == TS_EVENT_VCONN_EOS) {
/* client may end the connection, simply return */
return;
} else if (event == TS_EVENT_NET_ACCEPT_FAILED) {
- TSError("hc_process_read: Received TS_EVENT_NET_ACCEPT_FAILED\n");
+ TSLogError("Received TS_EVENT_NET_ACCEPT_FAILED");
} else {
TSReleaseAssert(!"Unexpected Event");
}
@@ -438,7 +440,7 @@ hc_process_write(TSCont contp, TSEvent event, HCState *my_state)
} else if (TS_EVENT_VCONN_WRITE_COMPLETE) {
cleanup(contp, my_state);
} else if (event == TS_EVENT_ERROR) {
- TSError("hc_process_write: Received TS_EVENT_ERROR\n");
+ TSLogError("Received TS_EVENT_ERROR");
} else {
TSReleaseAssert(!"Unexpected Event");
}
@@ -529,7 +531,7 @@ TSPluginInit(int argc, const char *argv[])
TSPluginRegistrationInfo info;
if (2 != argc) {
- TSError("Must specify a configuration file.\n");
+ TSLogError("Must specify a configuration file.");
return;
}
@@ -538,25 +540,26 @@ TSPluginInit(int argc, const char *argv[])
info.support_email = "dev@trafficserver.apache.org";
if (TS_SUCCESS != TSPluginRegister(TS_SDK_VERSION_3_0, &info)) {
- TSError("Plugin registration failed. \n");
+ TSLogError("Plugin registration failed.");
return;
}
/* This will update the global configuration file, and is not reloaded at run time */
/* ToDo: Support reloading with traffic_line -x ? */
if (NULL == (g_config = parse_configs(argv[1]))) {
- TSError("Unable to read / parse %s config file", argv[1]);
+ TSLogError("Unable to read / parse %s config file", argv[1]);
return;
}
/* Setup the background thread */
if (!TSThreadCreate(hc_thread, NULL)) {
- TSError("Failure in thread creation");
+ TSLogError("Failure in thread creation");
return;
}
/* Create a continuation with a mutex as there is a shared global structure
containing the headers to add */
- TSDebug(PLUGIN_NAME, "Started %s plugin", PLUGIN_NAME);
+ TSLogInfo("Started %s plugin", PLUGIN_NAME);
TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, TSContCreate(health_check_origin, NULL));
}
+
[10/13] git commit: transform rfc5861 to new logging non-API
Posted by ig...@apache.org.
transform rfc5861 to new logging non-API
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e68e0c88
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e68e0c88
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e68e0c88
Branch: refs/heads/consistent-gzip-error-msgs
Commit: e68e0c880286748a49c163dbce16496ea3dbbc47
Parents: ff043e1
Author: Igor Galić <i....@brainsware.org>
Authored: Fri Aug 9 00:03:08 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Fri Aug 9 00:03:08 2013 +0200
----------------------------------------------------------------------
plugins/experimental/rfc5861/rfc5861.c | 186 ++++++++++++++--------------
1 file changed, 94 insertions(+), 92 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e68e0c88/plugins/experimental/rfc5861/rfc5861.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/rfc5861/rfc5861.c b/plugins/experimental/rfc5861/rfc5861.c
index 384aa91..3646faa 100644
--- a/plugins/experimental/rfc5861/rfc5861.c
+++ b/plugins/experimental/rfc5861/rfc5861.c
@@ -36,7 +36,8 @@
#include "ts/ts.h"
#include "ts/experimental.h"
-#define LOG_PREFIX "rfc5861"
+#define PLUGIN_NAME "rfc5861"
+#include <ts/debug.h>
//#define ENABLE_SAVE_ORIGINAL_REQUEST
@@ -96,7 +97,7 @@ create_response_info(void)
{
ResponseInfo *resp_info;
- TSDebug(LOG_PREFIX, "Entering create_response_info");
+ TSLogDebug("Entering create_response_info");
resp_info = (ResponseInfo *) TSmalloc(sizeof(ResponseInfo));
@@ -105,7 +106,7 @@ create_response_info(void)
resp_info->parser = TSHttpParserCreate();
resp_info->parsed = false;
- TSDebug(LOG_PREFIX, "Leaving create_reseponse_info");
+ TSLogDebug("Leaving create_reseponse_info");
return resp_info;
}
@@ -113,14 +114,14 @@ create_response_info(void)
static void
free_response_info(ResponseInfo *resp_info)
{
- TSDebug(LOG_PREFIX, "Entering free_response_info");
+ TSLogDebug("Entering free_response_info");
TSHandleMLocRelease(resp_info->buf, TS_NULL_MLOC, resp_info->http_hdr_loc);
TSMBufferDestroy(resp_info->buf);
TSHttpParserDestroy(resp_info->parser);
TSfree(resp_info);
- TSDebug(LOG_PREFIX, "Leaving free_response_info");
+ TSLogDebug("Leaving free_response_info");
}
static RequestInfo*
@@ -132,14 +133,14 @@ create_request_info(TSHttpTxn txn)
TSMBuffer buf;
TSMLoc loc;
- TSDebug(LOG_PREFIX, "Entering create_request_info");
+ TSLogDebug("Entering create_request_info");
req_info = (RequestInfo *) TSmalloc(sizeof(RequestInfo));
url = TSHttpTxnEffectiveUrlStringGet(txn, &url_len);
req_info->effective_url = TSstrndup(url, url_len);
TSfree(url);
- //TSDebug(LOG_PREFIX, "URL: %s", req_info->effective_url);
+ //TSLogDebug("URL: %s", req_info->effective_url);
TSHttpTxnClientReqGet(txn, &buf, &loc);
req_info->buf = TSMBufferCreate();
@@ -149,7 +150,7 @@ create_request_info(TSHttpTxn txn)
req_info->client_addr = TSmalloc(sizeof(struct sockaddr));
memmove((void *) req_info->client_addr, (void *) TSHttpTxnClientAddrGet(txn), sizeof(struct sockaddr));
- TSDebug(LOG_PREFIX, "Leaving create_request_info");
+ TSLogDebug("Leaving create_request_info");
return req_info;
}
@@ -157,20 +158,20 @@ create_request_info(TSHttpTxn txn)
static void
free_request_info(RequestInfo *req_info)
{
- TSDebug(LOG_PREFIX, "Entering free_request_info");
- TSDebug(LOG_PREFIX, "Free effective URL");
- //TSDebug(LOG_PREFIX, "URL: %s", req_info->effective_url);
+ TSLogDebug("Entering free_request_info");
+ TSLogDebug("Free effective URL");
+ //TSLogDebug("URL: %s", req_info->effective_url);
TSfree(req_info->effective_url);
- TSDebug(LOG_PREFIX, "Release Http Header");
+ TSLogDebug("Release Http Header");
TSHandleMLocRelease(req_info->buf, TS_NULL_MLOC, req_info->http_hdr_loc);
- TSDebug(LOG_PREFIX, "Destroy Buffer");
+ TSLogDebug("Destroy Buffer");
TSMBufferDestroy(req_info->buf);
- TSDebug(LOG_PREFIX, "Free Client Addr");
+ TSLogDebug("Free Client Addr");
TSfree(req_info->client_addr);
- TSDebug(LOG_PREFIX, "Free Request Info");
+ TSLogDebug("Free Request Info");
TSfree(req_info);
- TSDebug(LOG_PREFIX, "Leaving free_request_info");
+ TSLogDebug("Leaving free_request_info");
}
static CachedHeaderInfo*
@@ -188,14 +189,14 @@ get_cached_header_info(TSHttpTxn txn)
chi->stale_while_revalidate = 0;
chi->stale_on_error = 0;
- TSDebug(LOG_PREFIX, "Inside get_cached_header_info");
+ TSLogDebug("Inside get_cached_header_info");
if (TSHttpTxnCachedRespGet(txn, &cr_buf, &cr_hdr_loc) == TS_SUCCESS)
{
cr_date_loc = TSMimeHdrFieldFind(cr_buf, cr_hdr_loc, TS_MIME_FIELD_DATE, TS_MIME_LEN_DATE);
if (cr_date_loc != TS_NULL_MLOC)
{
- TSDebug(LOG_PREFIX, "Found a date");
+ TSLogDebug("Found a date");
chi->date = TSMimeHdrFieldValueDateGet(cr_buf, cr_hdr_loc, cr_date_loc);
TSHandleMLocRelease(cr_buf, cr_hdr_loc, cr_date_loc);
}
@@ -204,7 +205,7 @@ get_cached_header_info(TSHttpTxn txn)
while(cr_cache_control_loc != TS_NULL_MLOC)
{
- TSDebug(LOG_PREFIX, "Found cache-control");
+ TSLogDebug("Found cache-control");
cr_cache_control_count = TSMimeHdrFieldValuesCount(cr_buf, cr_hdr_loc, cr_cache_control_loc);
for (i = 0; i < cr_cache_control_count; i++)
@@ -214,7 +215,7 @@ get_cached_header_info(TSHttpTxn txn)
if (strncmp(value, TS_HTTP_VALUE_MAX_AGE, TS_HTTP_LEN_MAX_AGE) == 0)
{
- TSDebug(LOG_PREFIX, "Found max-age");
+ TSLogDebug("Found max-age");
ptr += TS_HTTP_LEN_MAX_AGE;
if (*ptr == '=')
{
@@ -224,13 +225,13 @@ get_cached_header_info(TSHttpTxn txn)
else
{
ptr = TSstrndup(value, TS_HTTP_LEN_MAX_AGE + 2);
- TSDebug(LOG_PREFIX, "This is what I found: %s", ptr);
+ TSLogDebug("This is what I found: %s", ptr);
TSfree(ptr);
}
}
else if (strncmp(value, HTTP_VALUE_STALE_WHILE_REVALIDATE, strlen(HTTP_VALUE_STALE_WHILE_REVALIDATE)) == 0)
{
- TSDebug(LOG_PREFIX, "Found stale-while-revalidate");
+ TSLogDebug("Found stale-while-revalidate");
ptr += strlen(HTTP_VALUE_STALE_WHILE_REVALIDATE);
if (*ptr == '=')
{
@@ -240,7 +241,7 @@ get_cached_header_info(TSHttpTxn txn)
}
else if (strncmp(value, HTTP_VALUE_STALE_IF_ERROR, strlen(HTTP_VALUE_STALE_IF_ERROR)) == 0)
{
- TSDebug(LOG_PREFIX, "Found stale-on-error");
+ TSLogDebug("Found stale-on-error");
ptr += strlen(HTTP_VALUE_STALE_IF_ERROR);
if (*ptr == '=')
{
@@ -250,7 +251,7 @@ get_cached_header_info(TSHttpTxn txn)
}
else
{
- TSDebug(LOG_PREFIX, "Unknown field value");
+ TSLogDebug("Unknown field value");
}
}
@@ -261,7 +262,7 @@ get_cached_header_info(TSHttpTxn txn)
TSHandleMLocRelease(cr_buf, TS_NULL_MLOC, cr_hdr_loc);
}
- TSDebug(LOG_PREFIX, "Leaving get_cached_header_info");
+ TSLogDebug("Leaving get_cached_header_info");
return chi;
}
@@ -279,7 +280,7 @@ parse_response(StateInfo *state)
int64_t avail;
char *start;
- TSDebug(LOG_PREFIX, "Entering parse_response");
+ TSLogDebug("Entering parse_response");
block = TSIOBufferReaderStart(state->resp_io_buf_reader);
@@ -297,10 +298,10 @@ parse_response(StateInfo *state)
{
state->resp_info->status = TSHttpHdrStatusGet(state->resp_info->buf, state->resp_info->http_hdr_loc);
state->resp_info->parsed = true;
- TSDebug(LOG_PREFIX, "HTTP Status: %d", state->resp_info->status);
+ TSLogDebug("HTTP Status: %d", state->resp_info->status);
}
- TSDebug(LOG_PREFIX, "Leaving parse_response");
+ TSLogDebug("Leaving parse_response");
}
static int
@@ -312,7 +313,7 @@ consume_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
TSMLoc url_loc;
int lookup_count;
- TSDebug(LOG_PREFIX, "Entering consume_resource");
+ TSLogDebug("Entering consume_resource");
vconn = (TSVConn) edata;
state = (StateInfo *) TSContDataGet(cont);
@@ -321,15 +322,15 @@ consume_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
{
case TS_EVENT_VCONN_WRITE_READY:
// We shouldn't get here because we specify the exact size of the buffer.
- TSDebug(LOG_PREFIX, "Write Ready");
+ TSLogDebug("Write Ready");
case TS_EVENT_VCONN_WRITE_COMPLETE:
- TSDebug(LOG_PREFIX, "Write Complete");
- //TSDebug(LOG_PREFIX, "TSVConnShutdown()");
+ TSLogDebug("Write Complete");
+ //TSLogDebug("TSVConnShutdown()");
//TSVConnShutdown(state->vconn, 0, 1);
//TSVIOReenable(state->w_vio);
break;
case TS_EVENT_VCONN_READ_READY:
- TSDebug(LOG_PREFIX, "Read Ready");
+ TSLogDebug("Read Ready");
avail = TSIOBufferReaderAvail(state->resp_io_buf_reader);
@@ -349,21 +350,21 @@ consume_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
case TS_EVENT_VCONN_INACTIVITY_TIMEOUT:
if (event == TS_EVENT_VCONN_INACTIVITY_TIMEOUT)
{
- TSDebug(LOG_PREFIX, "Inactivity Timeout");
- TSDebug(LOG_PREFIX, "TSVConnAbort()");
+ TSLogDebug("Inactivity Timeout");
+ TSLogDebug("TSVConnAbort()");
TSVConnAbort(vconn, TS_VC_CLOSE_ABORT);
}
else
{
if (event == TS_EVENT_VCONN_READ_COMPLETE)
{
- TSDebug(LOG_PREFIX, "Read Complete");
+ TSLogDebug("Read Complete");
}
else if (event == TS_EVENT_VCONN_EOS)
{
- TSDebug(LOG_PREFIX, "EOS");
+ TSLogDebug("EOS");
}
- TSDebug(LOG_PREFIX, "TSVConnClose()");
+ TSLogDebug("TSVConnClose()");
TSVConnClose(state->vconn);
}
@@ -380,18 +381,18 @@ consume_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
TSVIONDoneSet(state->r_vio, TSVIONDoneGet(state->r_vio) + avail);
if (state->async_req)
{
- TSDebug(LOG_PREFIX, "Unlock URL");
+ TSLogDebug("Unlock URL");
TSMutexLock(troot_mutex);
tdelete(state->req_info->effective_url, &troot, xstrcmp);
TSMutexUnlock(troot_mutex);
}
else
{
- TSDebug(LOG_PREFIX, "In sync path. setting fresh and re-enabling");
+ TSLogDebug("In sync path. setting fresh and re-enabling");
TSHttpTxnCacheLookupCountGet(state->txn, &lookup_count);
if ((state->resp_info->status == 500) || ((state->resp_info->status >= 502) && (state->resp_info->status <= 504)) || lookup_count > 2)
{
- TSDebug(LOG_PREFIX, "Sending stale data as fresh");
+ TSLogDebug("Sending stale data as fresh");
if (log_info.object && (log_info.all || log_info.stale_if_error))
{
CachedHeaderInfo *chi = get_cached_header_info(state->txn);
@@ -403,7 +404,7 @@ consume_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
}
else
{
- TSDebug(LOG_PREFIX, "Attempting new cache lookup");
+ TSLogDebug("Attempting new cache lookup");
TSHttpHdrUrlGet(state->req_info->buf, state->req_info->http_hdr_loc, &url_loc);
TSHttpTxnNewCacheLookupDo(state->txn, state->req_info->buf, url_loc);
TSHandleMLocRelease(state->req_info->buf, state->req_info->http_hdr_loc, url_loc);
@@ -422,15 +423,15 @@ consume_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
TSIOBufferReaderFree(state->resp_io_buf_reader);
TSIOBufferDestroy(state->resp_io_buf);
TSfree(state);
- TSDebug(LOG_PREFIX, "Destroying Cont");
+ TSLogDebug("Destroying Cont");
TSContDestroy(cont);
break;
default:
- TSError("Unknown event %d.", event);
+ TSLogError("Unknown event %d.", event);
break;
}
- TSDebug(LOG_PREFIX, "Leaving consume_resource");
+ TSLogDebug("Leaving consume_resource");
return 0;
}
@@ -442,18 +443,18 @@ fetch_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
//struct sockaddr_in client_addr;
TSMLoc connection_hdr_loc, connection_hdr_dup_loc;
- TSDebug(LOG_PREFIX, "Entering fetch_resource");
+ TSLogDebug("Entering fetch_resource");
state = (StateInfo *) TSContDataGet(cont);
- TSDebug(LOG_PREFIX, "state: %p", state);
+ TSLogDebug("state: %p", state);
//li = (RequestInfo *) edata;
TSMutexLock(troot_mutex);
// If already doing async lookup lets just close shop and go home
if (state->async_req && (tfind(state->req_info->effective_url, &troot, xstrcmp) != NULL))
{
- TSDebug(LOG_PREFIX, "Looks like an async is already in progress");
+ TSLogDebug("Looks like an async is already in progress");
TSMutexUnlock(troot_mutex);
free_request_info(state->req_info);
TSfree(state);
@@ -461,11 +462,11 @@ fetch_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
// Otherwise lets do the lookup!
else
{
- TSDebug(LOG_PREFIX, "Lets do the lookup");
+ TSLogDebug("Lets do the lookup");
if (state->async_req)
{
// Lock in tree
- TSDebug(LOG_PREFIX, "Locking URL");
+ TSLogDebug("Locking URL");
tsearch(state->req_info->effective_url, &troot, xstrcmp);
}
TSMutexUnlock(troot_mutex);
@@ -481,12 +482,12 @@ fetch_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
state->resp_info = create_response_info();
}
- TSDebug(LOG_PREFIX, "Set Connection: close");
+ TSLogDebug("Set Connection: close");
connection_hdr_loc = TSMimeHdrFieldFind(state->req_info->buf, state->req_info->http_hdr_loc, TS_MIME_FIELD_CONNECTION, TS_MIME_LEN_CONNECTION);
while(connection_hdr_loc != TS_NULL_MLOC)
{
- TSDebug(LOG_PREFIX, "Found old Connection hdr");
+ TSLogDebug("Found old Connection hdr");
connection_hdr_dup_loc = TSMimeHdrFieldNextDup(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc);
TSMimeHdrFieldRemove(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc);
@@ -496,43 +497,43 @@ fetch_resource(TSCont cont, TSEvent event ATS_UNUSED, void *edata ATS_UNUSED)
}
// This seems to have little effect
- TSDebug(LOG_PREFIX, "Creating Connection hdr");
+ TSLogDebug("Creating Connection hdr");
TSMimeHdrFieldCreateNamed(state->req_info->buf, state->req_info->http_hdr_loc, TS_MIME_FIELD_CONNECTION, TS_MIME_LEN_CONNECTION, &connection_hdr_loc);
TSMimeHdrFieldValueStringInsert(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc, -1, TS_HTTP_VALUE_CLOSE, TS_HTTP_LEN_CLOSE);
TSMimeHdrFieldAppend(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc);
TSHandleMLocRelease(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc);
/*
- TSDebug(LOG_PREFIX, "Creating @RFC5861 header");
+ TSLogDebug("Creating @RFC5861 header");
TSMimeHdrFieldCreateNamed(state->req_info->buf, state->req_info->http_hdr_loc, TS_MIME_FIELD_CONNECTION, TS_MIME_LEN_CONNECTION, &connection_hdr_loc);
TSMimeHdrFieldValueStringInsert(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc, -1, TS_HTTP_VALUE_CLOSE, TS_HTTP_LEN_CLOSE);
TSMimeHdrFieldAppend(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc);
TSHandleMLocRelease(state->req_info->buf, state->req_info->http_hdr_loc, connection_hdr_loc);
*/
- TSDebug(LOG_PREFIX, "Create Buffers");
+ TSLogDebug("Create Buffers");
state->req_io_buf = TSIOBufferCreate();
state->req_io_buf_reader = TSIOBufferReaderAlloc(state->req_io_buf);
state->resp_io_buf = TSIOBufferCreate();
state->resp_io_buf_reader = TSIOBufferReaderAlloc(state->resp_io_buf);
- TSDebug(LOG_PREFIX, "HdrPrint()");
+ TSLogDebug("HdrPrint()");
TSHttpHdrPrint(state->req_info->buf, state->req_info->http_hdr_loc, state->req_io_buf);
TSIOBufferWrite(state->req_io_buf, "\r\n", 2);
- TSDebug(LOG_PREFIX, "TSHttpConnect()");
+ TSLogDebug("TSHttpConnect()");
//memmove((void *) &client_addr, (void *) state->req_info->client_addr, sizeof(struct sockaddr));
- //TSDebug(LOG_PREFIX, "client_addr: %s:%d", inet_ntoa(client_addr.sin_addr), client_addr.sin_port);
+ //TSLogDebug("client_addr: %s:%d", inet_ntoa(client_addr.sin_addr), client_addr.sin_port);
state->vconn = TSHttpConnect((struct sockaddr const *) state->req_info->client_addr);
- TSDebug(LOG_PREFIX, "TSVConnRead()");
+ TSLogDebug("TSVConnRead()");
state->r_vio = TSVConnRead(state->vconn, consume_cont, state->resp_io_buf, INT64_MAX);
- TSDebug(LOG_PREFIX, "TSVConnWrite()");
+ TSLogDebug("TSVConnWrite()");
state->w_vio = TSVConnWrite(state->vconn, consume_cont, state->req_io_buf_reader, TSIOBufferReaderAvail(state->req_io_buf_reader));
}
TSContDestroy(cont);
- TSDebug(LOG_PREFIX, "Leaving fetch_resource");
+ TSLogDebug("Leaving fetch_resource");
return 0;
}
@@ -549,26 +550,26 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
TSMLoc loc,warn_loc;
TSHttpStatus http_status;
- TSDebug(LOG_PREFIX, "Entering rfc5861_plugin");
+ TSLogDebug("Entering rfc5861_plugin");
switch (event)
{
// Is this the proper event?
case TS_EVENT_HTTP_READ_REQUEST_HDR:
- TSDebug(LOG_PREFIX, "Event: TS_EVENT_HTTP_READ_REQUEST_HDR");
+ TSLogDebug("Event: TS_EVENT_HTTP_READ_REQUEST_HDR");
if (TSHttpIsInternalRequest(txn) != TS_SUCCESS)
{
- TSDebug(LOG_PREFIX, "External Request");
+ TSLogDebug("External Request");
state = TSmalloc(sizeof(StateInfo));
time(&state->txn_start);
state->req_info = create_request_info(txn);
- TSDebug(LOG_PREFIX, "state after TSmalloc: %p", state);
+ TSLogDebug("state after TSmalloc: %p", state);
TSHttpTxnArgSet(txn, txn_slot, (void *) state);
TSHttpTxnHookAdd(txn, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, cont);
}
else
{
- TSDebug(LOG_PREFIX, "Internal Request"); // This is insufficient if there are other plugins using TSHttpConnect
+ TSLogDebug("Internal Request"); // This is insufficient if there are other plugins using TSHttpConnect
//TSHttpTxnHookAdd(txn, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, cont);
TSHttpTxnHookAdd(txn, TS_HTTP_READ_RESPONSE_HDR_HOOK, cont);
// This might be needed in 3.2.0 to fix a timeout issue
@@ -577,25 +578,25 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
}
TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
- TSDebug(LOG_PREFIX, "TS_EVENT_HTTP_READ_REQUEST_HDR Event Handler End");
+ TSLogDebug("TS_EVENT_HTTP_READ_REQUEST_HDR Event Handler End");
break;
case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE:
- TSDebug(LOG_PREFIX, "Event: TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE");
+ TSLogDebug("Event: TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE");
state = (StateInfo *) TSHttpTxnArgGet(txn, txn_slot);
TSHttpTxnCacheLookupCountGet(txn, &lookup_count);
- TSDebug(LOG_PREFIX, "state after arg get: %p", state);
+ TSLogDebug("state after arg get: %p", state);
if (TSHttpTxnCacheLookupStatusGet(txn, &status) == TS_SUCCESS)
{
// Are we stale?
if (status == TS_CACHE_LOOKUP_HIT_STALE)
{
- TSDebug(LOG_PREFIX, "CacheLookupStatus is STALE");
+ TSLogDebug("CacheLookupStatus is STALE");
// Get headers
chi = get_cached_header_info(txn);
if ((state->txn_start - chi->date) < (chi->max_age + chi->stale_while_revalidate))
{
- TSDebug(LOG_PREFIX, "Looks like we can return fresh info and validate in the background");
+ TSLogDebug("Looks like we can return fresh info and validate in the background");
if (log_info.object && (log_info.all || log_info.stale_while_revalidate))
TSTextLogObjectWrite(log_info.object, "stale-while-revalidate: %d - %d < %d + %d %s", (int) state->txn_start, (int) chi->date, (int) chi->max_age, (int) chi->stale_while_revalidate, state->req_info->effective_url);
// lookup async
@@ -606,23 +607,23 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
// Set warning header
TSHttpTxnHookAdd(txn, TS_HTTP_SEND_RESPONSE_HDR_HOOK, cont);
- TSDebug(LOG_PREFIX, "set state as async");
+ TSLogDebug("set state as async");
state->async_req = true;
- TSDebug(LOG_PREFIX, "TSHttpTxnCacheLookupStatusSet()");
+ TSLogDebug("TSHttpTxnCacheLookupStatusSet()");
TSHttpTxnCacheLookupStatusSet(txn, TS_CACHE_LOOKUP_HIT_FRESH);
//TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
- TSDebug(LOG_PREFIX, "TSContCreate()");
+ TSLogDebug("TSContCreate()");
fetch_cont = TSContCreate(fetch_resource, NULL);
- TSDebug(LOG_PREFIX, "TSContDataSet()");
+ TSLogDebug("TSContDataSet()");
TSContDataSet(fetch_cont, (void *) state);
- TSDebug(LOG_PREFIX, "state: %p", state);
+ TSLogDebug("state: %p", state);
TSContSchedule(fetch_cont, 0, TS_THREAD_POOL_TASK);
- TSDebug(LOG_PREFIX, "TSHttpTxnReenable()");
+ TSLogDebug("TSHttpTxnReenable()");
TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
}
else if ((state->txn_start - chi->date) < (chi->max_age + chi->stale_on_error))
{
- TSDebug(LOG_PREFIX, "Looks like we can return fresh data on 500 error");
+ TSLogDebug("Looks like we can return fresh data on 500 error");
#if (TS_VERSION_NUMBER >= 3003000)
TSHttpTxnConfigIntSet(txn, TS_CONFIG_HTTP_INSERT_AGE_IN_RESPONSE, 1);
#endif
@@ -636,7 +637,8 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
}
else
{
- TSDebug(LOG_PREFIX, "No love? now: %d date: %d max-age: %d swr: %d soe: %d", (int) state->txn_start, (int) chi->date, (int) chi->max_age, (int) chi->stale_while_revalidate, (int) chi->stale_on_error);
+ TSLogDebug("No love? now: %d date: %d max-age: %d swr: %d soe: %d", (int) state->txn_start,
+ (int) chi->date, (int) chi->max_age, (int) chi->stale_while_revalidate, (int) chi->stale_on_error);
if (lookup_count == 1)
{
free_request_info(state->req_info);
@@ -649,7 +651,7 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
}
else
{
- TSDebug(LOG_PREFIX, "Not Stale!");
+ TSLogDebug("Not Stale!");
if (lookup_count == 1)
{
free_request_info(state->req_info);
@@ -660,7 +662,7 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
}
else
{
- TSDebug(LOG_PREFIX, "Could not get CacheLookupStatus");
+ TSLogDebug("Could not get CacheLookupStatus");
if (lookup_count == 1)
{
free_request_info(state->req_info);
@@ -668,15 +670,15 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
}
TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
}
- TSDebug(LOG_PREFIX, "TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE Event Handler End");
+ TSLogDebug("TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE Event Handler End");
break;
case TS_EVENT_HTTP_READ_RESPONSE_HDR:
- TSDebug(LOG_PREFIX, "Event: TS_EVENT_HTTP_READ_RESPONSE_HDR");
+ TSLogDebug("Event: TS_EVENT_HTTP_READ_RESPONSE_HDR");
TSHttpTxnServerRespGet(txn, &buf, &loc);
http_status = TSHttpHdrStatusGet(buf, loc);
if ((http_status == 500) || ((http_status >= 502) && (http_status <= 504))) // 500, 502, 503, or 504
{
- TSDebug(LOG_PREFIX, "Set non-cachable");
+ TSLogDebug("Set non-cachable");
#if (TS_VERSION_NUMBER >= 3003000)
TSHttpTxnServerRespNoStoreSet(txn,1);
#else
@@ -685,11 +687,11 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
}
TSHandleMLocRelease(buf, TS_NULL_MLOC, loc);
TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
- TSDebug(LOG_PREFIX, "TS_EVENT_HTTP_READ_RESPONSE_HDR Event Handler End");
+ TSLogDebug("TS_EVENT_HTTP_READ_RESPONSE_HDR Event Handler End");
break;
case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
- TSDebug(LOG_PREFIX, "Event: TS_EVENT_HTTP_SEND_RESPONSE_HDR");
- TSDebug(LOG_PREFIX, "set warning header");
+ TSLogDebug("Event: TS_EVENT_HTTP_SEND_RESPONSE_HDR");
+ TSLogDebug("set warning header");
TSHttpTxnClientRespGet(txn, &buf, &loc);
TSMimeHdrFieldCreateNamed(buf, loc, TS_MIME_FIELD_WARNING, TS_MIME_LEN_WARNING, &warn_loc);
TSMimeHdrFieldValueStringInsert(buf, loc, warn_loc, -1, HTTP_VALUE_STALE_WARNING, strlen(HTTP_VALUE_STALE_WARNING));
@@ -697,14 +699,14 @@ rfc5861_plugin(TSCont cont, TSEvent event, void *edata)
TSHandleMLocRelease(buf, loc, warn_loc);
TSHandleMLocRelease(buf, TS_NULL_MLOC, loc);
TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
- TSDebug(LOG_PREFIX, "TS_EVENT_HTTP_SEND_RESPONSE_HDR Event Handler End");
+ TSLogDebug("TS_EVENT_HTTP_SEND_RESPONSE_HDR Event Handler End");
break;
default:
TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
break;
}
- TSDebug(LOG_PREFIX, "Leaving rfc5861_plugin");
+ TSLogDebug("Leaving rfc5861_plugin");
return 0;
}
@@ -721,12 +723,12 @@ TSPluginInit (int argc, const char *argv[])
if (TSPluginRegister(TS_SDK_VERSION_3_0 , &info) != TS_SUCCESS)
{
- TSError("Plugin registration failed.\n");
+ TSLogError("Plugin registration failed.\n");
return;
}
else
{
- TSDebug(LOG_PREFIX, "Plugin registration succeeded.\n");
+ TSLogDebug("Plugin registration succeeded.\n");
}
if (argc > 1)
@@ -771,5 +773,5 @@ TSPluginInit (int argc, const char *argv[])
main_cont = TSContCreate(rfc5861_plugin, NULL);
TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, main_cont);
- TSDebug(LOG_PREFIX, "Plugin Init Complete.\n");
+ TSLogDebug("Plugin Init Complete.\n");
}
[04/13] git commit: transform buffer_upload to new logging non-API
Posted by ig...@apache.org.
transform buffer_upload to new logging non-API
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/c10d8da1
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/c10d8da1
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/c10d8da1
Branch: refs/heads/consistent-gzip-error-msgs
Commit: c10d8da1ddc5af50386dc3a31485d111a9cdcb3a
Parents: 380aab3
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 22:45:16 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 22:45:16 2013 +0200
----------------------------------------------------------------------
.../experimental/buffer_upload/buffer_upload.cc | 171 +++++++++----------
1 file changed, 80 insertions(+), 91 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c10d8da1/plugins/experimental/buffer_upload/buffer_upload.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/buffer_upload/buffer_upload.cc b/plugins/experimental/buffer_upload/buffer_upload.cc
index 847c519..245ae3c 100644
--- a/plugins/experimental/buffer_upload/buffer_upload.cc
+++ b/plugins/experimental/buffer_upload/buffer_upload.cc
@@ -44,22 +44,12 @@
#define true 1
#define false 0
-/* #define DEBUG 1 */
-#define DEBUG_TAG "buffer_upload-dbg"
+#define PLUGIN_NAME "buffer_upload"
+#include <ts/debug.h>
/**************************************************
Log macros for error code return verification
**************************************************/
-#define PLUGIN_NAME "buffer_upload"
-//#define LOG_SET_FUNCTION_NAME(NAME) const char * FUNCTION_NAME = NAME
-#define LOG_ERROR(API_NAME) { \
- TSError("%s: %s %s %s File %s, line number %d", PLUGIN_NAME, API_NAME, "APIFAIL", \
- __FUNCTION__, __FILE__, __LINE__); \
- }
-#define LOG_ERROR_AND_RETURN(API_NAME) { \
- LOG_ERROR(API_NAME); \
- return TS_ERROR; \
- }
#define VALID_PTR(X) (X != NULL)
#define NOT_VALID_PTR(X) (X == NULL)
@@ -157,8 +147,8 @@ print_buffer(TSIOBufferReader reader)
block = TSIOBufferReaderStart(reader);
while (block != NULL) {
ptr = TSIOBufferBlockReadStart(block, reader, &size);
- TSDebug(DEBUG_TAG, "buffer size: %d", size);
- TSDebug(DEBUG_TAG, "buffer: %.*s", size, ptr);
+ TSLogDebug("buffer size: %d", size);
+ TSLogDebug("buffer: %.*s", size, ptr);
block = TSIOBufferBlockNext(block);
}
}
@@ -178,11 +168,13 @@ write_buffer_to_disk(TSIOBufferReader reader, pvc_state * my_state, TSCont contp
ptr = TSIOBufferBlockReadStart(block, reader, &size);
pBuf = (char *) TSmalloc(sizeof(char) * size);
if (pBuf == NULL) {
- LOG_ERROR_AND_RETURN("TSAIOWrite");
+ TSLogError("TSAIOWrite");
+ return TS_ERROR;
}
memcpy(pBuf, ptr, size);
if (TSAIOWrite(my_state->fd, my_state->write_offset, pBuf, size, contp) < 0) {
- LOG_ERROR_AND_RETURN("TSAIOWrite");
+ TSLogError("TSAIOWrite");
+ return TS_ERROR;
}
my_state->write_offset += size;
block = TSIOBufferBlockNext(block);
@@ -198,21 +190,25 @@ call_httpconnect(TSCont contp, pvc_state * my_state)
//unsigned int client_ip = TSHttpTxnClientIPGet(my_state->http_txnp);
sockaddr const *client_ip = TSHttpTxnClientAddrGet(my_state->http_txnp);
- TSDebug(DEBUG_TAG, "call TSHttpConnect() ...");
+ TSLogDebug("call TSHttpConnect() ...");
if ((my_state->net_vc = TSHttpConnect(client_ip)) == NULL) {
- LOG_ERROR_AND_RETURN("TSHttpConnect");
+ TSLogError("TSHttpConnect");
+ return TS_ERROR;
}
my_state->p_write_vio = TSVConnWrite(my_state->p_vc, contp, my_state->resp_reader, INT_MAX);
if (my_state->p_write_vio == NULL) {
- LOG_ERROR_AND_RETURN("TSVConnWrite");
+ TSLogError("TSVConnWrite");
+ return TS_ERROR;
}
my_state->n_read_vio = TSVConnRead(my_state->net_vc, contp, my_state->resp_buffer, INT_MAX);
if (my_state->n_read_vio == NULL) {
- LOG_ERROR_AND_RETURN("TSVConnRead");
+ TSLogError("TSVConnRead");
+ return TS_ERROR;
}
my_state->n_write_vio = TSVConnWrite(my_state->net_vc, contp, my_state->req_reader, INT_MAX);
if (my_state->n_write_vio == NULL) {
- LOG_ERROR_AND_RETURN("TSVConnWrite");
+ TSLogError("TSVConnWrite");
+ return TS_ERROR;
}
return TS_SUCCESS;
}
@@ -277,7 +273,7 @@ pvc_check_done(TSCont contp, pvc_state * my_state)
static void
pvc_process_accept(TSCont contp, int event, void *edata, pvc_state * my_state)
{
- TSDebug(DEBUG_TAG, "plugin called: pvc_process_accept with event %d", event);
+ TSLogDebug("plugin called: pvc_process_accept with event %d", event);
if (event == TS_EVENT_NET_ACCEPT) {
my_state->p_vc = (TSVConn) edata;
@@ -294,13 +290,13 @@ pvc_process_accept(TSCont contp, int event, void *edata, pvc_state * my_state)
if ((my_state->req_buffer == NULL) || (my_state->req_reader == NULL)
|| (my_state->resp_buffer == NULL) || (my_state->resp_reader == NULL)) {
- LOG_ERROR("TSIOBufferCreate || TSIOBufferReaderAlloc");
+ TSLogError("TSIOBufferCreate || TSIOBufferReaderAlloc");
TSVConnClose(my_state->p_vc);
pvc_cleanup(contp, my_state);
} else {
my_state->p_read_vio = TSVConnRead(my_state->p_vc, contp, my_state->req_buffer, INT_MAX);
if (my_state->p_read_vio == NULL) {
- LOG_ERROR("TSVConnRead");
+ TSLogError("TSVConnRead");
}
}
} else if (event == TS_EVENT_NET_ACCEPT_FAILED) {
@@ -315,7 +311,7 @@ pvc_process_p_read(TSCont contp, TSEvent event, pvc_state * my_state)
{
int size, consume_size;
- //TSDebug(DEBUG_TAG, "plugin called: pvc_process_p_read with event %d", event);
+ //TSLogDebug("plugin called: pvc_process_p_read with event %d", event);
switch (event) {
case TS_EVENT_VCONN_READ_READY:
@@ -335,7 +331,7 @@ pvc_process_p_read(TSCont contp, TSEvent event, pvc_state * my_state)
if (uconfig->use_disk_buffer) {
TSMutexLock(my_state->disk_io_mutex);
if (write_buffer_to_disk(my_state->req_hdr_reader, my_state, contp) == TS_ERROR) {
- LOG_ERROR("write_buffer_to_disk");
+ TSLogError("write_buffer_to_disk");
uconfig->use_disk_buffer = 0;
close(my_state->fd);
remove(my_state->filename);
@@ -347,7 +343,7 @@ pvc_process_p_read(TSCont contp, TSEvent event, pvc_state * my_state)
if (uconfig->use_disk_buffer) {
TSMutexLock(my_state->disk_io_mutex);
if (write_buffer_to_disk(my_state->req_reader, my_state, contp) == TS_ERROR) {
- TSDebug(DEBUG_TAG, "Error in writing to disk");
+ TSLogDebug("Error in writing to disk");
}
TSMutexUnlock(my_state->disk_io_mutex);
} else {
@@ -368,7 +364,7 @@ pvc_process_p_read(TSCont contp, TSEvent event, pvc_state * my_state)
if (size > 0) {
TSMutexLock(my_state->disk_io_mutex);
if (write_buffer_to_disk(my_state->req_reader, my_state, contp) == TS_ERROR) {
- TSDebug(DEBUG_TAG, "Error in writing to disk");
+ TSLogDebug("Error in writing to disk");
}
TSIOBufferReaderConsume(my_state->req_reader, size);
TSMutexUnlock(my_state->disk_io_mutex);
@@ -377,7 +373,7 @@ pvc_process_p_read(TSCont contp, TSEvent event, pvc_state * my_state)
// if the entire post data had been read in memory, then connect to origin server.
if (size >= my_state->req_size) {
if (call_httpconnect(contp, my_state) == TS_ERROR) {
- LOG_ERROR("call_httpconnect");
+ TSLogError("call_httpconnect");
}
}
}
@@ -394,7 +390,7 @@ pvc_process_p_read(TSCont contp, TSEvent event, pvc_state * my_state)
ndone = TSVIONDoneGet(my_state->p_read_vio);
if (ndone == TS_ERROR) {
- LOG_ERROR("TSVIODoneGet");
+ TSLogError("TSVIODoneGet");
}
my_state->p_read_vio = NULL;
@@ -420,7 +416,7 @@ pvc_process_n_write(TSCont contp, TSEvent event, pvc_state * my_state)
{
int size;
- //TSDebug(DEBUG_TAG, "plugin called: pvc_process_n_write with event %d", event);
+ //TSLogDebug("plugin called: pvc_process_n_write with event %d", event);
switch (event) {
case TS_EVENT_VCONN_WRITE_READY:
@@ -467,7 +463,7 @@ pvc_process_n_write(TSCont contp, TSEvent event, pvc_state * my_state)
static void
pvc_process_n_read(TSCont contp, TSEvent event, pvc_state * my_state)
{
- //TSDebug(DEBUG_TAG, "plugin called: pvc_process_n_read with event %d", event);
+ //TSLogDebug("plugin called: pvc_process_n_read with event %d", event);
switch (event) {
case TS_EVENT_VCONN_READ_READY:
@@ -484,7 +480,7 @@ pvc_process_n_read(TSCont contp, TSEvent event, pvc_state * my_state)
ndone = TSVIONDoneGet(my_state->n_read_vio);
if (ndone == TS_ERROR) {
- LOG_ERROR("TSVIODoneGet");
+ TSLogError("TSVIODoneGet");
}
my_state->n_read_vio = NULL;
@@ -493,7 +489,7 @@ pvc_process_n_read(TSCont contp, TSEvent event, pvc_state * my_state)
todo = TSVIONTodoGet(my_state->p_write_vio);
if (todo == TS_ERROR) {
- LOG_ERROR("TSVIOTodoGet");
+ TSLogError("TSVIOTodoGet");
/* Error so set it to 0 to cleanup */
todo = 0;
}
@@ -517,7 +513,7 @@ pvc_process_n_read(TSCont contp, TSEvent event, pvc_state * my_state)
static void
pvc_process_p_write(TSCont contp, TSEvent event, pvc_state * my_state)
{
- //TSDebug(DEBUG_TAG, "plugin called: pvc_process_p_write with event %d", event);
+ //TSLogDebug("plugin called: pvc_process_p_write with event %d", event);
switch (event) {
case TS_EVENT_VCONN_WRITE_READY:
@@ -571,7 +567,7 @@ pvc_plugin(TSCont contp, TSEvent event, void *edata)
char *buf = TSAIOBufGet(callback);
if (buf != my_state->chunk_buffer) {
// this TS_AIO_EVENT_DONE event is from TSAIOWrite()
- TSDebug(DEBUG_TAG, "aio write size: %d", size);
+ TSLogDebug("aio write size: %d", size);
my_state->size_written += size;
if (buf != NULL) {
TSfree(buf);
@@ -579,12 +575,12 @@ pvc_plugin(TSCont contp, TSEvent event, void *edata)
if (my_state->size_written >= my_state->req_size) {
// the entire post data had been written to disk already, make the connection now
if (call_httpconnect(contp, my_state) == TS_ERROR) {
- TSDebug(DEBUG_TAG, "call_httpconnect");
+ TSLogDebug("call_httpconnect");
}
}
} else {
// this TS_AIO_EVENT_DONE event is from TSAIORead()
- TSDebug(DEBUG_TAG, "aio read size: %d", size);
+ TSLogDebug("aio read size: %d", size);
TSIOBufferWrite(my_state->req_buffer, my_state->chunk_buffer, size);
my_state->size_read += size;
if (my_state->size_read >= my_state->req_size && my_state->fd != -1) {
@@ -598,7 +594,7 @@ pvc_plugin(TSCont contp, TSEvent event, void *edata)
TSMutexUnlock(my_state->disk_io_mutex);
} else {
- TSDebug(DEBUG_TAG, "event: %d", event);
+ TSLogDebug("event: %d", event);
TSReleaseAssert(!"Unexpected Event");
}
@@ -644,7 +640,7 @@ convert_url_func(TSMBuffer req_bufp, TSMLoc req_loc)
char pathTmp[len + 1];
memset(pathTmp, 0, sizeof pathTmp);
memcpy(pathTmp, str, len);
- TSDebug(DEBUG_TAG, "convert_url_func working on path: %s", pathTmp);
+ TSLogDebug("convert_url_func working on path: %s", pathTmp);
colon = strstr(str, ":");
if (colon != NULL && colon < slash) {
char *port_str = (char *) TSmalloc(sizeof(char) * (slash - colon));
@@ -702,7 +698,7 @@ attach_pvc_plugin(TSCont contp, TSEvent event, void *edata)
}
if (!TSHttpTxnClientReqGet(txnp, &req_bufp, &req_loc)) {
- LOG_ERROR("Error while retrieving client request header");
+ TSLogError("Error while retrieving client request header");
break;
}
@@ -721,12 +717,12 @@ attach_pvc_plugin(TSCont contp, TSEvent event, void *edata)
//TSHandleStringRelease(req_bufp, req_loc, method);
- TSDebug(DEBUG_TAG, "Got POST req");
+ TSLogDebug("Got POST req");
if (uconfig->url_list_file != NULL) {
- TSDebug(DEBUG_TAG, "url_list_file != NULL");
+ TSLogDebug("url_list_file != NULL");
// check against URL list
if (TSHttpHdrUrlGet(req_bufp, req_loc, &url_loc) == TS_ERROR) {
- LOG_ERROR("Couldn't get the url");
+ TSLogError("Couldn't get the URL");
}
str = TSUrlHostGet(req_bufp, url_loc, &str_len);
if (NOT_VALID_PTR(str) || str_len <= 0) {
@@ -735,7 +731,7 @@ attach_pvc_plugin(TSCont contp, TSEvent event, void *edata)
if (NOT_VALID_PTR(field_loc)) {
//if (VALID_PTR(str))
// TSHandleStringRelease(req_bufp, url_loc, str);
- LOG_ERROR("Host field not found.");
+ TSLogError("Host field not found.");
TSHandleMLocRelease(req_bufp, req_loc, url_loc);
TSHandleMLocRelease(req_bufp, TS_NULL_MLOC, req_loc);
break;
@@ -753,7 +749,7 @@ attach_pvc_plugin(TSCont contp, TSEvent event, void *edata)
char replacement_host_str[str_len + 1];
memset(replacement_host_str, 0, sizeof replacement_host_str);
memcpy(replacement_host_str, str, str_len);
- TSDebug(DEBUG_TAG, "Adding host to request url: %s", replacement_host_str);
+ TSLogDebug("Adding host to request url: %s", replacement_host_str);
TSUrlHostSet(req_bufp, url_loc, str, str_len);
@@ -769,10 +765,10 @@ attach_pvc_plugin(TSCont contp, TSEvent event, void *edata)
char urlStr[url_len + 1];
memset(urlStr, 0, sizeof urlStr);
memcpy(urlStr, url, url_len);
- TSDebug(DEBUG_TAG, "Request url: %s", urlStr);
+ TSLogDebug("Request url: %s", urlStr);
for (i = 0; i < uconfig->url_num; i++) {
- TSDebug(DEBUG_TAG, "uconfig url: %s", uconfig->urls[i]);
+ TSLogDebug("uconfig url: %s", uconfig->urls[i]);
if (strncmp(url, uconfig->urls[i], url_len) == 0) {
break;
}
@@ -783,21 +779,21 @@ attach_pvc_plugin(TSCont contp, TSEvent event, void *edata)
TSHandleMLocRelease(req_bufp, req_loc, url_loc);
if (uconfig->url_num > 0 && i == uconfig->url_num) {
- TSDebug(DEBUG_TAG, "breaking: url_num > 0 and i== url_num, URL match not found");
+ TSLogDebug("breaking: url_num > 0 and i== url_num, URL match not found");
TSHandleMLocRelease(req_bufp, TS_NULL_MLOC, req_loc);
break;
}
}
if (uconfig->convert_url) {
- TSDebug(DEBUG_TAG, "doing convert url");
+ TSLogDebug("doing convert url");
convert_url_func(req_bufp, req_loc);
}
if ((field_loc = TSMimeHdrFieldFind(req_bufp, req_loc, TS_MIME_FIELD_CONTENT_LENGTH, TS_MIME_LEN_CONTENT_LENGTH)) ||
field_loc == NULL) {
TSHandleMLocRelease(req_bufp, TS_NULL_MLOC, req_loc);
- LOG_ERROR("TSMimeHdrFieldRetrieve");
+ TSLogError("TSMimeHdrFieldRetrieve");
break;
}
@@ -805,7 +801,7 @@ attach_pvc_plugin(TSCont contp, TSEvent event, void *edata)
/*{
TSHandleMLocRelease(req_bufp, req_loc, field_loc);
TSHandleMLocRelease(req_bufp, TS_NULL_MLOC, req_loc);
- LOG_ERROR("TSMimeFieldValueGet");
+ TSLogError("TSMimeFieldValueGet");
} else
*/
// content_length = value;
@@ -814,7 +810,7 @@ attach_pvc_plugin(TSCont contp, TSEvent event, void *edata)
if (NOT_VALID_PTR(mutex)) {
TSHandleMLocRelease(req_bufp, req_loc, field_loc);
TSHandleMLocRelease(req_bufp, TS_NULL_MLOC, req_loc);
- LOG_ERROR("TSMutexCreate");
+ TSLogError("TSMutexCreate");
break;
}
@@ -822,7 +818,7 @@ attach_pvc_plugin(TSCont contp, TSEvent event, void *edata)
if (NOT_VALID_PTR(new_cont)) {
TSHandleMLocRelease(req_bufp, req_loc, field_loc);
TSHandleMLocRelease(req_bufp, TS_NULL_MLOC, req_loc);
- LOG_ERROR("TSContCreate");
+ TSLogError("TSContCreate");
break;
}
@@ -860,7 +856,7 @@ attach_pvc_plugin(TSCont contp, TSEvent event, void *edata)
my_state->disk_io_mutex = TSMutexCreate();
if (NOT_VALID_PTR(my_state->disk_io_mutex)) {
- LOG_ERROR("TSMutexCreate");
+ TSLogError("TSMutexCreate");
}
my_state->req_hdr_buffer = TSIOBufferCreate();
@@ -874,8 +870,7 @@ attach_pvc_plugin(TSCont contp, TSEvent event, void *edata)
TSStatIntIncrement(upload_vc_count, 1);
if (!uconfig->use_disk_buffer && my_state->req_size > uconfig->mem_buffer_size) {
- TSDebug(DEBUG_TAG,
- "The request size %lu is larger than memory buffer size %lu, bypass upload proxy feature for this request.",
+ TSLogDebug("The request size %lu is larger than memory buffer size %lu, bypass upload proxy feature for this request.",
my_state->req_size, uconfig->mem_buffer_size);
pvc_cleanup(new_cont, my_state);
@@ -904,18 +899,18 @@ attach_pvc_plugin(TSCont contp, TSEvent event, void *edata)
*/
my_state->filename = tempnam(path, NULL);
- TSDebug(DEBUG_TAG, "temp filename: %s", my_state->filename);
+ TSLogDebug("temp filename: %s", my_state->filename);
my_state->fd = open(my_state->filename, O_RDWR | O_NONBLOCK | O_TRUNC | O_CREAT);
if (my_state->fd < 0) {
- LOG_ERROR("open");
+ TSLogError("open");
uconfig->use_disk_buffer = 0;
my_state->fd = -1;
}
}
- TSDebug(DEBUG_TAG, "calling TSHttpTxnIntercept() ...");
+ TSLogDebug("calling TSHttpTxnIntercept() ...");
TSHttpTxnIntercept(new_cont, txnp);
break;
@@ -939,26 +934,26 @@ create_directory()
struct passwd *pwd;
if (getcwd(cwd, 4096) == NULL) {
- TSError("getcwd fails");
+ TSLogError("getcwd fails");
return 0;
}
if ((pwd = getpwnam("nobody")) == NULL) {
- TSError("can't get passwd entry for \"nobody\"");
+ TSLogError("can't get passwd entry for \"nobody\"");
goto error_out;
}
if (chdir(uconfig->base_dir) < 0) {
if (mkdir(uconfig->base_dir, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
- TSError("Unable to enter or create %s", uconfig->base_dir);
+ TSLogError("Unable to enter or create %s", uconfig->base_dir);
goto error_out;
}
if (chown(uconfig->base_dir, pwd->pw_uid, pwd->pw_gid) < 0) {
- TSError("Unable to chown %s", uconfig->base_dir);
+ TSLogError("Unable to chown %s", uconfig->base_dir);
goto error_out;
}
if (chdir(uconfig->base_dir) < 0) {
- TSError("Unable enter %s", uconfig->base_dir);
+ TSLogError("Unable enter %s", uconfig->base_dir);
goto error_out;
}
}
@@ -966,15 +961,15 @@ create_directory()
snprintf(str, 10, "%02X", i);
if (chdir(str) < 0) {
if (mkdir(str, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
- TSError("Unable to enter or create %s/%s", uconfig->base_dir, str);
+ TSLogError("Unable to enter or create %s/%s", uconfig->base_dir, str);
goto error_out;
}
if (chown(str, pwd->pw_uid, pwd->pw_gid) < 0) {
- TSError("Unable to chown %s", str);
+ TSLogError("Unable to chown %s", str);
goto error_out;
}
if (chdir(str) < 0) {
- TSError("Unable to enter %s/%s", uconfig->base_dir, str);
+ TSLogError("Unable to enter %s/%s", uconfig->base_dir, str);
goto error_out;
}
}
@@ -1012,7 +1007,7 @@ load_urls(char *filename)
for (i = 0; i < 2; i++) {
if ((file = TSfopen(filename, "r")) == NULL) {
TSfree(url_buf);
- TSError("Fail to open %s", filename);
+ TSLogError("Fail to open %s", filename);
return;
}
if (i == 0) { //first round
@@ -1062,8 +1057,7 @@ parse_config_line(char *line, const struct config_val_ul *cv)
int iv = strtol(tok, &end, 10);
if (end && *end == '\0') {
*((int *) cv->val) = iv;
- TSError("Parsed int config value %s : %d", cv->str, iv);
- TSDebug(DEBUG_TAG, "Parsed int config value %s : %d", cv->str, iv);
+ TSLogError("Parsed int config value %s : %d", cv->str, iv);
}
break;
}
@@ -1072,8 +1066,7 @@ parse_config_line(char *line, const struct config_val_ul *cv)
unsigned int uiv = strtoul(tok, &end, 10);
if (end && *end == '\0') {
*((unsigned int *) cv->val) = uiv;
- TSError("Parsed uint config value %s : %u", cv->str, uiv);
- TSDebug(DEBUG_TAG, "Parsed uint config value %s : %u", cv->str, uiv);
+ TSLogError("Parsed uint config value %s : %u", cv->str, uiv);
}
break;
}
@@ -1082,8 +1075,7 @@ parse_config_line(char *line, const struct config_val_ul *cv)
long lv = strtol(tok, &end, 10);
if (end && *end == '\0') {
*((long *) cv->val) = lv;
- TSError("Parsed long config value %s : %ld", cv->str, lv);
- TSDebug(DEBUG_TAG, "Parsed long config value %s : %ld", cv->str, lv);
+ TSLogError("Parsed long config value %s : %ld", cv->str, lv);
}
break;
}
@@ -1092,8 +1084,7 @@ parse_config_line(char *line, const struct config_val_ul *cv)
unsigned long ulv = strtoul(tok, &end, 10);
if (end && *end == '\0') {
*((unsigned long *) cv->val) = ulv;
- TSError("Parsed ulong config value %s : %lu", cv->str, ulv);
- TSDebug(DEBUG_TAG, "Parsed ulong config value %s : %lu", cv->str, ulv);
+ TSLogError("Parsed ulong config value %s : %lu", cv->str, ulv);
}
break;
}
@@ -1102,8 +1093,7 @@ parse_config_line(char *line, const struct config_val_ul *cv)
if (len > 0) {
*((char **) cv->val) = (char *) TSmalloc(len + 1);
strcpy(*((char **) cv->val), tok);
- TSError("Parsed string config value %s : %s", cv->str, tok);
- TSDebug(DEBUG_TAG, "Parsed string config value %s : %s", cv->str, tok);
+ TSLogError("Parsed string config value %s : %s", cv->str, tok);
}
break;
}
@@ -1114,8 +1104,7 @@ parse_config_line(char *line, const struct config_val_ul *cv)
*((bool *) cv->val) = true;
else
*((bool *) cv->val) = false;
- TSError("Parsed bool config value %s : %d", cv->str, *((bool *) cv->val));
- TSDebug(DEBUG_TAG, "Parsed bool config value %s : %d", cv->str, *((bool *) cv->val));
+ TSLogError("Parsed bool config value %s : %d", cv->str, *((bool *) cv->val));
}
break;
}
@@ -1132,7 +1121,7 @@ parse_config_line(char *line, const struct config_val_ul *cv)
bool
read_upload_config(const char *file_name)
{
- TSDebug(DEBUG_TAG, "read_upload_config: %s", file_name);
+ TSLogDebug("config file: %s", file_name);
uconfig = (upload_config *) TSmalloc(sizeof(upload_config));
uconfig->use_disk_buffer = true;
uconfig->convert_url = false;
@@ -1162,7 +1151,7 @@ read_upload_config(const char *file_name)
conf_file = TSfopen(file_name, "r");
if (conf_file != NULL) {
- TSDebug(DEBUG_TAG, "opened config: %s", file_name);
+ TSLogDebug("opened config: %s", file_name);
char buf[1024];
while (TSfgets(conf_file, buf, sizeof(buf) - 1) != NULL) {
if (buf[0] != '#') {
@@ -1171,7 +1160,7 @@ read_upload_config(const char *file_name)
}
TSfclose(conf_file);
} else {
- TSError("Failed to open upload config file %s", file_name);
+ TSLogError("Failed to open upload config file %s", file_name);
// if fail to open config file, use the default config
}
@@ -1213,21 +1202,21 @@ TSPluginInit(int argc, const char *argv[])
if (!read_upload_config(conf_filename) || !uconfig) {
if (argc > 1) {
- TSError("Failed to read upload config %s\n", argv[1]);
+ TSLogError("Failed to read upload config %s\n", argv[1]);
} else {
- TSError("No config file specified. Specify conf file in plugin.conf: "
+ TSLogError("No config file specified. Specify conf file in plugin.conf: "
"'buffer_upload.so /path/to/upload.conf'\n");
}
}
// set the num of threads for disk AIO
if (TSAIOThreadNumSet(uconfig->thread_num) == TS_ERROR) {
- TSError("Failed to set thread number.");
+ TSLogError("Failed to set thread number.");
}
- TSDebug(DEBUG_TAG, "uconfig->url_list_file: %s", uconfig->url_list_file);
+ TSLogDebug("uconfig->url_list_file: %s", uconfig->url_list_file);
if (uconfig->url_list_file) {
load_urls(uconfig->url_list_file);
- TSDebug(DEBUG_TAG, "loaded uconfig->url_list_file, num urls: %d", uconfig->url_num);
+ TSLogDebug("loaded uconfig->url_list_file, num urls: %d", uconfig->url_num);
}
info.plugin_name = const_cast<char*>("buffer_upload");
@@ -1235,12 +1224,12 @@ TSPluginInit(int argc, const char *argv[])
info.support_email = const_cast<char*>("");
if (uconfig->use_disk_buffer && !create_directory()) {
- TSError("Directory creation failed.");
+ TSLogError("Directory creation failed.");
uconfig->use_disk_buffer = 0;
}
if (TSPluginRegister(TS_SDK_VERSION_2_0, &info) != TS_SUCCESS) {
- TSError("Plugin registration failed.");
+ TSLogError("Plugin registration failed.");
}
/* create the statistic variables */