trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iga...@apache.org
Subject [4/5] TS-2106: transform all plugins to new logging non-API
Date Sun, 11 Aug 2013 18:31:22 GMT
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);


Mime
View raw message