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/11 20:31:19 UTC

[1/5] git commit: TS-2106 steal "api" from gzip plugin

Updated Branches:
  refs/heads/consistent-errors [created] 42306ff72


TS-2106 steal "api" from gzip plugin

because we really, really like the logging API in gzip plugin because
it's very detailed.


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

Branch: refs/heads/consistent-errors
Commit: 7facd11d03870f8c19ecab955f1b8504021f1daf
Parents: aeea92c
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 15:58:43 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Sun Aug 11 20:13:03 2013 +0200

----------------------------------------------------------------------
 plugins/gzip/configuration.cc | 12 +++---
 plugins/gzip/debug_macros.h   | 28 +-------------
 plugins/gzip/gzip.cc          | 76 +++++++++++++++++++-------------------
 plugins/gzip/misc.cc          | 12 +++---
 proxy/api/ts/debug.h          | 71 +++++++++++++++++++++++++++++++++++
 proxy/api/ts/ts.h.in          |  1 +
 6 files changed, 124 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7facd11d/plugins/gzip/configuration.cc
----------------------------------------------------------------------
diff --git a/plugins/gzip/configuration.cc b/plugins/gzip/configuration.cc
index 5e69c5c..98fd91b 100644
--- a/plugins/gzip/configuration.cc
+++ b/plugins/gzip/configuration.cc
@@ -118,7 +118,7 @@ namespace Gzip {
 
     for (size_t i = 0; i < disallows_.size(); i++) {
       if ( fnmatch (disallows_[i].c_str(), surl.c_str(), 0) == 0 ) {
-        info("url [%s] disabled for compression, matched on pattern [%s]",
+        TSLogInfo("URL [%s] disabled for compression, matched on pattern [%s]",
             surl.c_str(), disallows_[i].c_str());
         return false;
       }
@@ -138,7 +138,7 @@ namespace Gzip {
         match_string++;//skip '!'
       }
       if ( fnmatch (match_string, scontent_type.c_str(), 0) == 0 ) {
-        info("compressible content type [%s], matched on pattern [%s]",
+        TSLogInfo("compressible content type [%s], matched on pattern [%s]",
             scontent_type.c_str(), compressible_content_types_[i].c_str());
         is_match = !exclude;
       }
@@ -169,7 +169,7 @@ namespace Gzip {
     }
 
     path = pathstring.c_str();
-    info("Parsing file \"%s\"", path);
+    TSLogInfo("Parsing file \"%s\"", path);
     std::ifstream f;
 
     size_t lineno = 0;
@@ -177,7 +177,7 @@ namespace Gzip {
     f.open(path, std::ios::in);
 
     if (!f.is_open()) {
-      warning("could not open file [%s], skip",path);
+      TSLogWarning("could not open file [%s], skip",path);
       return c;
     }
 
@@ -223,7 +223,7 @@ namespace Gzip {
             state = kParseDisallow;
           }
           else {
-            warning("failed to interpret \"%s\" at line %zu", token.c_str(), lineno);
+            TSLogWarning("failed to interpret \"%s\" at line %zu", token.c_str(), lineno);
           }
           break;
         case kParseCompressibleContentType:
@@ -251,7 +251,7 @@ namespace Gzip {
     }
 
     if (state != kParseStart) {
-      warning("the parser state indicates that data was expected when it reached the end of the file (%d)", state);
+      TSLogWarning("the parser state indicates that data was expected when it reached the end of the file (%d)", state);
     }
 
     return c;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7facd11d/plugins/gzip/debug_macros.h
----------------------------------------------------------------------
diff --git a/plugins/gzip/debug_macros.h b/plugins/gzip/debug_macros.h
index 151de31..084c788 100644
--- a/plugins/gzip/debug_macros.h
+++ b/plugins/gzip/debug_macros.h
@@ -24,32 +24,8 @@
 #ifndef _DBG_MACROS_H
 #define _DBG_MACROS_H
 
-#include <ts/ts.h>
-
-#define TAG "gzip"
-
-#define debug(fmt, args...) do {                                    \
-  TSDebug(TAG, "DEBUG: [%s:%d] [%s] " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
-  } while (0)
-
-#define info(fmt, args...) do {                                    \
-  TSDebug(TAG, "INFO: " fmt, ##args ); \
-  } while (0)
-
-#define warning(fmt, args...) do {                                    \
-  TSDebug(TAG, "WARNING: " fmt, ##args ); \
-} while (0)
-
-#define error(fmt, args...) do {                                    \
-  TSError("[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
-  TSDebug(TAG, "[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
-} while (0)
-
-#define fatal(fmt, args...) do {                                    \
-  TSError("[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
-  TSDebug(TAG, "[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
-  exit(-1); \
-} while (0)
+#define PLUGIN_NAME "gzip"
+#include <ts/debug.h>
 
 //FIXME: this one doesn't deserve to be here
 #define DISALLOW_COPY_AND_ASSIGN(TypeName) \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7facd11d/plugins/gzip/gzip.cc
----------------------------------------------------------------------
diff --git a/plugins/gzip/gzip.cc b/plugins/gzip/gzip.cc
index 9c84dc8..c0d0c28 100644
--- a/plugins/gzip/gzip.cc
+++ b/plugins/gzip/gzip.cc
@@ -87,13 +87,13 @@ gzip_data_alloc(int compression_type)
   err = deflateInit2(&data->zstrm, ZLIB_COMPRESSION_LEVEL, Z_DEFLATED, window_bits, ZLIB_MEMLEVEL, Z_DEFAULT_STRATEGY);
 
   if (err != Z_OK) {
-    fatal("gzip-transform: ERROR: deflateInit (%d)!", err);
+    TSLogFatal("gzip-transform: deflateInit (%d)!", err);
   }
 
   if (dictionary) {
     err = deflateSetDictionary(&data->zstrm, (const Bytef *) dictionary, strlen(dictionary));
     if (err != Z_OK) {
-      fatal("gzip-transform: ERROR: deflateSetDictionary (%d)!", err);
+      TSLogFatal("gzip-transform: deflateSetDictionary (%d)!", err);
     }
   }
 
@@ -138,7 +138,7 @@ gzip_content_encoding_header(TSMBuffer bufp, TSMLoc hdr_loc, const int compressi
   }
 
   if (ret != TS_SUCCESS) {
-    error("cannot add the Content-Encoding header");
+    TSLogError("cannot add the Content-Encoding header");
   }
 
   return ret;
@@ -179,7 +179,7 @@ gzip_vary_header(TSMBuffer bufp, TSMLoc hdr_loc)
   }
 
   if (ret != TS_SUCCESS) {
-    error("cannot add/update the Vary header");
+    TSLogError("cannot add/update the Vary header");
   }
 
   return ret;
@@ -213,7 +213,7 @@ gzip_etag_header(TSMBuffer bufp, TSMLoc hdr_loc)
   }
 
   if (ret != TS_SUCCESS) {
-    error("cannot handle the %s header", TS_MIME_FIELD_ETAG);
+    TSLogError("cannot handle the %s header", TS_MIME_FIELD_ETAG);
   }
 
   return ret;
@@ -233,7 +233,7 @@ gzip_transform_init(TSCont contp, GzipData * data)
   data->state = transform_state_output;
 
   if (TSHttpTxnTransformRespGet(data->txn, &bufp, &hdr_loc) != TS_SUCCESS) {
-    error("Error TSHttpTxnTransformRespGet");
+    TSLogError("TSHttpTxnTransformRespGet");
     return;
   }
 
@@ -263,13 +263,13 @@ gzip_transform_one(GzipData * data, TSIOBufferReader upstream_reader, int amount
   while (amount > 0) {
     downstream_blkp = TSIOBufferReaderStart(upstream_reader);
     if (!downstream_blkp) {
-      error("couldn't get from IOBufferBlock");
+      TSLogError("could not get from IOBufferBlock");
       return;
     }
 
     upstream_buffer = TSIOBufferBlockReadStart(downstream_blkp, upstream_reader, &upstream_length);
     if (!upstream_buffer) {
-      error("couldn't get from TSIOBufferBlockReadStart");
+      TSLogError("could not get from TSIOBufferBlockReadStart");
       return;
     }
 
@@ -290,7 +290,7 @@ gzip_transform_one(GzipData * data, TSIOBufferReader upstream_reader, int amount
       err = deflate(&data->zstrm, Z_NO_FLUSH);
 
       if (err != Z_OK)
-        warning("deflate() call failed: %d", err);
+        TSLogWarning("deflate() call failed: %d", err);
 
       if (downstream_length > data->zstrm.avail_out) {
         TSIOBufferProduce(data->downstream_buffer, downstream_length - data->zstrm.avail_out);
@@ -299,7 +299,7 @@ gzip_transform_one(GzipData * data, TSIOBufferReader upstream_reader, int amount
 
       if (data->zstrm.avail_out > 0) {
         if (data->zstrm.avail_in != 0) {
-          error("gzip-transform: ERROR: avail_in is (%d): should be 0", data->zstrm.avail_in);
+          TSLogError("gzip-transform: ERROR: avail_in is (%d): should be 0", data->zstrm.avail_in);
         }
       }
     }
@@ -339,13 +339,13 @@ gzip_transform_finish(GzipData * data)
       }
 
       if (err != Z_STREAM_END) {
-        warning("deflate should report Z_STREAM_END");
+        TSLogWarning("deflate should report Z_STREAM_END");
       }
       break;
     }
 
     if (data->downstream_length != (int64_t) (data->zstrm.total_out)) {
-      error("gzip-transform: ERROR: output lengths don't match (%d, %ld)", data->downstream_length,
+      TSLogError("gzip-transform: output lengths don't match (%d, %ld)", data->downstream_length,
             data->zstrm.total_out);
     }
 
@@ -427,7 +427,7 @@ gzip_transform(TSCont contp, TSEvent event, void * /* edata ATS_UNUSED */)
   } else {
     switch (event) {
     case TS_EVENT_ERROR:{
-        debug("gzip_transform: TS_EVENT_ERROR starts");
+        TSLogDebug("gzip_transform: TS_EVENT_ERROR starts");
         TSVIO upstream_vio = TSVConnWriteVIOGet(contp);
         TSContCall(TSVIOContGet(upstream_vio), TS_EVENT_ERROR, upstream_vio);
       }
@@ -442,7 +442,7 @@ gzip_transform(TSCont contp, TSEvent event, void * /* edata ATS_UNUSED */)
       gzip_transform_do(contp);
       break;
     default:
-      warning("unknown event [%d]", event);
+      TSLogWarning("unknown event [%d]", event);
       gzip_transform_do(contp);
       break;
     }
@@ -480,7 +480,7 @@ gzip_transformable(TSHttpTxn txnp, int server, HostConfiguration * host_configur
 
   //conservatively pick some statusses to compress
   if (!(resp_status == 200 || resp_status == 404 || resp_status == 500)) {
-    info("http response status [%d] is not compressible", resp_status);
+    TSLogInfo("http response status [%d] is not compressible", resp_status);
     return 0;
   }
 
@@ -490,7 +490,7 @@ gzip_transformable(TSHttpTxn txnp, int server, HostConfiguration * host_configur
   int method_length;
   const char *method = TSHttpHdrMethodGet(cbuf, chdr, &method_length);
   if (!(method_length == TS_HTTP_LEN_GET && memcmp(method, TS_HTTP_METHOD_GET, TS_HTTP_LEN_GET) == 0)) {
-    debug("method is not GET, not compressible");
+    TSLogDebug("method is not GET, not compressible");
     TSHandleMLocRelease(cbuf, TS_NULL_MLOC, chdr);
     return 0;
   }
@@ -520,11 +520,11 @@ gzip_transformable(TSHttpTxn txnp, int server, HostConfiguration * host_configur
     TSHandleMLocRelease(cbuf, TS_NULL_MLOC, chdr);
 
     if (!compression_acceptable) {
-      info("no acceptable encoding found in request header, not compressible");
+      TSLogInfo("no acceptable encoding found in request header, not compressible");
       return 0;
     }
   } else {
-    info("no acceptable encoding found in request header, not compressible");
+    TSLogInfo("no acceptable encoding found in request header, not compressible");
     TSHandleMLocRelease(cbuf, chdr, cfield);
     TSHandleMLocRelease(cbuf, TS_NULL_MLOC, chdr);
     return 0;
@@ -540,7 +540,7 @@ gzip_transformable(TSHttpTxn txnp, int server, HostConfiguration * host_configur
      to do anything. */
   field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, TS_MIME_FIELD_CONTENT_ENCODING, -1);
   if (field_loc) {
-    info("response is already content encoded, not compressible");
+    TSLogInfo("response is already content encoded, not compressible");
     TSHandleMLocRelease(bufp, hdr_loc, field_loc);
     TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     return 0;
@@ -550,7 +550,7 @@ gzip_transformable(TSHttpTxn txnp, int server, HostConfiguration * host_configur
      content type of "text/" or "application/x-javascript". */
   field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, TS_MIME_FIELD_CONTENT_TYPE, -1);
   if (!field_loc) {
-    info("no content type header found, not compressible");
+    TSLogInfo("no content type header found, not compressible");
     TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     return 0;
   }
@@ -559,7 +559,7 @@ gzip_transformable(TSHttpTxn txnp, int server, HostConfiguration * host_configur
 
   int rv = host_configuration->ContentTypeIsCompressible(value, len);
   if (!rv) { 
-    info("content-type [%.*s] not compressible", len, value);
+    TSLogInfo("content-type [%.*s] not compressible", len, value);
   }
   TSHandleMLocRelease(bufp, hdr_loc, field_loc);
   TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
@@ -573,11 +573,11 @@ gzip_transform_add(TSHttpTxn txnp, int /* server ATS_UNUSED */, HostConfiguratio
   int *tmp = (int *) TSHttpTxnArgGet(txnp, arg_idx_hooked);
   if (tmp) {
     //happens on cache_stale_hit
-    debug("transform hook already set, bail");
+    TSLogDebug("transform hook already set, bail");
     return;
   } else {
     TSHttpTxnArgSet(txnp, arg_idx_hooked, (void *) &GZIP_ONE);
-    info("adding compression transform");
+    TSLogInfo("adding compression transform");
   }
 
   TSHttpTxnUntransformedRespCache(txnp, 1);
@@ -605,15 +605,15 @@ cache_transformable(TSHttpTxn txnp)
   int obj_status;
 
   if (TSHttpTxnCacheLookupStatusGet(txnp, &obj_status) == TS_ERROR) {
-    warning("Couldn't get cache status of object");
+    TSLogWarning("Couldn't get cache status of object");
     return 0;
   }
   if (obj_status == TS_CACHE_LOOKUP_HIT_STALE) {
-    info("stale cache hit");
+    TSLogInfo("stale cache hit");
     return 0;
   }
   if (obj_status == TS_CACHE_LOOKUP_HIT_FRESH) {
-    info("fresh cache hit");
+    TSLogInfo("fresh cache hit");
     return 1;
   }
 
@@ -659,7 +659,7 @@ transform_plugin(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata)
           if (!hc->enabled() || !hc->IsUrlAllowed(url, url_len)) {
             //FIXME: no double negatives
             TSHttpTxnArgSet(txnp, arg_idx_url_disallowed, (void *) &GZIP_ONE);
-            info("url [%.*s] not allowed", url_len, url);
+            TSLogInfo("url [%.*s] not allowed", url_len, url);
           } else {
             normalize_accept_encoding(txnp, req_buf, req_loc);	
           }
@@ -725,7 +725,7 @@ transform_plugin(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata)
       break;
 
     default:
-      fatal("gzip transform unknown event");
+      TSLogFatal("gzip transform unknown event");
   }
 
   return 0;
@@ -738,7 +738,7 @@ read_configuration(TSCont contp) {
   Configuration * newconfig = Configuration::Parse(path);
 
   Configuration * oldconfig =__sync_lock_test_and_set(&config, newconfig);
-  debug("config swapped,old config %p", oldconfig);
+  TSLogDebug("config swapped,old config %p", oldconfig);
 
   //FIXME: we have leaked.
   //consider cloning or refcounting the configuration passed to the txn
@@ -751,7 +751,7 @@ static int
 management_update(TSCont contp, TSEvent event, void * /* edata ATS_UNUSED */)
 {
   TSReleaseAssert(event == TS_EVENT_MGMT_UPDATE);
-  info("management update event received");
+  TSLogInfo("management update event received");
   read_configuration(contp);
   return 0;
 }
@@ -763,15 +763,15 @@ TSPluginInit(int argc, const char *argv[])
   string config_path;
 
   if (argc > 2)  {
-    fatal("the gzip plugin does not accept more than 1 plugin argument");
+    TSLogFatal("the gzip plugin does not accept more than 1 plugin argument");
   } else if (argc == 2) { 
     config_path = std::string(argv[1]);
   }
 
-  info("TSPluginInit %s", argv[0]);
+  TSLogInfo("TSPluginInit %s", argv[0]);
 
   if (!register_plugin()) {
-    fatal("The gzip plugin failed to register");
+    TSLogFatal("The gzip plugin failed to register");
   }
 
   //if (argc == 2) {
@@ -779,13 +779,13 @@ TSPluginInit(int argc, const char *argv[])
   //}
 
   if (TSHttpArgIndexReserve("gzip", "for remembering if the hook was set", &arg_idx_hooked) != TS_SUCCESS) {
-    fatal("failed to reserve an argument index");
+    TSLogFatal("failed to reserve an argument index");
   }
   if (TSHttpArgIndexReserve("gzip", "for storing if compression is applicable", &arg_idx_host_configuration) != TS_SUCCESS) {
-    fatal("failed to reserve an argument index");
+    TSLogFatal("failed to reserve an argument index");
   }
   if (TSHttpArgIndexReserve("gzip", "for storing if compression is disallowed for this txn", &arg_idx_url_disallowed) != TS_SUCCESS) {
-    fatal("failed to reserve an argument index");
+    TSLogFatal("failed to reserve an argument index");
   }
 
   global_hidden_header_name = init_hidden_header_name();
@@ -795,7 +795,7 @@ TSPluginInit(int argc, const char *argv[])
   char * p = (char*)TSmalloc(config_path.size()+1);
   strcpy(p,config_path.c_str());
   TSContDataSet(management_contp,(void*)p);
-  TSMgmtUpdateRegister(management_contp, TAG);
+  TSMgmtUpdateRegister(management_contp, PLUGIN_NAME);
   read_configuration(management_contp);
 
   TSCont transform_contp = TSContCreate(transform_plugin, NULL);
@@ -804,5 +804,5 @@ TSPluginInit(int argc, const char *argv[])
   TSHttpHookAdd(TS_HTTP_SEND_REQUEST_HDR_HOOK, transform_contp);
   TSHttpHookAdd(TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, transform_contp);
 
-  info("loaded");
+  TSLogInfo("loaded");
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7facd11d/plugins/gzip/misc.cc
----------------------------------------------------------------------
diff --git a/plugins/gzip/misc.cc b/plugins/gzip/misc.cc
index 13f9d39..63b42a7 100644
--- a/plugins/gzip/misc.cc
+++ b/plugins/gzip/misc.cc
@@ -83,10 +83,10 @@ normalize_accept_encoding(TSHttpTxn /* txnp ATS_UNUSED */, TSMBuffer reqp, TSMLo
 
     if (gzip) {
       TSMimeHdrFieldValueStringInsert(reqp, hdr_loc, field, -1, "gzip", strlen("gzip"));
-      info("normalized accept encoding to gzip");
+      TSLogInfo("normalized accept encoding to gzip");
     } else if (deflate) {
       TSMimeHdrFieldValueStringInsert(reqp, hdr_loc, field, -1, "deflate", strlen("deflate"));
-      info("normalized accept encoding to deflate");
+      TSLogInfo("normalized accept encoding to deflate");
     }
 
     TSMimeHdrFieldAppend(reqp, hdr_loc, field);
@@ -129,7 +129,7 @@ init_hidden_header_name()
   TSMgmtString result;
 
   if (TSMgmtStringGet(var_name, &result) != TS_SUCCESS) {
-    fatal("failed to get server name");
+    TSLogFatal("failed to get server name");
   } else {
     int hidden_header_name_len = strlen("x-accept-encoding-") + strlen(result);
     hidden_header_name = (char *) TSmalloc(hidden_header_name_len + 1);
@@ -166,7 +166,7 @@ load_dictionary(const char *preload_file)
 
   fp = fopen(preload_file, "r");
   if (!fp) {
-    fatal("gzip-transform: ERROR: Unable to open dict file %s", preload_file);
+    TSLogFatal("gzip-transform: Unable to open dict file %s", preload_file);
   }
 
   /* dict = (char *) calloc(8000, sizeof(char)); */
@@ -190,8 +190,8 @@ void
 gzip_log_ratio(int64_t in, int64_t out)
 {
   if (in) {
-    info("Compressed size %" PRId64" (bytes), Original size %" PRId64", ratio: %f", out, in, ((float) (in - out) / in));
+    TSLogInfo("Compressed size %" PRId64" (bytes), Original size %" PRId64", ratio: %f", out, in, ((float) (in - out) / in));
   } else {
-    debug("Compressed size %" PRId64" (bytes), Original size %" PRId64", ratio: %f", out, in, 0.0F);
+    TSLogDebug("Compressed size %" PRId64" (bytes), Original size %" PRId64", ratio: %f", out, in, 0.0F);
   }
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7facd11d/proxy/api/ts/debug.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/debug.h b/proxy/api/ts/debug.h
new file mode 100644
index 0000000..7e0854e
--- /dev/null
+++ b/proxy/api/ts/debug.h
@@ -0,0 +1,71 @@
+/** @file
+
+  Traffic Server SDK API header file for debug messages
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+  @section developers Developers
+
+ */
+
+#ifndef __TS_DEBUG_H__
+#define __TS_DEBUG_H__
+
+#include <ts/ts.h>
+
+/** all of these APIs assume you've defined PLUGIN_NAME first before
+ *  including this header file.
+ *
+ *  These APIs are private, that is: They are not installed. They
+ *  can be used by in-tree plugins, external plugins will have to redefine this
+ *  or find their own way of logging, until ATS has unified it's plugin logging
+ *  in the same way it has unified the core-logging.
+ **/
+
+#ifndef PLUGIN_NAME
+# error "A plugin must define a PLUGIN_NAME string constant *before* including <ts/ts.h> in order to use TSLog(Debug|Info|Warning|Error|Fatal)"
+#else
+
+#define TSLogDebug(fmt, args...) do {                                    \
+  TSDebug(PLUGIN_NAME, "DEBUG: [%s:%d] [%s] " fmt, __FILE__, __LINE__, __func__ , ##args ); \
+  } while (0)
+
+#define TSLogInfo(fmt, args...) do {                                    \
+  TSDebug(PLUGIN_NAME, "INFO: " fmt, ##args ); \
+  } while (0)
+
+#define TSLogWarning(fmt, args...) do {                                    \
+  TSDebug(PLUGIN_NAME, "WARNING: " fmt, ##args ); \
+} while (0)
+
+#define TSLogError(fmt, args...) do {                                    \
+  TSError("[%s] [%s:%d] [%s] ERROR: " fmt, PLUGIN_NAME, __FILE__, __LINE__, __func__ , ##args ); \
+  TSDebug(PLUGIN_NAME, "[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __func__ , ##args ); \
+} while (0)
+#endif
+
+#define TSLogFatal(fmt, args...) do {                                    \
+  TSError("[%s] [%s:%d] [%s] FATAL: " fmt, PLUGIN_NAME, __FILE__, __LINE__, __func__ , ##args ); \
+  TSDebug(PLUGIN_NAME, "[%s:%d] [%s] FATAL: " fmt, __FILE__, __LINE__, __func__ , ##args ); \
+  exit(-1); \
+} while (0)
+
+
+# endif /* __TS_DEBUG_H__ */
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7facd11d/proxy/api/ts/ts.h.in
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h.in b/proxy/api/ts/ts.h.in
index 3379a26..7da91d7 100644
--- a/proxy/api/ts/ts.h.in
+++ b/proxy/api/ts/ts.h.in
@@ -1300,6 +1300,7 @@ extern "C"
   */
   tsapi void TSError(const char* fmt, ...) TS_PRINTFLIKE(1, 2);
 
+
   /* --------------------------------------------------------------------------
      Assertions */
   tsapi void _TSReleaseAssert(const char* txt, const char* f, int l) TS_NORETURN;


[4/5] TS-2106: transform all plugins to new logging non-API

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

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/experimental/geoip_acl/acl.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/geoip_acl/acl.cc b/plugins/experimental/geoip_acl/acl.cc
index 90bbe79..e0aaa00 100644
--- a/plugins/experimental/geoip_acl/acl.cc
+++ b/plugins/experimental/geoip_acl/acl.cc
@@ -37,9 +37,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);
   }
 }
 
@@ -71,7 +71,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"
@@ -81,7 +81,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;
       }
     }
@@ -102,11 +102,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;
   }
 
@@ -140,9 +140,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);
   }
 }
 
@@ -171,9 +171,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);
   }
 }
 
@@ -190,7 +190,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()));
@@ -212,7 +212,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);
       }
     }
     break;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/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 87e4d03..c3c9a41 100644
--- a/plugins/experimental/geoip_acl/geoip_acl.cc
+++ b/plugins/experimental/geoip_acl/geoip_acl.cc
@@ -50,7 +50,7 @@ TSRemapInit(TSRemapInterface* api_info, char *errbuf, int errbuf_size)
   //gGI = GeoIP_new(GEOIP_STANDARD); // This seems to break on threaded apps
   gGI = GeoIP_new(GEOIP_MMAP_CACHE);
 
-  TSDebug(PLUGIN_NAME, "remap plugin is successfully initialized");
+  TSLogDebug("remap plugin is successfully initialized");
   return TS_SUCCESS;                     /* success */
 }
 
@@ -59,13 +59,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();
     }
 
@@ -73,7 +73,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;
     }
   }
@@ -97,7 +97,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/42306ff7/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__
 

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

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


[2/5] TS-2106: transform all plugins to new logging non-API

Posted by ig...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/resources.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/resources.cc b/plugins/header_rewrite/resources.cc
index c33dfbf..41b1498 100644
--- a/plugins/header_rewrite/resources.cc
+++ b/plugins/header_rewrite/resources.cc
@@ -27,13 +27,13 @@
 void
 Resources::gather(const ResourceIDs ids, TSHttpHookID hook)
 {
-  TSDebug(PLUGIN_NAME, "Building resource structure for hook (%d)", hook);
+  TSLogDebug("Building resource structure for hook (%d)", hook);
 
   // If we need the client request headers, make sure it's also available in the client vars.
   if (ids & RSRC_CLIENT_REQUEST_HEADERS) {
-    TSDebug(PLUGIN_NAME, "\tAdding TXN client request header buffers");
+    TSLogDebug("\tAdding TXN client request header buffers");
     if (TSHttpTxnClientReqGet(txnp, &client_bufp, &client_hdr_loc) != TS_SUCCESS) {
-      TSDebug(PLUGIN_NAME, "could not gather bufp/hdr_loc for request");
+      TSLogDebug("could not gather bufp/hdr_loc for request");
       return;
     }
   }
@@ -42,14 +42,14 @@ Resources::gather(const ResourceIDs ids, TSHttpHookID hook)
   case TS_HTTP_READ_RESPONSE_HDR_HOOK:
     // Read response headers from server
     if (ids & RSRC_SERVER_RESPONSE_HEADERS) {
-      TSDebug(PLUGIN_NAME, "\tAdding TXN server response header buffers");
+      TSLogDebug("\tAdding TXN server response header buffers");
       if (TSHttpTxnServerRespGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
-        TSDebug(PLUGIN_NAME, "could not gather bufp/hdr_loc for response");
+        TSLogDebug("Could not gather bufp/hdr_loc for response");
         return;
       }
     }
     if (ids & RSRC_RESPONSE_STATUS) {
-      TSDebug(PLUGIN_NAME, "\tAdding TXN server response status resource");
+      TSLogDebug("\tAdding TXN server response status resource");
       resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
     }
     break;
@@ -57,9 +57,9 @@ Resources::gather(const ResourceIDs ids, TSHttpHookID hook)
   case TS_HTTP_SEND_REQUEST_HDR_HOOK:
     // Read request headers to server
     if (ids & RSRC_SERVER_REQUEST_HEADERS) {
-      TSDebug(PLUGIN_NAME, "\tAdding TXN server request header buffers");
+      TSLogDebug("\tAdding TXN server request header buffers");
       if (!TSHttpTxnServerReqGet(txnp, &bufp, &hdr_loc)) {
-        TSDebug(PLUGIN_NAME, "could not gather bufp/hdr_loc for request");
+        TSLogDebug("Could not gather bufp/hdr_loc for request");
         return;
       }
     }
@@ -77,13 +77,13 @@ Resources::gather(const ResourceIDs ids, TSHttpHookID hook)
   case TS_HTTP_SEND_RESPONSE_HDR_HOOK:
     // Send response headers to client
     if (ids & RSRC_CLIENT_RESPONSE_HEADERS) {
-      TSDebug(PLUGIN_NAME, "\tAdding TXN client response header buffers");
+      TSLogDebug("\tAdding TXN client response header buffers");
       if (TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
-        TSDebug(PLUGIN_NAME, "could not gather bufp/hdr_loc for request");
+        TSLogDebug("Could not gather bufp/hdr_loc for request");
         return;
       }
       if (ids & RSRC_RESPONSE_STATUS) {
-        TSDebug(PLUGIN_NAME, "\tAdding TXN client esponse status resource");
+        TSLogDebug("\tAdding TXN client esponse status resource");
         resp_status = TSHttpHdrStatusGet(bufp, hdr_loc);
       }
     }
@@ -92,7 +92,7 @@ Resources::gather(const ResourceIDs ids, TSHttpHookID hook)
   case TS_REMAP_PSEUDO_HOOK:
     // Pseudo-hook for a remap instance
     if (client_bufp && client_hdr_loc) {
-      TSDebug(PLUGIN_NAME, "\tAdding TXN client request header buffers for remap instance");
+      TSLogDebug("\tAdding TXN client request header buffers for remap instance");
       bufp = client_bufp;
       hdr_loc = client_hdr_loc;
     }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/resources.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/resources.h b/plugins/header_rewrite/resources.h
index d2ce9f5..815a3e1 100644
--- a/plugins/header_rewrite/resources.h
+++ b/plugins/header_rewrite/resources.h
@@ -51,7 +51,7 @@ public:
     : txnp(txnptr), contp(contptr), bufp(NULL), hdr_loc(NULL), client_bufp(NULL), client_hdr_loc(NULL),
       resp_status(TS_HTTP_STATUS_NONE), _rri(NULL), changed_url(false), _ready(false)
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for Resources (InkAPI)");
+    TSLogDebug("Calling CTOR for Resources (InkAPI)");
   }
 
   Resources(TSHttpTxn txnptr, TSRemapRequestInfo *rri) :
@@ -59,8 +59,8 @@ public:
     bufp(NULL), hdr_loc(NULL), client_bufp(NULL), client_hdr_loc(NULL), resp_status(TS_HTTP_STATUS_NONE),
     _rri(rri), _ready(false)
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for Resources (RemapAPI)");
-    TSDebug(PLUGIN_NAME, "rri: %p", _rri);
+    TSLogDebug("Calling CTOR for Resources (RemapAPI)");
+    TSLogDebug("rri: %p", _rri);
   }
 
   ~Resources() { destroy(); }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/ruleset.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/ruleset.cc b/plugins/header_rewrite/ruleset.cc
index 9b2d688..11204c7 100644
--- a/plugins/header_rewrite/ruleset.cc
+++ b/plugins/header_rewrite/ruleset.cc
@@ -45,10 +45,10 @@ RuleSet::add_condition(Parser& p) {
   Condition* c = condition_factory(p.get_op());
 
   if (NULL != c) {
-    TSDebug(PLUGIN_NAME, "Adding condition: %%{%s} with arg: %s\n", p.get_op().c_str(), p.get_arg().c_str());
+    TSLogDebug("Adding condition: %%{%s} with arg: %s\n", p.get_op().c_str(), p.get_arg().c_str());
     c->initialize(p);
     if (!c->set_hook(_hook)) {
-      TSError("header_rewrite: can't use this condition in this hook");
+      TSLogError("Cannot use this condition in this hook");
       return;
     }
     if (NULL == _cond) {
@@ -70,10 +70,10 @@ RuleSet::add_operator(Parser& p) {
 
   if (NULL != o) {
     // TODO: This should be extended to show both the "argument" and the "value" (if both are used)
-    TSDebug(PLUGIN_NAME, "Adding operator: %s(%s)\n", p.get_op().c_str(), p.get_arg().c_str());
+    TSLogDebug("Adding operator: %s(%s)\n", p.get_op().c_str(), p.get_arg().c_str());
     o->initialize(p);
     if (!o->set_hook(_hook)) {
-      TSError("header_rewrite: can't use this operator in this hook");
+      TSLogError("Cannot use this operator in this hook");
       return;
     }
     if (NULL == _oper) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/statement.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/statement.h b/plugins/header_rewrite/statement.h
index 15fdf11..7492137 100644
--- a/plugins/header_rewrite/statement.h
+++ b/plugins/header_rewrite/statement.h
@@ -51,11 +51,11 @@ class Statement
   Statement()
     : _next(NULL), _pdata(NULL), _rsrc(RSRC_NONE), _initialized(false), _hook(TS_HTTP_READ_RESPONSE_HDR_HOOK)
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for Statement");
+    TSLogDebug("Calling CTOR for Statement");
   }
 
   virtual ~Statement() {
-    TSDebug(PLUGIN_NAME_DBG, "Calling DTOR for Statement");
+    TSLogDebug("Calling DTOR for Statement");
     free_pdata();
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/value.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/value.h b/plugins/header_rewrite/value.h
index 0c318fc..55fa537 100644
--- a/plugins/header_rewrite/value.h
+++ b/plugins/header_rewrite/value.h
@@ -44,7 +44,7 @@ public:
   Value()
     : _value(""), _int_value(-1), _cond_val(NULL)
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for Value");
+    TSLogDebug("Calling CTOR for Value");
   };
 
   void

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/libloader/libloader.c
----------------------------------------------------------------------
diff --git a/plugins/libloader/libloader.c b/plugins/libloader/libloader.c
index ef84c2f..acf8373 100644
--- a/plugins/libloader/libloader.c
+++ b/plugins/libloader/libloader.c
@@ -32,6 +32,9 @@
 #include <stdlib.h>
 #include <ts/ts.h>
 
+#define PLUGIN_NAME "libloader"
+#include <ts/debug.h>
+
 typedef struct {
     void *handle;
     void *next;
@@ -61,7 +64,7 @@ void TSPluginInit(int argc, const char *argv[])
     info.support_email = (char *)"users@trafficserver.apache.org";
 
     if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) {
-        TSError("[libloader] Plugin registration failed.\n");
+        TSLogError("Plugin registration failed.");
         return;
     }
 
@@ -75,10 +78,10 @@ void TSPluginInit(int argc, const char *argv[])
             l->handle = handle;
             l->next = libs;
             libs = l;
-            TSDebug("libloader", " loaded %s\n", lib);
+            TSLogDebug("loaded %s", lib);
         }
         else {
-            TSError("[libloader] failed to load %s: %s\n", lib, dlerror());
+            TSLogError("Failed to load %s: %s", lib, dlerror());
         }
     }
     return;

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


[3/5] TS-2106: transform all plugins to new logging non-API

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

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

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

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_filter/header_filter.cc
----------------------------------------------------------------------
diff --git a/plugins/header_filter/header_filter.cc b/plugins/header_filter/header_filter.cc
index 33713e9..8d1737d 100644
--- a/plugins/header_filter/header_filter.cc
+++ b/plugins/header_filter/header_filter.cc
@@ -69,8 +69,7 @@ cont_header_filter(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata)
       hook = TS_HTTP_SEND_RESPONSE_HDR_HOOK;
     break;
   default:
-    TSError("header_filter: unknown event for this plugin");
-    TSDebug(PLUGIN_NAME, "unknown event for this plugin");
+    TSLogError("Unknown event (%d) for this plugin", event);
     break;
   }
 
@@ -105,25 +104,25 @@ TSPluginInit(int argc, const char *argv[])
   info.support_email = const_cast<char*>("users@trafficserver.apache.org");
 
   if (TSPluginRegister(TS_SDK_VERSION_3_0 , &info) != TS_SUCCESS) {
-    TSError("header_filter: plugin registration failed.\n"); 
+    TSLogError("plugin registration failed."); 
   }
 
   // Parse the rules file
   if ((argc > 1)) {
     if (!global.parse_file(argv[1]))
-      TSError("header_filter: failed to parse configuration file");
+      TSLogError("failed to parse configuration file");
   }
 
   TSCont cont = TSContCreate(cont_header_filter, NULL);
 
   for (int i=TS_HTTP_READ_REQUEST_HDR_HOOK; i < TS_HTTP_LAST_HOOK; ++i) {
     if (global.supported_hook(static_cast<TSHttpHookID>(i))) {
-      TSDebug(PLUGIN_NAME, "Registering hook %d", i);
+      TSLogDebug("Registering hook %d", i);
       TSHttpHookAdd(static_cast<TSHttpHookID>(i), cont);
     }
   }
   if (TSHttpArgIndexReserve(PLUGIN_NAME, "Filter out headers in various hooks", &arg_idx) != TS_SUCCESS) {
-    TSError("header_filter: failed to reserve private data slot");
+    TSLogError("failed to reserve private data slot");
   }
 }
 
@@ -150,7 +149,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 */
 }
 
@@ -159,7 +158,7 @@ TSReturnCode
 TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED */, int /* errbuf_size */)
 {
   if (argc < 3) {
-    TSError("Unable to create remap instance, need rules file");
+    TSLogError("Unable to create remap instance, need rules file");
     return TS_ERROR;
   } else {
     Rules* conf = new(Rules);
@@ -187,7 +186,7 @@ TSRemapStatus
 TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
 {
   if (NULL == ih) {
-    TSDebug(PLUGIN_NAME, "No Rules configured, falling back to default mapping rule");
+    TSLogDebug("No Rules configured, falling back to default mapping rule");
   } else {
     Rules* confp = static_cast<Rules*>(ih);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_filter/lulu.h
----------------------------------------------------------------------
diff --git a/plugins/header_filter/lulu.h b/plugins/header_filter/lulu.h
index 24cc165..80c73f5 100644
--- a/plugins/header_filter/lulu.h
+++ b/plugins/header_filter/lulu.h
@@ -47,8 +47,8 @@
 #endif
 
 // Used for Debug etc.
-static const char* PLUGIN_NAME = "header_filter";
-static const char* PLUGIN_NAME_DBG = "header_filter_dbg";
+#define PLUGIN_NAME "header_filter"
+#include <ts/debug.h>
 
 // From google styleguide: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
 #define DISALLOW_COPY_AND_ASSIGN(TypeName)      \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_filter/rules.cc
----------------------------------------------------------------------
diff --git a/plugins/header_filter/rules.cc b/plugins/header_filter/rules.cc
index 62c21cb..1257887 100644
--- a/plugins/header_filter/rules.cc
+++ b/plugins/header_filter/rules.cc
@@ -45,14 +45,14 @@ inline void
 add_header(TSMBuffer& reqp, TSMLoc& hdr_loc, const char* hdr, int hdr_len, const char* val, int val_len)
 {
   if (val_len <= 0) {
-    TSDebug(PLUGIN_NAME, "\tWould set header %s to an empty value, skipping", hdr);
+    TSLogDebug("\tWould set header %s to an empty value, skipping", hdr);
   } else {
     TSMLoc new_field;
 
     if (TS_SUCCESS == TSMimeHdrFieldCreateNamed(reqp, hdr_loc, hdr, hdr_len, &new_field)) {
       if (TS_SUCCESS == TSMimeHdrFieldValueStringInsert(reqp, hdr_loc, new_field, -1,  val, val_len))
         if (TS_SUCCESS == TSMimeHdrFieldAppend(reqp, hdr_loc, new_field))
-          TSDebug(PLUGIN_NAME, "\tAdded header %s: %s", hdr, val);
+          TSLogDebug("\tAdded header %s: %s", hdr, val);
       TSHandleMLocRelease(reqp, hdr_loc, new_field);
     }
   }
@@ -130,7 +130,7 @@ RulesEntry::execute(TSMBuffer& reqp, TSMLoc& hdr_loc) const
             nuke = false;
             first_set = false;
             if (TS_SUCCESS == TSMimeHdrFieldValueStringSet(reqp, hdr_loc, field, -1, _qualifier, _q_len))
-              TSDebug(PLUGIN_NAME, "\tSet header:  %s: %s", _header, _qualifier);
+              TSLogDebug("\tSet header:  %s: %s", _header, _qualifier);
           } else {
             // Nuke all other "duplicates" of this header
             nuke = true;
@@ -145,7 +145,7 @@ RulesEntry::execute(TSMBuffer& reqp, TSMLoc& hdr_loc) const
           nuke = !nuke;
         if (nuke) {
           if (TS_SUCCESS == TSMimeHdrFieldDestroy(reqp, hdr_loc, field))
-            TSDebug(PLUGIN_NAME, "\tDeleting header %.*s", static_cast<int>(_h_len), _header);
+            TSLogDebug("\tDeleting header %.*s", static_cast<int>(_h_len), _header);
         }
         TSHandleMLocRelease(reqp, hdr_loc, field);
         field = tmp;
@@ -158,7 +158,7 @@ RulesEntry::execute(TSMBuffer& reqp, TSMLoc& hdr_loc) const
 // Rules class implementations
 Rules::~Rules()
 {
-  TSDebug(PLUGIN_NAME_DBG, "Calling DTOR for Rules");
+  TSLogDebug("Calling DTOR for Rules");
 
   for (int i = 0; i < TS_HTTP_LAST_HOOK; ++i)
     delete _entries[i];
@@ -190,10 +190,10 @@ Rules::parse_file(const char* filename)
   // TODO: Should we support a 'default' prefix here for the rules?
   f.open(filename, std::ios::in);
   if (!f.is_open()) {
-    TSError("unable to open %s", filename);
+    TSLogError("unable to open %s", filename);
     return false;
   }
-  TSDebug(PLUGIN_NAME, "Parsing config file %s", filename);
+  TSLogDebug("Parsing config file %s", filename);
   while (!f.eof()) {
     bool inverse = false;
     int options = 0;
@@ -277,18 +277,18 @@ Rules::parse_file(const char* filename)
                 qualifier = line.substr(pos1+1, pos2-pos1-1);
                 if (line[pos2+1] == 'i')
                   options |= PCRE_CASELESS;
-                TSDebug(PLUGIN_NAME, "Adding '%s' to hook %d, type is %d, qualifier is %c %s (%c)",
+                TSLogDebug("Adding '%s' to hook %d, type is %d, qualifier is %c %s (%c)",
                         word.c_str(), hook, type, inverse ? '!' : ' ', qualifier.c_str(), options & PCRE_CASELESS ? 'i' : ' ');
                 add_entry(hook, word, qualifier, type, inverse, options);
               } else {
-                TSError("Missing trailing delimiter in qualifier");
+                TSLogError("Missing trailing delimiter in qualifier");
               }
             } else {
-              TSError("Missing leading delimiter in qualifier");
+              TSLogError("Missing leading delimiter in qualifier");
             }
           } else {
             // No qualifier, so we'll nuke this header for all values
-            TSDebug(PLUGIN_NAME, "Adding %s to hook %d (unqualified)", word.c_str(), hook);
+            TSLogDebug("Adding %s to hook %d (unqualified)", word.c_str(), hook);
             add_entry(hook, word);
           }
         }
@@ -308,7 +308,7 @@ Rules::execute(TSMBuffer& reqp, TSMLoc& hdr_loc, const TSHttpHookID hook) const
   if (_entries[hook]) {
     RulesEntry* n = _entries[hook];
 
-    TSDebug(PLUGIN_NAME, "Executing rules(s) for hook %d", hook);
+    TSLogDebug("Executing rules(s) for hook %d", hook);
     do {
       n->execute(reqp, hdr_loc);
     } while (NULL != (n = n->next()));

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_filter/rules.h
----------------------------------------------------------------------
diff --git a/plugins/header_filter/rules.h b/plugins/header_filter/rules.h
index 70e3756..a6d6335 100644
--- a/plugins/header_filter/rules.h
+++ b/plugins/header_filter/rules.h
@@ -78,16 +78,16 @@ public:
                             &erroffset,           // for error offset
                             NULL);                // use default character tables
         if (!_rex)
-          TSError("header_filter: PCRE failed on %s at offset %d: %s\n", _qualifier, erroffset, error);
+          TSLogError("PCRE failed on %s at offset %d: %s\n", _qualifier, erroffset, error);
       }
     }
 
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for RulesEntry, header is %s, qualifier is %s", _header, _qualifier);
+    TSLogDebug("Calling CTOR for RulesEntry, header is %s, qualifier is %s", _header, _qualifier);
   }
 
   ~RulesEntry()
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling DTOR for RulesEntry");
+    TSLogDebug("Calling DTOR for RulesEntry");
     delete _next; // Potentially "deep" recursion, but should be OK.
     if (_header)
       TSfree(_header);
@@ -127,7 +127,7 @@ class Rules
 public:
   Rules()
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for Rules");
+    TSLogDebug("Calling CTOR for Rules");
     memset(_entries, 0, sizeof(_entries));
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/condition.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/condition.cc b/plugins/header_rewrite/condition.cc
index 5180962..9ee323c 100644
--- a/plugins/header_rewrite/condition.cc
+++ b/plugins/header_rewrite/condition.cc
@@ -60,7 +60,7 @@ Condition::initialize(Parser& p)
 
   if (p.mod_exist("OR")) {
     if (p.mod_exist("AND")) {
-      TSError("header_rewrite: Can't have both AND and OR in mods");
+      TSLogError("Can't have both AND and OR in mods");
     } else {
       _mods = static_cast<CondModifiers>(_mods | COND_OR);
     }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/condition.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/condition.h b/plugins/header_rewrite/condition.h
index e832a87..9393ff0 100644
--- a/plugins/header_rewrite/condition.h
+++ b/plugins/header_rewrite/condition.h
@@ -52,7 +52,7 @@ public:
   Condition()
     : _qualifier(""), _cond_op(MATCH_EQUAL), _matcher(NULL), _mods(COND_NONE)
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for Condition");
+    TSLogDebug("Calling CTOR for Condition");
   }
 
   // Inline this, it's critical for speed (and only used twice)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/conditions.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/conditions.cc b/plugins/header_rewrite/conditions.cc
index 84ad1f0..c541267 100644
--- a/plugins/header_rewrite/conditions.cc
+++ b/plugins/header_rewrite/conditions.cc
@@ -54,7 +54,7 @@ ConditionStatus::initialize_hooks() {
 
 bool
 ConditionStatus::eval(const Resources& res) {
-  TSDebug(PLUGIN_NAME, "Evaluating STATUS()"); // TODO: It'd be nice to get the args here ...
+  TSLogDebug("Evaluating STATUS()"); // TODO: It'd be nice to get the args here ...
   return static_cast<const Matchers<TSHttpStatus>*>(_matcher)->test(res.resp_status);
 }
 
@@ -62,7 +62,7 @@ ConditionStatus::eval(const Resources& res) {
 void
 ConditionStatus::append_value(std::string& s, const Resources& res) {
   s += boost::lexical_cast<std::string>(res.resp_status);
-  TSDebug(PLUGIN_NAME, "Appending STATUS(%d) to evaluation value -> %s", res.resp_status, s.c_str());
+  TSLogDebug("Appending STATUS(%d) to evaluation value -> %s", res.resp_status, s.c_str());
 }
 
 
@@ -87,7 +87,7 @@ ConditionRandom::initialize(Parser& p)
 
 bool
 ConditionRandom::eval(const Resources& /* res ATS_UNUSED */) {
-  TSDebug(PLUGIN_NAME, "Evaluating RANDOM(%d)", _max);
+  TSLogDebug("Evaluating RANDOM(%d)", _max);
   return static_cast<const Matchers<unsigned int>*>(_matcher)->test(rand_r(&_seed) % _max);
 }
 
@@ -96,7 +96,7 @@ void
 ConditionRandom::append_value(std::string& s, const Resources& /* res ATS_UNUSED */)
 {
   s += boost::lexical_cast<std::string>(rand_r(&_seed) % _max);
-  TSDebug(PLUGIN_NAME, "Appending RANDOM(%d) to evaluation value -> %s", _max, s.c_str());
+  TSLogDebug("Appending RANDOM(%d) to evaluation value -> %s", _max, s.c_str());
 }
 
 
@@ -133,7 +133,7 @@ ConditionAccess::eval(const Resources& /* res ATS_UNUSED */)
 
   gettimeofday(&tv, NULL);
 
-  TSDebug(PLUGIN_NAME, "Evaluating ACCESS(%s)", _qualifier.c_str());
+  TSLogDebug("Evaluating ACCESS(%s)", _qualifier.c_str());
   if (tv.tv_sec > _next) {
     // There is a small "race" here, where we could end up calling access() a few times extra. I think
     // that is OK, and not worth protecting with a lock.
@@ -186,10 +186,10 @@ ConditionHeader::append_value(std::string& s, const Resources& res)
 
   if (bufp && hdr_loc) {
     field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, _qualifier.c_str(), _qualifier.size());
-    TSDebug(PLUGIN_NAME, "Getting Header: %s, field_loc: %p", _qualifier.c_str(), field_loc);
+    TSLogDebug("Getting Header: %s, field_loc: %p", _qualifier.c_str(), field_loc);
     if (field_loc != NULL) {
       value = TSMimeHdrFieldValueStringGet(res.bufp, res.hdr_loc, field_loc, 0, &len);
-      TSDebug(PLUGIN_NAME, "Appending HEADER(%s) to evaluation value -> %.*s", _qualifier.c_str(), len, value);
+      TSLogDebug("Appending HEADER(%s) to evaluation value -> %.*s", _qualifier.c_str(), len, value);
       s.append(value, len);
       TSHandleMLocRelease(res.bufp, res.hdr_loc, field_loc);
     }
@@ -204,7 +204,7 @@ ConditionHeader::eval(const Resources& res)
 
   append_value(s, res);
   bool rval = static_cast<const Matchers<std::string>*>(_matcher)->test(s);
-  TSDebug(PLUGIN_NAME, "Evaluating HEADER(): %s - rval: %d", s.c_str(), rval);
+  TSLogDebug("Evaluating HEADER(): %s - rval: %d", s.c_str(), rval);
   return rval;
 }
 
@@ -225,7 +225,7 @@ ConditionPath::append_value(std::string& s, const Resources& res)
 { 
   int path_len = 0;
   const char *path = TSUrlPathGet(res._rri->requestBufp, res._rri->requestUrl, &path_len);
-  TSDebug(PLUGIN_NAME, "Appending PATH to evaluation value: %.*s", path_len, path);
+  TSLogDebug("Appending PATH to evaluation value: %.*s", path_len, path);
   s.append(path, path_len);
 }
 
@@ -235,11 +235,11 @@ ConditionPath::eval(const Resources& res)
   std::string s;
 
   if (NULL == res._rri) {
-    TSDebug(PLUGIN_NAME, "PATH requires remap initialization! Evaluating to false!");
+    TSLogDebug("PATH requires remap initialization! Evaluating to false!");
     return false;
   }
   append_value(s, res);
-  TSDebug(PLUGIN_NAME, "Evaluating PATH");
+  TSLogDebug("Evaluating PATH");
 
   return static_cast<const Matchers<std::string>*>(_matcher)->test(s);
 }
@@ -261,7 +261,7 @@ ConditionQuery::append_value(std::string& s, const Resources& res)
 {
   int query_len = 0;
   const char *query = TSUrlHttpQueryGet(res._rri->requestBufp, res._rri->requestUrl, &query_len);
-  TSDebug(PLUGIN_NAME, "Appending QUERY to evaluation value: %.*s", query_len, query);
+  TSLogDebug("Appending QUERY to evaluation value: %.*s", query_len, query);
   s.append(query, query_len);
 }
 
@@ -271,11 +271,11 @@ ConditionQuery::eval(const Resources& res)
   std::string s;
 
   if (NULL == res._rri) {
-    TSDebug(PLUGIN_NAME, "QUERY requires remap initialization! Evaluating to false!");
+    TSLogDebug("QUERY requires remap initialization! Evaluating to false!");
     return false;
   }
   append_value(s, res);
-  TSDebug(PLUGIN_NAME, "Evaluating QUERY - %s", s.c_str());
+  TSLogDebug("Evaluating QUERY - %s", s.c_str());
   return static_cast<const Matchers<std::string>*>(_matcher)->test(s);
 }
 
@@ -326,13 +326,13 @@ ConditionDBM::initialize(Parser& p)
     _file = _qualifier.substr(0, pos);
     //_dbm = mdbm_open(_file.c_str(), O_RDONLY, 0, 0, 0);
     // if (NULL != _dbm) {
-    //   TSDebug(PLUGIN_NAME, "Opened DBM file %s\n", _file.c_str());
+    //   TSLogDebug("Opened DBM file %s\n", _file.c_str());
     //   _key.set_value(_qualifier.substr(pos + 1));
     // } else {
-    //   TSError("Failed to open DBM file: %s", _file.c_str());
+    //   TSLogError("Failed to open DBM file: %s", _file.c_str());
     // }
   } else {
-    TSError("Malformed DBM condition");
+    TSLogError("Malformed DBM condition");
   }
 }
 
@@ -349,7 +349,7 @@ ConditionDBM::append_value(std::string& /* s ATS_UNUSED */, const Resources& /*
   // if (key.size() > 0) {
   //   datum k, v;
 
-  //   TSDebug(PLUGIN_NAME, "Looking up DBM(\"%s\")", key.c_str());
+  //   TSLogDebug("Looking up DBM(\"%s\")", key.c_str());
   //   k.dptr = const_cast<char*>(key.c_str());
   //   k.dsize = key.size();
 
@@ -357,7 +357,7 @@ ConditionDBM::append_value(std::string& /* s ATS_UNUSED */, const Resources& /*
   //   //v = mdbm_fetch(_dbm, k);
   //   TSMutexUnlock(_mutex);
   //   if (v.dsize > 0) {
-  //     TSDebug(PLUGIN_NAME, "Appending DBM(%.*s) to evaluation value -> %.*s", k.dsize, k.dptr, v.dsize, v.dptr);
+  //     TSLogDebug("Appending DBM(%.*s) to evaluation value -> %.*s", k.dsize, k.dptr, v.dsize, v.dptr);
   //     s.append(v.dptr, v.dsize);
   //   }
   // }
@@ -370,7 +370,7 @@ ConditionDBM::eval(const Resources& res)
   std::string s;
 
   append_value(s, res);
-  TSDebug(PLUGIN_NAME, "Evaluating DBM(%s, \"%s\")", _file.c_str(), s.c_str());
+  TSLogDebug("Evaluating DBM(%s, \"%s\")", _file.c_str(), s.c_str());
 
   return static_cast<const Matchers<std::string>*>(_matcher)->test(s);
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/conditions.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/conditions.h b/plugins/header_rewrite/conditions.h
index 904533d..922550f 100644
--- a/plugins/header_rewrite/conditions.h
+++ b/plugins/header_rewrite/conditions.h
@@ -43,14 +43,14 @@ class ConditionTrue : public Condition
 public:
   ConditionTrue()
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for ConditionTrue");
+    TSLogDebug("Calling CTOR for ConditionTrue");
   }
 
   void append_value(std::string& s, const Resources& /* res ATS_UNUSED */) { s += "TRUE";  }
 
 protected:
   bool eval(const Resources& /* res ATS_UNUSED */) {
-    TSDebug(PLUGIN_NAME, "Evaluating TRUE()");
+    TSLogDebug("Evaluating TRUE()");
     return true;
   }
 
@@ -65,13 +65,13 @@ class ConditionFalse : public Condition
 public:
   ConditionFalse()
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for ConditionFalse");
+    TSLogDebug("Calling CTOR for ConditionFalse");
   }
   void append_value(std::string& s, const Resources& /* res ATS_UNUSED */) { s += "FALSE"; }
 
 protected:
   bool eval(const Resources& /* res ATS_UNUSED */) {
-    TSDebug(PLUGIN_NAME, "Evaluating FALSE()");
+    TSLogDebug("Evaluating FALSE()");
     return false;
   }
 
@@ -86,7 +86,7 @@ class ConditionStatus : public Condition
 public:
   ConditionStatus()
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for ConditionStatus");
+    TSLogDebug("Calling CTOR for ConditionStatus");
   }
   void initialize(Parser& p);
   void append_value(std::string& s, const Resources& res);
@@ -107,7 +107,7 @@ public:
   ConditionRandom()
     : _seed(0), _max(0)
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for ConditionRandom");
+    TSLogDebug("Calling CTOR for ConditionRandom");
   }
   void initialize(Parser& p);
   void append_value(std::string& s, const Resources& res);
@@ -130,7 +130,7 @@ public:
   ConditionAccess()
     : _next(0), _last(false)
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for ConditionAccess");
+    TSLogDebug("Calling CTOR for ConditionAccess");
   }
   void initialize(Parser& p);
   void append_value(std::string& s, const Resources& res);
@@ -153,7 +153,7 @@ public:
   explicit ConditionHeader(bool client = false)
     : _client(client)
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for ConditionHeader, client %d", client);
+    TSLogDebug("Calling CTOR for ConditionHeader, client %d", client);
   };
 
   void initialize(Parser& p);
@@ -174,7 +174,7 @@ class ConditionPath : public Condition
 public:
   explicit ConditionPath()
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for ConditionPath");
+    TSLogDebug("Calling CTOR for ConditionPath");
   };
 
   void initialize(Parser& p);
@@ -206,7 +206,7 @@ class ConditionQuery : public Condition
 public:
   explicit ConditionQuery()
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for ConditionQuery");
+    TSLogDebug("Calling CTOR for ConditionQuery");
   };
 
   void initialize(Parser& p);
@@ -228,7 +228,7 @@ public:
   explicit ConditionUrl(bool client = false)
     : _url_qual(URL_QUAL_NONE), _client(client)
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for ConditionUrl");
+    TSLogDebug("Calling CTOR for ConditionUrl");
   };
 
   void initialize(Parser& p);
@@ -256,7 +256,7 @@ public:
       _file("")
   {
     _mutex = TSMutexCreate();
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for ConditionDBM");
+    TSLogDebug("Calling CTOR for ConditionDBM");
   }
 
   ~ConditionDBM() {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/factory.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/factory.cc b/plugins/header_rewrite/factory.cc
index d20fa40..b9a803e 100644
--- a/plugins/header_rewrite/factory.cc
+++ b/plugins/header_rewrite/factory.cc
@@ -50,7 +50,7 @@ operator_factory(const std::string& op)
   } else if (op == "no-op") {
     o = new OperatorNoOp();
   } else {
-    TSError("header_rewrite: unknown operator in header_rewrite: %s", op.c_str());
+    TSLogError("Unknown operator in header_rewrite: %s", op.c_str());
     return NULL;
   }
 
@@ -98,7 +98,7 @@ condition_factory(const std::string& cond)
   } else if (c_name == "DBM") {
     c = new ConditionDBM();
   } else {
-    TSError("header_rewrite: unknown condition in header_rewrite: %s",c_name.c_str());
+    TSLogError("unknown condition in header_rewrite: %s",c_name.c_str());
     return NULL;
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/header_rewrite.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/header_rewrite.cc b/plugins/header_rewrite/header_rewrite.cc
index 1300742..35b6d19 100644
--- a/plugins/header_rewrite/header_rewrite.cc
+++ b/plugins/header_rewrite/header_rewrite.cc
@@ -32,9 +32,6 @@
 #include "resources.h"
 
 // "Defines"
-const char* PLUGIN_NAME = "header_rewrite";
-const char* PLUGIN_NAME_DBG = "header_rewrite_dbg";
-
 static const char* DEFAULT_CONF_PATH = "/usr/local/etc/header_rewrite/";
 
 
@@ -46,7 +43,7 @@ static ResourceIDs all_resids[TS_HTTP_LAST_HOOK+1];
 static bool
 add_rule(RuleSet* rule) {
   if (rule && rule->has_operator()) {
-    TSDebug(PLUGIN_NAME, "Adding rule to hook=%d\n", rule->get_hook());
+    TSLogDebug("Adding rule to hook=%d\n", rule->get_hook());
     if (NULL == all_rules[rule->get_hook()]) {
       all_rules[rule->get_hook()] = rule;
     } else {
@@ -82,18 +79,18 @@ parse_config(const std::string fname, TSHttpHookID default_hook)
 
   f.open(filename.c_str(), std::ios::in);
   if (!f.is_open()) {
-    TSError("header_rewrite: unable to open %s", filename.c_str());
+    TSLogError("Unable to open %s", filename.c_str());
     return false;
   }
 
-  TSDebug(PLUGIN_NAME, "Loading header_rewrite config from %s", filename.c_str());
+  TSLogDebug("Loading header_rewrite config from %s", filename.c_str());
 
   while (!f.eof()) {
     std::string line;
 
     getline(f, line);
     ++lineno; // ToDo: we should probably use this for error messages ...
-    TSDebug(PLUGIN_NAME, "Reading line: %d: %s", lineno, line.c_str());
+    TSLogDebug("Reading line: %d: %s", lineno, line.c_str());
 
     boost::trim(line);
     if (line.empty() || (line[0] == '#'))
@@ -156,7 +153,7 @@ parse_config(const std::string fname, TSHttpHookID default_hook)
 static int
 cont_rewrite_headers(TSCont contp, TSEvent event, void *edata)
 {
-  TSDebug(PLUGIN_NAME, "plugin: %d", event);
+  TSLogDebug("plugin: %d", event);
 
   TSHttpTxn txnp = (TSHttpTxn) edata;
   Resources res(txnp, contp);
@@ -181,8 +178,7 @@ cont_rewrite_headers(TSCont contp, TSEvent event, void *edata)
     hook = TS_HTTP_SEND_RESPONSE_HDR_HOOK;
     break;
   default:
-    TSError("header_rewrite: unknown event for this plugin");
-    TSDebug(PLUGIN_NAME, "unknown event for this plugin");
+    TSLogError("unknown event (%d) for this plugin", event);
     break;
   }
 
@@ -221,12 +217,12 @@ TSPluginInit(int argc, const char *argv[])
   info.support_email = (char*)"";
 
   if (TS_SUCCESS != TSPluginRegister(TS_SDK_VERSION_3_0 , &info)) {
-    TSError("header_rewrite: plugin registration failed.\n"); 
+    TSLogError("plugin registration failed."); 
   }
 
-  TSDebug(PLUGIN_NAME, "number of arguments: %d", argc);
+  TSLogDebug("number of arguments: %d", argc);
   if (argc != 2) {
-    TSError("usage: %s <config-file>\n", argv[0] );
+    TSLogError("usage: %s <config-file>", argv[0] );
     assert(argc == 2);
   }
 
@@ -240,12 +236,12 @@ TSPluginInit(int argc, const char *argv[])
   if (parse_config(argv[1], TS_HTTP_READ_RESPONSE_HDR_HOOK)) {
     for (int i=TS_HTTP_READ_REQUEST_HDR_HOOK; i<TS_HTTP_LAST_HOOK; ++i) {
       if (all_rules[i]) {
-        TSDebug(PLUGIN_NAME, "adding hook: %d", i);
+        TSLogDebug("adding hook: %d", i);
         TSHttpHookAdd(static_cast<TSHttpHookID>(i), TSContCreate(cont_rewrite_headers, NULL));
       }
     }
   } else {
-    TSError("header_rewrite: failed to parse configuration file");
+    TSLogError("Failed to parse configuration file");
   }
 }
 
@@ -272,7 +268,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;
 }
 
@@ -280,10 +276,10 @@ TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
 TSReturnCode
 TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSED */, int /* errbuf_size ATS_UNUSED */)
 {
-  TSDebug(PLUGIN_NAME, "initializing the remap plugin header_rewrite");
+  TSLogDebug("initializing the remap plugin header_rewrite");
 
   if (argc < 3) {
-    TSError("Unable to create remap instance, need config file");
+    TSLogError("Unable to create remap instance, need config file");
     return TS_ERROR;
   }
 
@@ -291,14 +287,14 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSE
   // remap instantiation.
   all_rules[TS_REMAP_PSEUDO_HOOK] = NULL;
   if (!parse_config(argv[2], TS_REMAP_PSEUDO_HOOK)) {
-    TSError("Unable to create remap instance");
+    TSLogError("Unable to create remap instance");
     return TS_ERROR;
   }
 
   *ih = all_rules[TS_REMAP_PSEUDO_HOOK];
   all_rules[TS_REMAP_PSEUDO_HOOK] = NULL;
 
-  TSDebug(PLUGIN_NAME, "successfully initialize the header_rewrite plugin");
+  TSLogInfo("successfully initialized plugin");
   return TS_SUCCESS;
 }
 
@@ -320,7 +316,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
   TSRemapStatus rval = TSREMAP_NO_REMAP;
 
   if (NULL == ih) {
-    TSDebug(PLUGIN_NAME, "No Rules configured, falling back to default");
+    TSLogDebug("No Rules configured, falling back to default");
     return rval;
   } else {
     RuleSet* rule = (RuleSet*)ih;
@@ -346,7 +342,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
 
   }
 
-  TSDebug(PLUGIN_NAME, "returing with status: %d", rval);
+  TSLogDebug("returing with status: %d", rval);
   return rval;
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/lulu.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/lulu.h b/plugins/header_rewrite/lulu.h
index 99876ec..80bcafc 100644
--- a/plugins/header_rewrite/lulu.h
+++ b/plugins/header_rewrite/lulu.h
@@ -43,8 +43,8 @@
 #error "Define barriers"
 #endif
 
-extern const char* PLUGIN_NAME;
-extern const char* PLUGIN_NAME_DBG;
+#define PLUGIN_NAME "header_rewrite"
+#include <ts/debug.h>
 
 
 // From google styleguide: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/matcher.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/matcher.h b/plugins/header_rewrite/matcher.h
index d9648c8..ae8fca6 100644
--- a/plugins/header_rewrite/matcher.h
+++ b/plugins/header_rewrite/matcher.h
@@ -48,11 +48,11 @@ public:
   explicit Matcher(const MatcherOps op)
     : _pdata(NULL), _op(op)
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for Matcher");
+    TSLogDebug("Calling CTOR for Matcher");
   }
 
   virtual ~Matcher() {
-    TSDebug(PLUGIN_NAME_DBG, "Calling DTOR for Matcher");
+    TSLogDebug("Calling DTOR for Matcher");
     free_pdata();
   }
 
@@ -86,7 +86,7 @@ public:
       std::cout<<"Invalid regex:failed to precompile"<<std::endl;
       abort();
     }
-    TSDebug(PLUGIN_NAME,"Regex precompiled successfully");
+    TSLogDebug("Regex precompiled successfully");
   }
 
   void setRegex(const unsigned int /* t ATS_UNUSED */) { return; }
@@ -148,10 +148,10 @@ private:
  }
   
   bool test_reg(const std::string t) const {
-      TSDebug(PLUGIN_NAME, "Test regular expression %s : %s", _data.c_str(), t.c_str());
+      TSLogDebug("Test regular expression %s : %s", _data.c_str(), t.c_str());
           int ovector[OVECCOUNT];
           if (helper.regexMatch(t.c_str(), t.length(), ovector) > 0) {
-              TSDebug(PLUGIN_NAME, "Successfully found regular expression match");
+              TSLogDebug("Successfully found regular expression match");
               return true;
     }
       return false;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/operator.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/operator.h b/plugins/header_rewrite/operator.h
index f136290..db67202 100644
--- a/plugins/header_rewrite/operator.h
+++ b/plugins/header_rewrite/operator.h
@@ -48,7 +48,7 @@ public:
   Operator()
     : _mods(OPER_NONE)
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for Operator");
+    TSLogDebug("Calling CTOR for Operator");
   }
 
   void do_exec(const Resources& res) const {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/operators.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/operators.cc b/plugins/header_rewrite/operators.cc
index 3775166..c2ab9c9 100644
--- a/plugins/header_rewrite/operators.cc
+++ b/plugins/header_rewrite/operators.cc
@@ -45,10 +45,10 @@ OperatorRMHeader::exec(const Resources& res) const
   TSMLoc field_loc, tmp;
 
   if (res.bufp && res.hdr_loc) {
-    TSDebug(PLUGIN_NAME, "OperatorRMHeader::exec() invoked on header %s", _header.c_str());
+    TSLogDebug("OperatorRMHeader::exec() invoked on header %s", _header.c_str());
     field_loc = TSMimeHdrFieldFind(res.bufp, res.hdr_loc, _header.c_str(), _header.size());
     while (field_loc) {
-      TSDebug(PLUGIN_NAME, "\tdeleting header %s", _header.c_str());
+      TSLogDebug("\tdeleting header %s", _header.c_str());
       tmp = TSMimeHdrFieldNextDup(res.bufp, res.hdr_loc, field_loc);
       TSMimeHdrFieldDestroy(res.bufp, res.hdr_loc, field_loc);
       TSHandleMLocRelease(res.bufp, res.hdr_loc, field_loc);
@@ -66,7 +66,7 @@ OperatorSetStatus::initialize(Parser& p) {
   _status.set_value(p.get_arg());
 
   if (NULL == (_reason = TSHttpHdrReasonLookup((TSHttpStatus)_status.get_int_value()))) {
-    TSError("header_rewrite: unknown status %d", _status.get_int_value());
+    TSLogError("unknown status %d", _status.get_int_value());
     _reason_len = 0;
   } else {
     _reason_len = strlen(_reason);
@@ -120,7 +120,7 @@ OperatorSetStatusReason::exec(const Resources& res) const {
 
     _reason.append_value(reason, res);
     if (reason.size() > 0) {
-      TSDebug(PLUGIN_NAME, "Setting Status Reason to %s", reason.c_str());
+      TSLogDebug("Setting Status Reason to %s", reason.c_str());
       TSHttpHdrReasonSet(res.bufp, res.hdr_loc, reason.c_str(), reason.size());
     }
   }
@@ -153,17 +153,17 @@ OperatorAddHeader::exec(const Resources& res) const
 
   // Never set an empty header (I don't think that ever makes sense?)
   if (value.empty()) {
-    TSDebug(PLUGIN_NAME, "Would set header %s to an empty value, skipping", _header.c_str());
+    TSLogDebug("Would set header %s to an empty value, skipping", _header.c_str());
     return;
   }
   
   if (res.bufp && res.hdr_loc) {
-    TSDebug(PLUGIN_NAME, "OperatorAddHeader::exec() invoked on header %s: %s", _header.c_str(), value.c_str());
+    TSLogDebug("OperatorAddHeader::exec() invoked on header %s: %s", _header.c_str(), value.c_str());
     TSMLoc field_loc;
     
     if (TS_SUCCESS == TSMimeHdrFieldCreateNamed(res.bufp, res.hdr_loc, _header.c_str(), _header.size(), &field_loc)) {
       if (TS_SUCCESS == TSMimeHdrFieldValueStringInsert(res.bufp, res.hdr_loc, field_loc, -1, value.c_str(), value.size())) {
-        TSDebug(PLUGIN_NAME, "   adding header %s", _header.c_str());
+        TSLogDebug("   adding header %s", _header.c_str());
         //INKHttpHdrPrint(res.bufp, res.hdr_loc, reqBuff);
         TSMimeHdrFieldAppend(res.bufp, res.hdr_loc, field_loc);
       }
@@ -198,35 +198,35 @@ OperatorSetDestination::exec(const Resources& res) const
     case URL_QUAL_HOST:
       _value.append_value(value, res);
       if (value.empty()) {
-        TSDebug(PLUGIN_NAME, "Would set destination HOST to an empty value, skipping");
+        TSLogDebug("Would set destination HOST to an empty value, skipping");
       } else {
         const_cast<Resources&>(res).changed_url = true;
         TSUrlHostSet(res._rri->requestBufp, res._rri->requestUrl, value.c_str(), value.size());
-        TSDebug(PLUGIN_NAME, "OperatorSetHost::exec() invoked with HOST: %s", value.c_str());
+        TSLogDebug("OperatorSetHost::exec() invoked with HOST: %s", value.c_str());
       }
       break;
 
     case URL_QUAL_PATH:
       _value.append_value(value, res);
       if (value.empty()) {
-        TSDebug(PLUGIN_NAME, "Would set destination PATH to an empty value, skipping");
+        TSLogDebug("Would set destination PATH to an empty value, skipping");
       } else {
         const_cast<Resources&>(res).changed_url = true;
         TSUrlPathSet(res._rri->requestBufp, res._rri->requestUrl, value.c_str(), value.size());
-        TSDebug(PLUGIN_NAME, "OperatorSetHost::exec() invoked with PATH: %s", value.c_str());
+        TSLogDebug("OperatorSetHost::exec() invoked with PATH: %s", value.c_str());
       }
       break;
 
     case URL_QUAL_QUERY:
       _value.append_value(value, res);
       if (value.empty()) {
-        TSDebug(PLUGIN_NAME, "Would set destination QUERY to an empty value, skipping");
+        TSLogDebug("Would set destination QUERY to an empty value, skipping");
       } else {
         //1.6.4--Support for preserving QSA in case of set-destination
         if (get_oper_modifiers() & OPER_QSA) {
           int query_len = 0;
           const char* query = TSUrlHttpQueryGet(res._rri->requestBufp, res._rri->requestUrl, &query_len);
-          TSDebug(PLUGIN_NAME, "QSA mode, append original query string: %.*s", query_len, query);
+          TSLogDebug("QSA mode, append original query string: %.*s", query_len, query);
           //std::string connector = (value.find("?") == std::string::npos)? "?" : "&";
           value.append("&");
           value.append(query, query_len);
@@ -234,17 +234,17 @@ OperatorSetDestination::exec(const Resources& res) const
 
         const_cast<Resources&>(res).changed_url = true;
         TSUrlHttpQuerySet(res._rri->requestBufp, res._rri->requestUrl, value.c_str(), value.size());
-        TSDebug(PLUGIN_NAME, "OperatorSetHost::exec() invoked with QUERY: %s", value.c_str());
+        TSLogDebug("OperatorSetHost::exec() invoked with QUERY: %s", value.c_str());
       }
       break;
 
     case URL_QUAL_PORT:
       if (_value.get_int_value() <= 0) {
-        TSDebug(PLUGIN_NAME, "Would set destination PORT to an invalid range, skipping");
+        TSLogDebug("Would set destination PORT to an invalid range, skipping");
       } else {
         const_cast<Resources&>(res).changed_url = true;
         TSUrlPortSet(res._rri->requestBufp, res._rri->requestUrl, _value.get_int_value());
-        TSDebug(PLUGIN_NAME, "OperatorSetHost::exec() invoked with PORT: %d", _value.get_int_value());
+        TSLogDebug("OperatorSetHost::exec() invoked with PORT: %d", _value.get_int_value());
       }
       break;
     case URL_QUAL_URL:
@@ -270,7 +270,7 @@ OperatorSetRedirect::initialize(Parser& p) {
 
   if ((_status.get_int_value() != (int)TS_HTTP_STATUS_MOVED_PERMANENTLY) &&
       (_status.get_int_value() != (int)TS_HTTP_STATUS_MOVED_TEMPORARILY)) {
-    TSError("header_rewrite: unsupported redirect status %d", _status.get_int_value());
+    TSLogError("Unsupported redirect status %d", _status.get_int_value());
   }
 
   require_resources(RSRC_SERVER_RESPONSE_HEADERS);
@@ -296,7 +296,7 @@ OperatorSetRedirect::exec(const Resources& res) const
           int path_len = 0;
           const char *path = TSUrlPathGet(res._rri->requestBufp, res._rri->requestUrl, &path_len);
           if (path_len > 0) {
-            TSDebug(PLUGIN_NAME, "Find %%{PATH} in redirect url, replace it with: %.*s", path_len, path);
+            TSLogDebug("Find %%{PATH} in redirect url, replace it with: %.*s", path_len, path);
             value.insert(pos_path, path, path_len);
           }
       }
@@ -305,7 +305,7 @@ OperatorSetRedirect::exec(const Resources& res) const
       int query_len = 0;
       const char *query = TSUrlHttpQueryGet(res._rri->requestBufp, res._rri->requestUrl, &query_len);
       if ((get_oper_modifiers() & OPER_QSA) && (query_len > 0)) {
-          TSDebug(PLUGIN_NAME, "QSA mode, append original query string: %.*s", query_len, query);
+          TSLogDebug("QSA mode, append original query string: %.*s", query_len, query);
           std::string connector = (value.find("?") == std::string::npos)? "?" : "&";
           value.append(connector);
           value.append(query, query_len);
@@ -316,7 +316,7 @@ OperatorSetRedirect::exec(const Resources& res) const
       const char *start = value.c_str();
       const char *end = value.size() + start;
       TSUrlParse(res._rri->requestBufp, res._rri->requestUrl, &start, end);
-      TSDebug(PLUGIN_NAME, "OperatorSetRedirect::exec() invoked with destination=%s and status code=%d", 
+      TSLogDebug("OperatorSetRedirect::exec() invoked with destination=%s and status code=%d", 
               value.c_str(), _status.get_int_value());
     }
     
@@ -341,7 +341,7 @@ OperatorSetTimeoutOut::initialize(Parser& p) {
     _type = TO_OUT_DNS;
   } else {
     _type = TO_OUT_UNDEFINED;
-    TSError("header_rewrite: unsupported timeout qualifier: %s", p.get_arg().c_str());
+    TSLogError("unsupported timeout qualifier: %s", p.get_arg().c_str());
   }
 
   _timeout.set_value(p.get_value());
@@ -353,26 +353,26 @@ OperatorSetTimeoutOut::exec(const Resources& res) const
 {
   switch (_type) {
   case TO_OUT_ACTIVE:
-    TSDebug(PLUGIN_NAME, "OperatorSetTimeoutOut::exec(active, %d)", _timeout.get_int_value());
+    TSLogDebug("OperatorSetTimeoutOut::exec(active, %d)", _timeout.get_int_value());
     TSHttpTxnActiveTimeoutSet(res.txnp, _timeout.get_int_value());
     break;
 
   case TO_OUT_INACTIVE:
-    TSDebug(PLUGIN_NAME, "OperatorSetTimeoutOut::exec(inactive, %d)", _timeout.get_int_value());
+    TSLogDebug("OperatorSetTimeoutOut::exec(inactive, %d)", _timeout.get_int_value());
     TSHttpTxnNoActivityTimeoutSet(res.txnp, _timeout.get_int_value());
     break;
 
   case TO_OUT_CONNECT:
-    TSDebug(PLUGIN_NAME, "OperatorSetTimeoutOut::exec(connect, %d)", _timeout.get_int_value());
+    TSLogDebug("OperatorSetTimeoutOut::exec(connect, %d)", _timeout.get_int_value());
     TSHttpTxnConnectTimeoutSet(res.txnp, _timeout.get_int_value());
     break;
 
   case TO_OUT_DNS:
-    TSDebug(PLUGIN_NAME, "OperatorSetTimeoutOut::exec(dns, %d)", _timeout.get_int_value());
+    TSLogDebug("OperatorSetTimeoutOut::exec(dns, %d)", _timeout.get_int_value());
     TSHttpTxnDNSTimeoutSet(res.txnp, _timeout.get_int_value());
     break;
   default:
-    TSError("header_rewrite: unsupported timeout");
+    TSLogError("unsupported timeout");
     break;
   }
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/operators.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/operators.h b/plugins/header_rewrite/operators.h
index f43858f..b54732e 100644
--- a/plugins/header_rewrite/operators.h
+++ b/plugins/header_rewrite/operators.h
@@ -39,7 +39,7 @@ public:
   OperatorRMHeader()
     : _header("")
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for OperatorRMHeader");
+    TSLogDebug("Calling CTOR for OperatorRMHeader");
   }
   void initialize(Parser& p);
 
@@ -59,7 +59,7 @@ public:
   OperatorSetStatus()
     : _reason(NULL), _reason_len(0)
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for OperatorSetStatus");
+    TSLogDebug("Calling CTOR for OperatorSetStatus");
   }
   void initialize(Parser& p);
 
@@ -81,7 +81,7 @@ class OperatorSetStatusReason : public Operator
 public:
   OperatorSetStatusReason()
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for OperatorSetStatusReason");
+    TSLogDebug("Calling CTOR for OperatorSetStatusReason");
   }
   void initialize(Parser& p);
 
@@ -102,7 +102,7 @@ public:
   OperatorAddHeader()
     : _header("")
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for OperatorAddHeader");
+    TSLogDebug("Calling CTOR for OperatorAddHeader");
   }
   void initialize(Parser& p);
 
@@ -123,7 +123,7 @@ public:
   OperatorSetDestination()
     : _url_qual(URL_QUAL_NONE)
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for OperatorSetDestination");
+    TSLogDebug("Calling CTOR for OperatorSetDestination");
   }
   void initialize(Parser& p);
 
@@ -143,7 +143,7 @@ class OperatorSetRedirect : public Operator
 public:
   OperatorSetRedirect()
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for OperatorSetRedirect");
+    TSLogDebug("Calling CTOR for OperatorSetRedirect");
   }
   void initialize(Parser& p);
 
@@ -163,7 +163,7 @@ class OperatorNoOp : public Operator
 public:
   OperatorNoOp()
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for OperatorNoOp");
+    TSLogDebug("Calling CTOR for OperatorNoOp");
   }
 
 protected:
@@ -180,7 +180,7 @@ public:
   OperatorSetTimeoutOut()
     : _type(TO_OUT_UNDEFINED)
   {
-    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for OperatorSetTimeoutOut");
+    TSLogDebug("Calling CTOR for OperatorSetTimeoutOut");
   }
   void initialize(Parser& p);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42306ff7/plugins/header_rewrite/parser.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/parser.cc b/plugins/header_rewrite/parser.cc
index f354422..81db2a2 100644
--- a/plugins/header_rewrite/parser.cc
+++ b/plugins/header_rewrite/parser.cc
@@ -54,7 +54,7 @@ Parser::preprocess(std::vector<std::string>& tokens)
       else
         _arg = "";
     } else {
-      TSError("header_rewrite: conditions must be embraced in %%{}");
+      TSLogError("Conditions must be embraced in %%{}");
       return;
     }
   } else {
@@ -87,7 +87,7 @@ Parser::preprocess(std::vector<std::string>& tokens)
         }
       } else {
         // Syntax error
-        TSError("header_rewrite: mods have to be embraced in []");
+        TSLogError("mods have to be embraced in []");
         return;
       }
     }
@@ -98,7 +98,7 @@ Parser::preprocess(std::vector<std::string>& tokens)
 Parser::Parser(const std::string& line) :
   _cond(false), _empty(false)
 {
-  TSDebug("header_rewrite_dbg", "Calling CTOR for Parser");
+  TSLogDebug("Calling CTOR for Parser");
 
   if (line[0] == '#') {
     _empty = true;


[5/5] git commit: TS-2106: transform all plugins to new logging non-API

Posted by ig...@apache.org.
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....@brainsware.org>
Authored: Thu Aug 8 18:05:36 2013 +0200
Committer: Igor Galić <i....@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);
 }