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/08 19:46:56 UTC

[01/15] git commit: transform libloader to new logging non-API

Updated Branches:
  refs/heads/consistent-gzip-error-msgs [created] 891ada6c7


transform libloader to new logging non-API


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: 0e3ed88c1c05b152bcbc7ec94a9dba193bf1a16f
Parents: 9800aa9
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 19:18:10 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:39:03 2013 +0200

----------------------------------------------------------------------
 plugins/libloader/libloader.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0e3ed88c/plugins/libloader/libloader.c
----------------------------------------------------------------------
diff --git a/plugins/libloader/libloader.c b/plugins/libloader/libloader.c
index ef84c2f..ff0268b 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(i"loaded %s", lib);
         }
         else {
-            TSError("[libloader] failed to load %s: %s\n", lib, dlerror());
+            TSLogError("Failed to load %s: %s", lib, dlerror());
         }
     }
     return;


[03/15] git commit: transform cacheurl to new logging non-API

Posted by ig...@apache.org.
transform cacheurl to new logging non-API


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: 10ff0adc1293f6994a53f7ec5fa88c4bbee44263
Parents: 889ae2e
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 18:05:36 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:39:03 2013 +0200

----------------------------------------------------------------------
 plugins/cacheurl/cacheurl.c | 61 ++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/10ff0adc/plugins/cacheurl/cacheurl.c
----------------------------------------------------------------------
diff --git a/plugins/cacheurl/cacheurl.c b/plugins/cacheurl/cacheurl.c
index 7b28d7d..fca6df4 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;
         }
 
@@ -266,17 +261,15 @@ static pr_list* load_config_file(const char *config_file) {
                     "Adding pattern/replacement pair: '%s' -> '%s'",
                     buffer, spend);
         }
-        TSDebug(PLUGIN_NAME, "Adding pattern/replacement pair: '%s' -> '%s'\n",
+        TSDebug(
                 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 +295,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 +312,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 +350,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 +388,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 +402,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 +444,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");
         }
     }
 


[10/15] git commit: use C99's __func__.

Posted by ig...@apache.org.
use C99's __func__.


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: d2c4a27a13c63466f309bc3564adc50117c0a7d3
Parents: f12bd8c
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 17:30:18 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:39:03 2013 +0200

----------------------------------------------------------------------
 proxy/api/ts/ts-debug.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d2c4a27a/proxy/api/ts/ts-debug.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts-debug.h b/proxy/api/ts/ts-debug.h
index e5a4f9d..7e0854e 100644
--- a/proxy/api/ts/ts-debug.h
+++ b/proxy/api/ts/ts-debug.h
@@ -43,7 +43,7 @@
 #else
 
 #define TSLogDebug(fmt, args...) do {                                    \
-  TSDebug(PLUGIN_NAME, "DEBUG: [%s:%d] [%s] " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+  TSDebug(PLUGIN_NAME, "DEBUG: [%s:%d] [%s] " fmt, __FILE__, __LINE__, __func__ , ##args ); \
   } while (0)
 
 #define TSLogInfo(fmt, args...) do {                                    \
@@ -55,14 +55,14 @@
 } while (0)
 
 #define TSLogError(fmt, args...) do {                                    \
-  TSError("[%s] [%s:%d] [%s] ERROR: " fmt, PLUGIN_NAME, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
-  TSDebug(PLUGIN_NAME, "[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+  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__, __FUNCTION__ , ##args ); \
-  TSDebug(PLUGIN_NAME, "[%s:%d] [%s] FATAL: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+  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)
 


[09/15] git commit: rename api

Posted by ig...@apache.org.
rename api


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: f12bd8c13eab772dc1667ac3eb0471b5d4f02b19
Parents: 872afee
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 17:22:53 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:39:03 2013 +0200

----------------------------------------------------------------------
 plugins/gzip/configuration.cc | 12 +++----
 plugins/gzip/gzip.cc          | 74 +++++++++++++++++++-------------------
 plugins/gzip/misc.cc          | 12 +++----
 3 files changed, 49 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f12bd8c1/plugins/gzip/configuration.cc
----------------------------------------------------------------------
diff --git a/plugins/gzip/configuration.cc b/plugins/gzip/configuration.cc
index f1ca18d..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 ) {
-        TSPluginInfo("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 ) {
-        TSPluginInfo("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();
-    TSPluginInfo("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()) {
-      TSPluginWarning("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 {
-            TSPluginWarning("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) {
-      TSPluginWarning("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/f12bd8c1/plugins/gzip/gzip.cc
----------------------------------------------------------------------
diff --git a/plugins/gzip/gzip.cc b/plugins/gzip/gzip.cc
index 68d1351..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) {
-    TSPluginFatal("gzip-transform: deflateInit (%d)!", err);
+    TSLogFatal("gzip-transform: deflateInit (%d)!", err);
   }
 
   if (dictionary) {
     err = deflateSetDictionary(&data->zstrm, (const Bytef *) dictionary, strlen(dictionary));
     if (err != Z_OK) {
-      TSPluginFatal("gzip-transform: 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) {
-    TSPluginError("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) {
-    TSPluginError("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) {
-    TSPluginError("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) {
-    TSPluginError("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) {
-      TSPluginError("could not get from IOBufferBlock");
+      TSLogError("could not get from IOBufferBlock");
       return;
     }
 
     upstream_buffer = TSIOBufferBlockReadStart(downstream_blkp, upstream_reader, &upstream_length);
     if (!upstream_buffer) {
-      TSPluginError("could not 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)
-        TSPluginWarning("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) {
-          TSPluginError("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) {
-        TSPluginWarning("deflate should report Z_STREAM_END");
+        TSLogWarning("deflate should report Z_STREAM_END");
       }
       break;
     }
 
     if (data->downstream_length != (int64_t) (data->zstrm.total_out)) {
-      TSPluginError("gzip-transform: 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:{
-        TSPluginDebug("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:
-      TSPluginWarning("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)) {
-    TSPluginInfo("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)) {
-    TSPluginDebug("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) {
-      TSPluginInfo("no acceptable encoding found in request header, not compressible");
+      TSLogInfo("no acceptable encoding found in request header, not compressible");
       return 0;
     }
   } else {
-    TSPluginInfo("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) {
-    TSPluginInfo("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) {
-    TSPluginInfo("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) { 
-    TSPluginInfo("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
-    TSPluginDebug("transform hook already set, bail");
+    TSLogDebug("transform hook already set, bail");
     return;
   } else {
     TSHttpTxnArgSet(txnp, arg_idx_hooked, (void *) &GZIP_ONE);
-    TSPluginInfo("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) {
-    TSPluginWarning("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) {
-    TSPluginInfo("stale cache hit");
+    TSLogInfo("stale cache hit");
     return 0;
   }
   if (obj_status == TS_CACHE_LOOKUP_HIT_FRESH) {
-    TSPluginInfo("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);
-            TSPluginInfo("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:
-      TSPluginFatal("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);
-  TSPluginDebug("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);
-  TSPluginInfo("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)  {
-    TSPluginFatal("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]);
   }
 
-  TSPluginInfo("TSPluginInit %s", argv[0]);
+  TSLogInfo("TSPluginInit %s", argv[0]);
 
   if (!register_plugin()) {
-    TSPluginFatal("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) {
-    TSPluginFatal("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) {
-    TSPluginFatal("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) {
-    TSPluginFatal("failed to reserve an argument index");
+    TSLogFatal("failed to reserve an argument index");
   }
 
   global_hidden_header_name = init_hidden_header_name();
@@ -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);
 
-  TSPluginInfo("loaded");
+  TSLogInfo("loaded");
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f12bd8c1/plugins/gzip/misc.cc
----------------------------------------------------------------------
diff --git a/plugins/gzip/misc.cc b/plugins/gzip/misc.cc
index e3dd4d3..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"));
-      TSPluginInfo("normalized accept encoding to gzip");
+      TSLogInfo("normalized accept encoding to gzip");
     } else if (deflate) {
       TSMimeHdrFieldValueStringInsert(reqp, hdr_loc, field, -1, "deflate", strlen("deflate"));
-      TSPluginInfo("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) {
-    TSPluginFatal("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) {
-    TSPluginFatal("gzip-transform: 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) {
-    TSPluginInfo("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 {
-    TSPluginDebug("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);
   }
 }


[15/15] git commit: transform libloader to new logging non-API - fix typo

Posted by ig...@apache.org.
transform libloader to new logging non-API - fix typo


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: 891ada6c72e50de7fcf733b937f93b460c382075
Parents: 0e3ed88
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 19:45:42 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:45:42 2013 +0200

----------------------------------------------------------------------
 plugins/libloader/libloader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/891ada6c/plugins/libloader/libloader.c
----------------------------------------------------------------------
diff --git a/plugins/libloader/libloader.c b/plugins/libloader/libloader.c
index ff0268b..acf8373 100644
--- a/plugins/libloader/libloader.c
+++ b/plugins/libloader/libloader.c
@@ -78,7 +78,7 @@ void TSPluginInit(int argc, const char *argv[])
             l->handle = handle;
             l->next = libs;
             libs = l;
-            TSLogDebug(i"loaded %s", lib);
+            TSLogDebug("loaded %s", lib);
         }
         else {
             TSLogError("Failed to load %s: %s", lib, dlerror());


[05/15] git commit: steal "api" from gzip plugin

Posted by ig...@apache.org.
steal "api" from gzip plugin


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: 4c57a1f3b599ab13700a025bc997ac247b6044c4
Parents: c8725ba
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 15:58:43 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:39:03 2013 +0200

----------------------------------------------------------------------
 plugins/gzip/debug_macros.h | 27 ++-------------------------
 proxy/api/ts/ts.h.in        | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4c57a1f3/plugins/gzip/debug_macros.h
----------------------------------------------------------------------
diff --git a/plugins/gzip/debug_macros.h b/plugins/gzip/debug_macros.h
index 151de31..858d749 100644
--- a/plugins/gzip/debug_macros.h
+++ b/plugins/gzip/debug_macros.h
@@ -24,32 +24,9 @@
 #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 PLUGIN_NAME "gzip"
 
-#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)
+#include <ts/ts.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/4c57a1f3/proxy/api/ts/ts.h.in
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h.in b/proxy/api/ts/ts.h.in
index 3379a26..7bd2453 100644
--- a/proxy/api/ts/ts.h.in
+++ b/proxy/api/ts/ts.h.in
@@ -1300,6 +1300,29 @@ extern "C"
   */
   tsapi void TSError(const char* fmt, ...) TS_PRINTFLIKE(1, 2);
 
+#define TSPluginDebug(fmt, args...) do {                                    \
+  TSDebug(PLUGIN_NAME, "DEBUG: [%s:%d] [%s] " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+  } while (0)
+
+#define TSPluginInfo(fmt, args...) do {                                    \
+  TSDebugSpecific(PLUGIN_NAME, "INFO: " fmt, ##args ); \
+  } while (0)
+
+#define TSPluginWarning(fmt, args...) do {                                    \
+  TSDebugSpecific(PLUGIN_NAME, "WARNING: " fmt, ##args ); \
+} while (0)
+
+#define TSPluginError(fmt, args...) do {                                    \
+  TSError("[%s] [%s:%d] [%s] ERROR: " fmt, PLUGIN_NAME, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+  TSDebugSpecific(PLUGIN_NAME, "[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+} while (0)
+
+#define TSPluginFatal(fmt, args...) do {                                    \
+  TSError("[%s] [%s:%d] [%s] FATAL: " fmt, PLUGIN_NAME, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+  TSDebugSpecific(PLUGIN_NAME, "[%s:%d] [%s] FATAL: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+  exit(-1); \
+} while (0)
+
   /* --------------------------------------------------------------------------
      Assertions */
   tsapi void _TSReleaseAssert(const char* txt, const char* f, int l) TS_NORETURN;


[13/15] git commit: rename to debug.h

Posted by ig...@apache.org.
rename to debug.h


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: 889ae2e8b4943138b66282d6f0bbb3856ebd7346
Parents: d2c4a27
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 17:39:01 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:39:03 2013 +0200

----------------------------------------------------------------------
 plugins/gzip/debug_macros.h |  3 +-
 proxy/api/ts/debug.h        | 71 ++++++++++++++++++++++++++++++++++++++++
 proxy/api/ts/ts-debug.h     | 71 ----------------------------------------
 3 files changed, 72 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/889ae2e8/plugins/gzip/debug_macros.h
----------------------------------------------------------------------
diff --git a/plugins/gzip/debug_macros.h b/plugins/gzip/debug_macros.h
index b9905be..084c788 100644
--- a/plugins/gzip/debug_macros.h
+++ b/plugins/gzip/debug_macros.h
@@ -25,8 +25,7 @@
 #define _DBG_MACROS_H
 
 #define PLUGIN_NAME "gzip"
-
-#include <ts/ts-debug.h>
+#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/889ae2e8/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/889ae2e8/proxy/api/ts/ts-debug.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts-debug.h b/proxy/api/ts/ts-debug.h
deleted file mode 100644
index 7e0854e..0000000
--- a/proxy/api/ts/ts-debug.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/** @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__ */
-


[12/15] git commit: transform header_filter to new logging non-API

Posted by ig...@apache.org.
transform header_filter to new logging non-API


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: 4e5cfae7662ea9bd8ff4bffcb89a30ce2475d697
Parents: 065644e
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 18:25:54 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:39:03 2013 +0200

----------------------------------------------------------------------
 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 ++++----
 4 files changed, 26 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


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


[04/15] git commit: don't use TSPluginSpecific

Posted by ig...@apache.org.
don't use TSPluginSpecific

because we're don't want to depend on a txn we don't have access to as
well as a hyptothetical PLUGIN_NAME


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: 6d10294ae5116432555a66ddc9c99eb3925418af
Parents: 4c57a1f
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 16:22:33 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:39:03 2013 +0200

----------------------------------------------------------------------
 proxy/api/ts/ts.h.in | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6d10294a/proxy/api/ts/ts.h.in
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h.in b/proxy/api/ts/ts.h.in
index 7bd2453..05f2fe5 100644
--- a/proxy/api/ts/ts.h.in
+++ b/proxy/api/ts/ts.h.in
@@ -1305,21 +1305,21 @@ extern "C"
   } while (0)
 
 #define TSPluginInfo(fmt, args...) do {                                    \
-  TSDebugSpecific(PLUGIN_NAME, "INFO: " fmt, ##args ); \
+  TSDebug(PLUGIN_NAME, "INFO: " fmt, ##args ); \
   } while (0)
 
 #define TSPluginWarning(fmt, args...) do {                                    \
-  TSDebugSpecific(PLUGIN_NAME, "WARNING: " fmt, ##args ); \
+  TSDebug(PLUGIN_NAME, "WARNING: " fmt, ##args ); \
 } while (0)
 
 #define TSPluginError(fmt, args...) do {                                    \
   TSError("[%s] [%s:%d] [%s] ERROR: " fmt, PLUGIN_NAME, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
-  TSDebugSpecific(PLUGIN_NAME, "[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+  TSDebug(PLUGIN_NAME, "[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
 } while (0)
 
 #define TSPluginFatal(fmt, args...) do {                                    \
   TSError("[%s] [%s:%d] [%s] FATAL: " fmt, PLUGIN_NAME, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
-  TSDebugSpecific(PLUGIN_NAME, "[%s:%d] [%s] FATAL: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+  TSDebug(PLUGIN_NAME, "[%s:%d] [%s] FATAL: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
   exit(-1); \
 } while (0)
 


[14/15] git commit: transform conf_remap to new logging non-API

Posted by ig...@apache.org.
transform conf_remap to new logging non-API


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: 065644e409f27e7385a7f1390824d3a12eee3e40
Parents: 04ccc82
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 18:12:06 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:39:03 2013 +0200

----------------------------------------------------------------------
 plugins/conf_remap/conf_remap.cc | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/065644e4/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 ?


[11/15] git commit: make cacheurl compile ;)

Posted by ig...@apache.org.
make cacheurl compile ;)


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: 04ccc8221fe339881c8d7f858ee040dee2514da3
Parents: 10ff0ad
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 18:07:35 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:39:03 2013 +0200

----------------------------------------------------------------------
 plugins/cacheurl/cacheurl.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04ccc822/plugins/cacheurl/cacheurl.c
----------------------------------------------------------------------
diff --git a/plugins/cacheurl/cacheurl.c b/plugins/cacheurl/cacheurl.c
index fca6df4..db165d5 100644
--- a/plugins/cacheurl/cacheurl.c
+++ b/plugins/cacheurl/cacheurl.c
@@ -257,12 +257,9 @@ 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(
-                buffer, spend);
+        TSDebug("Adding pattern/replacement pair: '%s' -> '%s'\n", buffer, spend);
         retval = regex_compile(&info, buffer, spend);
         if (!retval) {
             TSLogError("Unable to precompile regex/replacement. Skipping.");


[06/15] git commit: missed a few

Posted by ig...@apache.org.
missed a few


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: 09a33a4f0a22b1e6a1f1beeed687a15838085d98
Parents: 6d10294
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 16:23:35 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:39:03 2013 +0200

----------------------------------------------------------------------
 plugins/gzip/configuration.cc | 12 +++---
 plugins/gzip/gzip.cc          | 76 +++++++++++++++++++-------------------
 plugins/gzip/misc.cc          | 12 +++---
 3 files changed, 50 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/09a33a4f/plugins/gzip/configuration.cc
----------------------------------------------------------------------
diff --git a/plugins/gzip/configuration.cc b/plugins/gzip/configuration.cc
index 5e69c5c..f1ca18d 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]",
+        TSPluginInfo("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]",
+        TSPluginInfo("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);
+    TSPluginInfo("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);
+      TSPluginWarning("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);
+            TSPluginWarning("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);
+      TSPluginWarning("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/09a33a4f/plugins/gzip/gzip.cc
----------------------------------------------------------------------
diff --git a/plugins/gzip/gzip.cc b/plugins/gzip/gzip.cc
index 9c84dc8..68d1351 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);
+    TSPluginFatal("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);
+      TSPluginFatal("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");
+    TSPluginError("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");
+    TSPluginError("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);
+    TSPluginError("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");
+    TSPluginError("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");
+      TSPluginError("could not get from IOBufferBlock");
       return;
     }
 
     upstream_buffer = TSIOBufferBlockReadStart(downstream_blkp, upstream_reader, &upstream_length);
     if (!upstream_buffer) {
-      error("couldn't get from TSIOBufferBlockReadStart");
+      TSPluginError("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);
+        TSPluginWarning("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);
+          TSPluginError("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");
+        TSPluginWarning("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,
+      TSPluginError("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");
+        TSPluginDebug("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);
+      TSPluginWarning("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);
+    TSPluginInfo("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");
+    TSPluginDebug("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");
+      TSPluginInfo("no acceptable encoding found in request header, not compressible");
       return 0;
     }
   } else {
-    info("no acceptable encoding found in request header, not compressible");
+    TSPluginInfo("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");
+    TSPluginInfo("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");
+    TSPluginInfo("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);
+    TSPluginInfo("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");
+    TSPluginDebug("transform hook already set, bail");
     return;
   } else {
     TSHttpTxnArgSet(txnp, arg_idx_hooked, (void *) &GZIP_ONE);
-    info("adding compression transform");
+    TSPluginInfo("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");
+    TSPluginWarning("Couldn't get cache status of object");
     return 0;
   }
   if (obj_status == TS_CACHE_LOOKUP_HIT_STALE) {
-    info("stale cache hit");
+    TSPluginInfo("stale cache hit");
     return 0;
   }
   if (obj_status == TS_CACHE_LOOKUP_HIT_FRESH) {
-    info("fresh cache hit");
+    TSPluginInfo("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);
+            TSPluginInfo("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");
+      TSPluginFatal("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);
+  TSPluginDebug("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");
+  TSPluginInfo("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");
+    TSPluginFatal("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]);
+  TSPluginInfo("TSPluginInit %s", argv[0]);
 
   if (!register_plugin()) {
-    fatal("The gzip plugin failed to register");
+    TSPluginFatal("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");
+    TSPluginFatal("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");
+    TSPluginFatal("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");
+    TSPluginFatal("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");
+  TSPluginInfo("loaded");
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/09a33a4f/plugins/gzip/misc.cc
----------------------------------------------------------------------
diff --git a/plugins/gzip/misc.cc b/plugins/gzip/misc.cc
index 13f9d39..e3dd4d3 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");
+      TSPluginInfo("normalized accept encoding to gzip");
     } else if (deflate) {
       TSMimeHdrFieldValueStringInsert(reqp, hdr_loc, field, -1, "deflate", strlen("deflate"));
-      info("normalized accept encoding to deflate");
+      TSPluginInfo("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");
+    TSPluginFatal("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);
+    TSPluginFatal("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));
+    TSPluginInfo("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);
+    TSPluginDebug("Compressed size %" PRId64" (bytes), Original size %" PRId64", ratio: %f", out, in, 0.0F);
   }
 }


[02/15] git commit: transform header_rewrite to new logging non-API

Posted by ig...@apache.org.
transform header_rewrite to new logging non-API


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: 9800aa9219f87f8ea83faf4c9c1be56fdcbef571
Parents: 4e5cfae
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 19:10:57 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:39:03 2013 +0200

----------------------------------------------------------------------
 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 +-
 17 files changed, 121 insertions(+), 125 deletions(-)
----------------------------------------------------------------------


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

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


[08/15] git commit: Rename prefix to TSLog, add warning about usage

Posted by ig...@apache.org.
Rename prefix to TSLog, add warning about usage

these APIs are still "internal" until we figure out a better way of
presenting them to the outside world.


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: 872afee05bc8dadbe754bd2440aff44e0c887d69
Parents: c91e1c1
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 17:21:46 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:39:03 2013 +0200

----------------------------------------------------------------------
 proxy/api/ts/ts-debug.h | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/872afee0/proxy/api/ts/ts-debug.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts-debug.h b/proxy/api/ts/ts-debug.h
index dc1abda..e5a4f9d 100644
--- a/proxy/api/ts/ts-debug.h
+++ b/proxy/api/ts/ts-debug.h
@@ -31,31 +31,36 @@
 
 /** 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 TSPlugin(Debug|Info|Warning|Error|Fatal)"
+# 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 TSPluginDebug(fmt, args...) do {                                    \
+#define TSLogDebug(fmt, args...) do {                                    \
   TSDebug(PLUGIN_NAME, "DEBUG: [%s:%d] [%s] " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
   } while (0)
 
-#define TSPluginInfo(fmt, args...) do {                                    \
+#define TSLogInfo(fmt, args...) do {                                    \
   TSDebug(PLUGIN_NAME, "INFO: " fmt, ##args ); \
   } while (0)
 
-#define TSPluginWarning(fmt, args...) do {                                    \
+#define TSLogWarning(fmt, args...) do {                                    \
   TSDebug(PLUGIN_NAME, "WARNING: " fmt, ##args ); \
 } while (0)
 
-#define TSPluginError(fmt, args...) do {                                    \
+#define TSLogError(fmt, args...) do {                                    \
   TSError("[%s] [%s:%d] [%s] ERROR: " fmt, PLUGIN_NAME, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
   TSDebug(PLUGIN_NAME, "[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
 } while (0)
 #endif
 
-#define TSPluginFatal(fmt, args...) do {                                    \
+#define TSLogFatal(fmt, args...) do {                                    \
   TSError("[%s] [%s:%d] [%s] FATAL: " fmt, PLUGIN_NAME, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
   TSDebug(PLUGIN_NAME, "[%s:%d] [%s] FATAL: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
   exit(-1); \


[07/15] git commit: move APIs into ts/ts-debug.h

Posted by ig...@apache.org.
move APIs into ts/ts-debug.h

this way we don't pollute the main API and are able to issue an #error
when something's wrong (i.e.: no PLUGIN_NAME defined)


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: c91e1c11f1e387f52069eff6b15e25edaf281c7d
Parents: 09a33a4
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 17:03:51 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 19:39:03 2013 +0200

----------------------------------------------------------------------
 plugins/gzip/debug_macros.h |  2 +-
 proxy/api/ts/ts-debug.h     | 66 ++++++++++++++++++++++++++++++++++++++++
 proxy/api/ts/ts.h.in        | 22 --------------
 3 files changed, 67 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c91e1c11/plugins/gzip/debug_macros.h
----------------------------------------------------------------------
diff --git a/plugins/gzip/debug_macros.h b/plugins/gzip/debug_macros.h
index 858d749..b9905be 100644
--- a/plugins/gzip/debug_macros.h
+++ b/plugins/gzip/debug_macros.h
@@ -26,7 +26,7 @@
 
 #define PLUGIN_NAME "gzip"
 
-#include <ts/ts.h>
+#include <ts/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/c91e1c11/proxy/api/ts/ts-debug.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts-debug.h b/proxy/api/ts/ts-debug.h
new file mode 100644
index 0000000..dc1abda
--- /dev/null
+++ b/proxy/api/ts/ts-debug.h
@@ -0,0 +1,66 @@
+/** @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.
+ **/
+
+#ifndef PLUGIN_NAME
+# error "A plugin must define a PLUGIN_NAME string constant *before* including <ts/ts.h> in order to use TSPlugin(Debug|Info|Warning|Error|Fatal)"
+#else
+
+#define TSPluginDebug(fmt, args...) do {                                    \
+  TSDebug(PLUGIN_NAME, "DEBUG: [%s:%d] [%s] " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+  } while (0)
+
+#define TSPluginInfo(fmt, args...) do {                                    \
+  TSDebug(PLUGIN_NAME, "INFO: " fmt, ##args ); \
+  } while (0)
+
+#define TSPluginWarning(fmt, args...) do {                                    \
+  TSDebug(PLUGIN_NAME, "WARNING: " fmt, ##args ); \
+} while (0)
+
+#define TSPluginError(fmt, args...) do {                                    \
+  TSError("[%s] [%s:%d] [%s] ERROR: " fmt, PLUGIN_NAME, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+  TSDebug(PLUGIN_NAME, "[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+} while (0)
+#endif
+
+#define TSPluginFatal(fmt, args...) do {                                    \
+  TSError("[%s] [%s:%d] [%s] FATAL: " fmt, PLUGIN_NAME, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+  TSDebug(PLUGIN_NAME, "[%s:%d] [%s] FATAL: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
+  exit(-1); \
+} while (0)
+
+
+# endif /* __TS_DEBUG_H__ */
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c91e1c11/proxy/api/ts/ts.h.in
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h.in b/proxy/api/ts/ts.h.in
index 05f2fe5..7da91d7 100644
--- a/proxy/api/ts/ts.h.in
+++ b/proxy/api/ts/ts.h.in
@@ -1300,28 +1300,6 @@ extern "C"
   */
   tsapi void TSError(const char* fmt, ...) TS_PRINTFLIKE(1, 2);
 
-#define TSPluginDebug(fmt, args...) do {                                    \
-  TSDebug(PLUGIN_NAME, "DEBUG: [%s:%d] [%s] " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
-  } while (0)
-
-#define TSPluginInfo(fmt, args...) do {                                    \
-  TSDebug(PLUGIN_NAME, "INFO: " fmt, ##args ); \
-  } while (0)
-
-#define TSPluginWarning(fmt, args...) do {                                    \
-  TSDebug(PLUGIN_NAME, "WARNING: " fmt, ##args ); \
-} while (0)
-
-#define TSPluginError(fmt, args...) do {                                    \
-  TSError("[%s] [%s:%d] [%s] ERROR: " fmt, PLUGIN_NAME, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
-  TSDebug(PLUGIN_NAME, "[%s:%d] [%s] ERROR: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
-} while (0)
-
-#define TSPluginFatal(fmt, args...) do {                                    \
-  TSError("[%s] [%s:%d] [%s] FATAL: " fmt, PLUGIN_NAME, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
-  TSDebug(PLUGIN_NAME, "[%s:%d] [%s] FATAL: " fmt, __FILE__, __LINE__, __FUNCTION__ , ##args ); \
-  exit(-1); \
-} while (0)
 
   /* --------------------------------------------------------------------------
      Assertions */