You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ig...@apache.org on 2013/08/09 01:09:19 UTC

[07/13] git commit: transform geoip_acl to new logging non-API

transform geoip_acl to new logging non-API


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

Branch: refs/heads/consistent-gzip-error-msgs
Commit: e62f7d06ff3be6c45b046d4b4284547344d9a3dc
Parents: 7a13335
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Aug 8 23:18:04 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Aug 8 23:18:04 2013 +0200

----------------------------------------------------------------------
 plugins/experimental/geoip_acl/acl.cc       | 24 ++++++++++++------------
 plugins/experimental/geoip_acl/geoip_acl.cc | 10 +++++-----
 plugins/experimental/geoip_acl/lulu.h       |  3 ++-
 3 files changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e62f7d06/plugins/experimental/geoip_acl/acl.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/geoip_acl/acl.cc b/plugins/experimental/geoip_acl/acl.cc
index ad917d5..6067dc3 100644
--- a/plugins/experimental/geoip_acl/acl.cc
+++ b/plugins/experimental/geoip_acl/acl.cc
@@ -41,9 +41,9 @@ Acl::read_html(const char* fn)
   if (f.is_open()) {
     _html.append(std::istreambuf_iterator<char>(f), std::istreambuf_iterator<char>());
     f.close();
-    TSDebug(PLUGIN_NAME, "Loaded HTML from %s", fn);
+    TSLogDebug("Loaded HTML from %s", fn);
   } else {
-    TSError("Unable to open HTML file %s", fn);
+    TSLogError("Unable to open HTML file %s", fn);
   }
 }
 
@@ -75,7 +75,7 @@ RegexAcl::parse_line(const char* filename, const std::string& line, int lineno)
         else if (tmp == "deny")
           _acl->set_allow(false);
         else {
-          TSError("Bad action on in %s:line %d: %s", filename, lineno, tmp.c_str());
+          TSLogError("Bad action on in %s:line %d: %s", filename, lineno, tmp.c_str());
           return false;
         }
         // The rest are "tokens"
@@ -85,7 +85,7 @@ RegexAcl::parse_line(const char* filename, const std::string& line, int lineno)
           _acl->add_token(tmp);
         }
         compile(regex, filename, lineno);
-        TSDebug(PLUGIN_NAME, "Added regex rule for /%s/", regex.c_str());
+        TSLogDebug("Added regex rule for /%s/", regex.c_str());
         return true;
       }
     }
@@ -106,11 +106,11 @@ RegexAcl::compile(const std::string& str, const char* filename, int lineno)
   if (NULL != _rex) {
     _extra = pcre_study(_rex, 0, &error);
     if ((NULL == _extra) && error && (*error != 0)) {
-      TSError("Failed to study regular expression in %s:line %d at offset %d: %s\n", filename, lineno, erroffset, error);
+      TSLogError("Failed to study regular expression in %s:line %d at offset %d: %s\n", filename, lineno, erroffset, error);
       return false;
     }
   } else {
-    TSError("Failed to compile regular expression in %s:line %d: %s\n", filename, lineno, error);
+    TSLogError("Failed to compile regular expression in %s:line %d: %s\n", filename, lineno, error);
     return false;
   }
 
@@ -146,9 +146,9 @@ CountryAcl::add_token(const std::string& str)
 
   if (iso > 0 && iso < NUM_ISO_CODES) {
     _iso_country_codes[iso] = true;
-    TSDebug(PLUGIN_NAME, "Added %s(%d) to remap rule, ACL=%d", str.c_str(), iso, _allow);
+    TSLogDebug("Added %s(%d) to remap rule, ACL=%d", str.c_str(), iso, _allow);
   } else {
-    TSError("Tried setting an ISO code (%d) outside the supported range", iso);
+    TSLogError("Tried setting an ISO code (%d) outside the supported range", iso);
   }
 }
 
@@ -177,9 +177,9 @@ CountryAcl::read_regex(const char* fn)
       }
     }
     f.close();
-    TSDebug(PLUGIN_NAME, "Loaded regex rules from %s", fn);
+    TSLogDebug("Loaded regex rules from %s", fn);
   } else {
-    TSError("Unable to open regex file %s", fn);
+    TSLogError("Unable to open regex file %s", fn);
   }
 }
 
@@ -196,7 +196,7 @@ CountryAcl::eval(TSRemapRequestInfo *rri, TSHttpTxn txnp) const
 
     do {
       if (acl->match(path, path_len)) {
-        TSDebug(PLUGIN_NAME, "Path = %.*s matched /%s/", path_len, path, acl->get_regex().c_str());
+        TSLogDebug("Path = %.*s matched /%s/", path_len, path, acl->get_regex().c_str());
         return acl->eval(rri, txnp);
       }
     } while ((acl = acl->next()));
@@ -219,7 +219,7 @@ CountryAcl::eval(TSRemapRequestInfo *rri, TSHttpTxn txnp) const
       iso = GeoIP_id_by_ipnum(gGI, ip);
       if (TSIsDebugTagSet(PLUGIN_NAME)) {
         const char* c = GeoIP_country_code_by_ipnum(gGI, ip);
-        TSDebug(PLUGIN_NAME, "eval(): IP=%u seems to come from ISO=%d / %s", ip, iso, c);
+        TSLogDebug("eval(): IP=%u seems to come from ISO=%d / %s", ip, iso, c);
       }
     }
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e62f7d06/plugins/experimental/geoip_acl/geoip_acl.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/geoip_acl/geoip_acl.cc b/plugins/experimental/geoip_acl/geoip_acl.cc
index 3249ea4..4abf683 100644
--- a/plugins/experimental/geoip_acl/geoip_acl.cc
+++ b/plugins/experimental/geoip_acl/geoip_acl.cc
@@ -52,7 +52,7 @@ TSRemapInit(TSRemapInterface* api_info, char *errbuf, int errbuf_size)
   gGI = GeoIP_new(GEOIP_MMAP_CACHE);
 #endif
 
-  TSDebug(PLUGIN_NAME, "remap plugin is successfully initialized");
+  TSLogDebug("remap plugin is successfully initialized");
   return TS_SUCCESS;                     /* success */
 }
 
@@ -61,13 +61,13 @@ TSReturnCode
 TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf */, int /* errbuf_size */)
 {
   if (argc < 3) {
-    TSError("Unable to create remap instance, need more parameters");
+    TSLogError("Unable to create remap instance, need more parameters");
     return TS_ERROR;
   } else {
     Acl* a = NULL;
 
     if (!strncmp(argv[2], "country", 11)) {
-      TSDebug(PLUGIN_NAME, "creating an ACL rule with ISO country codes");
+      TSLogDebug("creating an ACL rule with ISO country codes");
       a = new CountryAcl();
     }
 
@@ -75,7 +75,7 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf */, int /*
       a->process_args(argc, argv);
       *ih = static_cast<void*>(a);
     } else {
-      TSError("Unable to create remap instance, no supported ACL specified as first parameter");
+      TSLogError("Unable to create remap instance, no supported ACL specified as first parameter");
       return TS_ERROR;
     }
   }
@@ -99,7 +99,7 @@ TSRemapStatus
 TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
 {
   if (NULL == ih) {
-    TSDebug(PLUGIN_NAME, "No ACLs configured, this is probably a plugin bug");
+    TSLogDebug("No ACLs configured, this is probably a plugin bug");
   } else {
     Acl* a = static_cast<Acl*>(ih);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e62f7d06/plugins/experimental/geoip_acl/lulu.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/geoip_acl/lulu.h b/plugins/experimental/geoip_acl/lulu.h
index acb154f..319000e 100644
--- a/plugins/experimental/geoip_acl/lulu.h
+++ b/plugins/experimental/geoip_acl/lulu.h
@@ -47,7 +47,8 @@
 #endif
 
 // Used for Debug etc.
-static const char* PLUGIN_NAME = "geoip_acl";
+#define PLUGIN_NAME "geoip_acl"
+#include <ts/debug.h>
 
 #endif // __LULU_H__