trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iga...@apache.org
Subject [5/5] git commit: TS-2106: transform all plugins to new logging non-API
Date Sun, 11 Aug 2013 18:31:23 GMT
TS-2106: transform all plugins to new logging non-API

some of the experimental plugins are not finished because the libraries
are deep, and not widely used (by me). And then there's the odd one
that doesn't even compile yet..


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/42306ff7
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/42306ff7
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/42306ff7

Branch: refs/heads/consistent-errors
Commit: 42306ff72404129bec73cfe0900a2c5eb98ce920
Parents: 7facd11
Author: Igor Galić <i.galic@brainsware.org>
Authored: Thu Aug 8 18:05:36 2013 +0200
Committer: Igor Galić <i.galic@brainsware.org>
Committed: Sun Aug 11 20:14:25 2013 +0200

----------------------------------------------------------------------
 plugins/cacheurl/cacheurl.c                     |  66 +++----
 plugins/conf_remap/conf_remap.cc                |  26 +--
 plugins/experimental/authproxy/authproxy.cc     |  42 ++---
 plugins/experimental/authproxy/utils.cc         |   8 +-
 plugins/experimental/authproxy/utils.h          |   4 +-
 plugins/experimental/balancer/balancer.cc       |  48 ++---
 plugins/experimental/balancer/resources.h       |   9 +-
 .../experimental/buffer_upload/buffer_upload.cc | 171 ++++++++---------
 .../experimental/channel_stats/channel_stats.cc | 102 +++++-----
 .../experimental/channel_stats/debug_macros.h   |  36 +---
 .../custom_redirect/custom_redirect.cc          |  17 +-
 plugins/experimental/esi/combo_handler.cc       | 167 ++++++++---------
 plugins/experimental/esi/esi.cc                 | 151 ++++++++-------
 plugins/experimental/geoip_acl/acl.cc           |  24 +--
 plugins/experimental/geoip_acl/geoip_acl.cc     |  10 +-
 plugins/experimental/geoip_acl/lulu.h           |   3 +-
 .../experimental/healthchecks/healthchecks.c    |  37 ++--
 plugins/experimental/metalink/metalink.cc       |  11 +-
 plugins/experimental/rfc5861/rfc5861.c          | 186 ++++++++++---------
 plugins/experimental/spdy/lib/base/logging.h    |  16 +-
 plugins/experimental/spdy/spdy.cc               |  28 +--
 plugins/experimental/spdy/stream.cc             |   2 +-
 plugins/experimental/tcp_info/tcp_info.cc       |  45 ++---
 plugins/header_filter/header_filter.cc          |  17 +-
 plugins/header_filter/lulu.h                    |   4 +-
 plugins/header_filter/rules.cc                  |  24 +--
 plugins/header_filter/rules.h                   |   8 +-
 plugins/header_rewrite/condition.cc             |   2 +-
 plugins/header_rewrite/condition.h              |   2 +-
 plugins/header_rewrite/conditions.cc            |  40 ++--
 plugins/header_rewrite/conditions.h             |  24 +--
 plugins/header_rewrite/factory.cc               |   4 +-
 plugins/header_rewrite/header_rewrite.cc        |  40 ++--
 plugins/header_rewrite/lulu.h                   |   4 +-
 plugins/header_rewrite/matcher.h                |  10 +-
 plugins/header_rewrite/operator.h               |   2 +-
 plugins/header_rewrite/operators.cc             |  52 +++---
 plugins/header_rewrite/operators.h              |  16 +-
 plugins/header_rewrite/parser.cc                |   6 +-
 plugins/header_rewrite/resources.cc             |  24 +--
 plugins/header_rewrite/resources.h              |   6 +-
 plugins/header_rewrite/ruleset.cc               |   8 +-
 plugins/header_rewrite/statement.h              |   4 +-
 plugins/header_rewrite/value.h                  |   2 +-
 plugins/libloader/libloader.c                   |   9 +-
 plugins/regex_remap/regex_remap.cc              |  58 +++---
 plugins/stats_over_http/stats_over_http.c       |  31 ++--
 47 files changed, 770 insertions(+), 836 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/cacheurl/cacheurl.c
----------------------------------------------------------------------
diff --git a/plugins/cacheurl/cacheurl.c b/plugins/cacheurl/cacheurl.c
index 7b28d7d..db165d5 100644
--- a/plugins/cacheurl/cacheurl.c
+++ b/plugins/cacheurl/cacheurl.c
@@ -42,6 +42,8 @@
 #define PATTERNCOUNT 30
 #define PLUGIN_NAME "cacheurl"
 
+#include "ts/debug.h"
+
 typedef struct {
     pcre *re;       /* Compiled regular expression */
     int tokcount;   /* Token count */
@@ -76,7 +78,7 @@ static int regex_substitute(char **buf, char *str, regex_info *info) {
             case PCRE_ERROR_NOMATCH:
                 break;
             default:
-                TSError("[%s] Matching error: %d\n", PLUGIN_NAME, matchcount);
+                TSLogError("Matching error: %d", matchcount);
                 break;
         }
         return 0;
@@ -85,7 +87,7 @@ static int regex_substitute(char **buf, char *str, regex_info *info) {
     /* Verify the replacement has the right number of matching groups */
     for (i=0; i<info->tokcount; i++) {
         if (info->tokens[i] >= matchcount) {
-            TSError("[%s] Invalid reference int replacement: $%d\n", PLUGIN_NAME, info->tokens[i]);
+            TSLogError("Invalid reference int replacement: $%d", info->tokens[i]);
             return 0;
         }
     }
@@ -138,8 +140,7 @@ static int regex_compile(regex_info **buf, char *pattern, char *replacement) {
     /* Precompile the regular expression */
     info->re =  pcre_compile(pattern, 0, &reerror, &reerroffset, NULL);
     if (!info->re) {
-        TSError("[%s] Compilation of regex '%s' failed at char %d: %s\n",
-                PLUGIN_NAME, pattern, reerroffset, reerror);
+        TSLogError("Compilation of regex '%s' failed at char %d: %s", pattern, reerroffset, reerror);
         status = 0;
     }
 
@@ -151,14 +152,11 @@ static int regex_compile(regex_info **buf, char *pattern, char *replacement) {
         for (i=0; i<strlen(replacement); i++) {
             if (replacement[i] == '$') {
                 if (tokcount >= TOKENCOUNT) {
-                    TSError("[%s] Error: too many tokens in replacement "
-                            "string: %s\n", PLUGIN_NAME, replacement);
+                    TSLogError("Too many tokens in replacement string: %s", replacement);
                     status = 0;
                     break;
                 } else if (replacement[i+1] < '0' || replacement[i+1] > '9') {
-                    TSError("[%s] Error: Invalid replacement token $%c in "
-                            "%s: should be $0 - $9\n", PLUGIN_NAME,
-                            replacement[i+1], replacement);
+                    TSLogError("Invalid replacement token $%c in %s: should be $0 - $9", replacement[i+1], replacement);
                     status = 0;
                     break;
                 } else {
@@ -212,12 +210,11 @@ static pr_list* load_config_file(const char *config_file) {
         sprintf(default_config_file, "%s/cacheurl.config", TSPluginDirGet());
         config_file = (const char *)default_config_file;
     }
-    TSDebug(PLUGIN_NAME, "Opening config file: %s", config_file);
+    TSLogDebug("Opening config file: %s", config_file);
     fh = TSfopen(config_file, "r");
 
     if (!fh) {
-        TSError("[%s] Unable to open %s. No patterns will be loaded\n",
-                PLUGIN_NAME, config_file);
+        TSLogError("Unable to open %s. No patterns will be loaded", config_file);
         return prl;
     }
 
@@ -241,8 +238,7 @@ static pr_list* load_config_file(const char *config_file) {
             spstart = strstr(buffer, "\t");
         }
         if (!spstart) {
-            TSError("[%s] ERROR: Invalid format on line %d. Skipping\n",
-                    PLUGIN_NAME, lineno);
+            TSLogError("Invalid format on line %d. Skipping", lineno);
             continue;
         }
         /* Find part of the line after any whitespace */
@@ -252,8 +248,7 @@ static pr_list* load_config_file(const char *config_file) {
         }
         if (*spend == 0) {
             /* We reached the end of the string without any non-whitepace */
-            TSError("[%s] ERROR: Invalid format on line %d. Skipping\n",
-                    PLUGIN_NAME, lineno);
+            TSLogError("Invalid format on line %d. Skipping", lineno);
             continue;
         }
 
@@ -262,21 +257,16 @@ static pr_list* load_config_file(const char *config_file) {
          * buffer is the first part of the line. spend is the second part just
          * after the whitespace */
         if (log) {
-            TSTextLogObjectWrite(log,
-                    "Adding pattern/replacement pair: '%s' -> '%s'",
-                    buffer, spend);
+            TSTextLogObjectWrite(log, "Adding pattern/replacement pair: '%s' -> '%s'", buffer, spend);
         }
-        TSDebug(PLUGIN_NAME, "Adding pattern/replacement pair: '%s' -> '%s'\n",
-                buffer, spend);
+        TSDebug("Adding pattern/replacement pair: '%s' -> '%s'\n", buffer, spend);
         retval = regex_compile(&info, buffer, spend);
         if (!retval) {
-            TSError("[%s] Error precompiling regex/replacement. Skipping.\n",
-                    PLUGIN_NAME);
+            TSLogError("Unable to precompile regex/replacement. Skipping.");
         }
         // TODO - remove patterncount and make pr_list infinite (linked list)
         if (prl->patterncount >= PATTERNCOUNT) {
-            TSError("[%s] Warning, too many patterns - skipping the rest"
-                    "(max: %d)\n", PLUGIN_NAME, PATTERNCOUNT);
+            TSLogWarning("Too many patterns - skipping the rest (max: %d)", PATTERNCOUNT);
             TSfree(info);
             break;
         }
@@ -302,8 +292,7 @@ static int rewrite_cacheurl(pr_list *prl, TSHttpTxn txnp) {
     if (ok) {
         url = TSHttpTxnEffectiveUrlStringGet(txnp, &url_length);
         if (!url) {
-            TSError("[%s] couldn't retrieve request url\n",
-                    PLUGIN_NAME);
+            TSLogError("Could not retrieve request URL");
             ok = 0;
         }
     }
@@ -320,16 +309,11 @@ static int rewrite_cacheurl(pr_list *prl, TSHttpTxn txnp) {
         }
         if (newurl) {
             if (log) {
-                TSTextLogObjectWrite(log,
-                        "Rewriting cache URL for %s to %s", url,
-                        newurl);
+                TSTextLogObjectWrite(log, "Rewriting cache URL for %s to %s", url, newurl);
             }
-            TSDebug(PLUGIN_NAME, "Rewriting cache URL for %s to %s\n",
-                    url, newurl);
-            if (TSCacheUrlSet(txnp, newurl, strlen(newurl))
-                    != TS_SUCCESS) {
-                TSError("[%s] Unable to modify cache url from "
-                        "%s to %s\n", PLUGIN_NAME, url, newurl);
+            TSLogDebug("Rewriting cache URL for %s to %s", url, newurl);
+            if (TS_SUCCESS != TSCacheUrlSet(txnp, newurl, strlen(newurl)) ) {
+                TSLogError("Unable to modify cache URL from %s to %s", url, newurl);
                 ok = 0;
             }
         }
@@ -363,8 +347,8 @@ static int handle_hook(TSCont contp, TSEvent event, void *edata) {
 
 /* Generic error message function for errors in plugin initialization */
 static void initialization_error(char *msg) {
-    TSError("[%s] %s\n", PLUGIN_NAME, msg);
-    TSError("[%s] Unable to initialize plugin (disabled).\n", PLUGIN_NAME);
+    TSLogError("%s", msg);
+    TSLogError("Unable to initialize plugin (disabled).");
 }
 
 TSReturnCode TSRemapInit(TSRemapInterface *api_info, char *errbuf,
@@ -401,7 +385,7 @@ TSReturnCode TSRemapInit(TSRemapInterface *api_info, char *errbuf,
         }
     }
 
-    TSDebug(PLUGIN_NAME, "remap plugin is successfully initialized");
+    TSLogInfo("remap plugin is successfully initialized");
     return TS_SUCCESS;
 }
 
@@ -415,7 +399,7 @@ TSReturnCode TSRemapNewInstance(int argc, char* argv[], void** ih, char* errbuf
 
 void TSRemapDeleteInstance(void *ih) {
     // Clean up
-    TSDebug(PLUGIN_NAME, "Deleting remap instance");
+    TSLogDebug("Deleting remap instance");
     pr_list *prl = (pr_list *)ih;
     int i=0;
     while (prl->pr[i]) {
@@ -457,7 +441,7 @@ void TSPluginInit(int argc, const char *argv[]) {
         error = TSTextLogObjectCreate("cacheurl", TS_LOG_MODE_ADD_TIMESTAMP,
                 &log);
         if (!log || error == TS_ERROR) {
-            TSError("[%s] Error creating log file\n", PLUGIN_NAME);
+            TSLogError("Cannot create log file");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/conf_remap/conf_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/conf_remap/conf_remap.cc b/plugins/conf_remap/conf_remap.cc
index f2f8026..520af73 100644
--- a/plugins/conf_remap/conf_remap.cc
+++ b/plugins/conf_remap/conf_remap.cc
@@ -25,7 +25,9 @@
 #include <ctype.h>
 #include <stdlib.h>
 
-static const char* PLUGIN_NAME = "conf_remap";
+#define PLUGIN_NAME "conf_remap"
+#include <ts/debug.h>
+
 // This makes the plugin depend on the version of traffic server installed, but that's
 // OK, since this plugin is distributed only with the "core" (it's a core piece).
 #define MAX_OVERRIDABLE_CONFIGS TS_CONFIG_LAST_ENTRY
@@ -85,7 +87,7 @@ RemapConfigs::parse_file(const char* fn)
     return false;
 
   if (NULL == (file = TSfopen(fn, "r"))) {
-    TSError("conf_remap: could not open config file %s", fn);
+    TSLogError("Could not open config file %s", fn);
     return false;
   }
 
@@ -103,26 +105,26 @@ RemapConfigs::parse_file(const char* fn)
       continue;
 
     if (strncmp(tok, "CONFIG", 6)) {
-      TSError("conf_remap: file %s, line %d: non-CONFIG line encountered", fn, line_num);
+      TSLogError("File %s, line %d: non-CONFIG line encountered", fn, line_num);
       continue;
     }
 
     // Find the configuration name
     tok = strtok_r(NULL, " \t", &ln);
     if (TSHttpTxnConfigFind(tok, -1, &name, &expected_type) != TS_SUCCESS) {
-      TSError("conf_remap: file %s, line %d: no records.config name given", fn, line_num);
+      TSLogError("File %s, line %d: no records.config name given", fn, line_num);
       continue;
     }
     
     // Find the type (INT or STRING only)
     tok = strtok_r(NULL, " \t", &ln);
     if (TS_RECORDDATATYPE_NULL == (type = str_to_datatype(tok))) {
-      TSError("conf_remap: file %s, line %d: only INT and STRING types supported", fn, line_num);
+      TSLogError("File %s, line %d: only INT and STRING types supported", fn, line_num);
       continue;
     }
 
     if (type != expected_type) {
-      TSError("conf_remap: file %s, line %d: mismatch between provide data type, and expected type", fn, line_num);
+      TSLogError("File %s, line %d: mismatch between provide data type, and expected type", fn, line_num);
       continue;
     }
 
@@ -146,7 +148,7 @@ RemapConfigs::parse_file(const char* fn)
       tok = NULL;
     }
     if (!tok) {
-      TSError("conf_remap: file %s, line %d: the configuration must provide a value", fn, line_num);
+      TSLogError("File %s, line %d: the configuration must provide a value", fn, line_num);
       continue;
     }
 
@@ -160,7 +162,7 @@ RemapConfigs::parse_file(const char* fn)
       _items[_current]._data_len = strlen(tok);
       break;
     default:
-      TSError("conf_remap: file %s, line %d: type not support (unheard of)", fn, line_num);
+      TSLogError("File %s, line %d: type not support (unheard of)", fn, line_num);
       continue;
       break;
     }
@@ -190,7 +192,7 @@ TSRemapInit(TSRemapInterface* api_info, char *errbuf, int errbuf_size)
     return TS_ERROR;
   }
 
-  TSDebug(PLUGIN_NAME, "remap plugin is successfully initialized");
+  TSLogInfo("remap plugin is successfully initialized");
   return TS_SUCCESS;                     /* success */
 }
 
@@ -199,7 +201,7 @@ TSReturnCode
 TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED */, int /* errbuf_size ATS_UNUSED */)
 {
   if (argc < 3) {
-    TSError("Unable to create remap instance, need configuration file");
+    TSLogError("Unable to create remap instance, need configuration file");
     return TS_ERROR;
   } else {
     RemapConfigs* conf = new(RemapConfigs);
@@ -243,11 +245,11 @@ TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo * /* rri ATS_UNUSED */
       switch (conf->_items[ix]._type) {
       case TS_RECORDDATATYPE_INT:
         TSHttpTxnConfigIntSet(txnp, conf->_items[ix]._name, conf->_items[ix]._data.rec_int);
-        TSDebug(PLUGIN_NAME, "Setting config id %d to %" PRId64"", conf->_items[ix]._name, conf->_items[ix]._data.rec_int);
+        TSLogDebug("Setting config id %d to %" PRId64"", conf->_items[ix]._name, conf->_items[ix]._data.rec_int);
         break;
       case TS_RECORDDATATYPE_STRING:
         TSHttpTxnConfigStringSet(txnp, conf->_items[ix]._name, conf->_items[ix]._data.rec_string, conf->_items[ix]._data_len);
-        TSDebug(PLUGIN_NAME, "Setting config id %d to %s", conf->_items[ix]._name, conf->_items[ix]._data.rec_string);
+        TSLogDebug("Setting config id %d to %s", conf->_items[ix]._name, conf->_items[ix]._data.rec_string);
         break;
       default:
         break; // Error ?

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/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/42306ff7/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/42306ff7/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() {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/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/42306ff7/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;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/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 */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/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/42306ff7/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)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/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);
 }


Mime
View raw message