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:24 UTC

[12/13] git commit: transform esi to new logging non-API

transform esi 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/ea58dc2d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ea58dc2d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ea58dc2d

Branch: refs/heads/consistent-gzip-error-msgs
Commit: ea58dc2d760b307110d814a0d0955e0cb54b60a0
Parents: 1f440b8
Author: Igor Galić <i....@brainsware.org>
Authored: Fri Aug 9 00:23:13 2013 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Fri Aug 9 00:23:13 2013 +0200

----------------------------------------------------------------------
 plugins/experimental/spdy/lib/base/logging.h | 16 ++-----------
 plugins/experimental/spdy/spdy.cc            | 28 +++++++++++------------
 plugins/experimental/spdy/stream.cc          |  2 +-
 3 files changed, 17 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ea58dc2d/plugins/experimental/spdy/lib/base/logging.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/spdy/lib/base/logging.h b/plugins/experimental/spdy/lib/base/logging.h
index a4c065a..32b520a 100644
--- a/plugins/experimental/spdy/lib/base/logging.h
+++ b/plugins/experimental/spdy/lib/base/logging.h
@@ -21,18 +21,8 @@
 
 #include <string>
 
-extern "C" {
-
-// TS logging APIs don't get format attributes, so make sure we have a
-// compatible forward declaration.
-void TSDebug(const char *, const char *, ...)
-    __attribute__((format(printf, 2, 3)));
-
-void TSError(const char *, ...)
-    __attribute__((format(printf, 1, 2)));
-
-int TSIsDebugTagSet(const char*);
-}
+#define PLUGIN_NAME "spdy"
+#include <ts/debug.h>
 
 template <typename T> std::string stringof(const T&);
 #define cstringof(x) stringof(x).c_str()
@@ -45,8 +35,6 @@ template <typename T> std::string stringof(const T&);
 
 #define debug_protocol(fmt, ...) \
     debug_tag("spdy.protocol", "%s:%d " fmt, __func__, __LINE__, ##__VA_ARGS__)
-#define debug_plugin(fmt, ...) \
-    debug_tag("spdy.plugin", "%s:%d " fmt, __func__, __LINE__, ##__VA_ARGS__)
 #define debug_http(fmt, ...) \
     debug_tag("spdy.http", "%s:%d " fmt, __func__, __LINE__, ##__VA_ARGS__)
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ea58dc2d/plugins/experimental/spdy/spdy.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/spdy/spdy.cc b/plugins/experimental/spdy/spdy.cc
index 1a83e2a..91d1876 100644
--- a/plugins/experimental/spdy/spdy.cc
+++ b/plugins/experimental/spdy/spdy.cc
@@ -172,7 +172,7 @@ dispatch_spdy_control_frame(
         break;
     default:
         // SPDY 2.2.1 - MUST ignore unrecognized control frames
-        TSError("[spdy] ignoring invalid control frame type %u", header.control.type);
+        TSLogError("ignoring invalid control frame type %u", header.control.type);
     }
 
     io->reenable();
@@ -217,14 +217,14 @@ next_frame:
         // This should not fail because we only try to consume the header when
         // there are enough bytes to read the header. Experimentally, however,
         // it does fail. I wonder why.
-        TSError("TSIOBufferBlockReadStart failed unexpectedly");
+        TSLogError("TSIOBufferBlockReadStart failed unexpectedly");
         return;
     }
 
     if (nbytes < spdy::message_header::size) {
         // We should never get here, because we check for space before
         // entering. Unfortunately this does happen :(
-        debug_plugin("short read %" PRId64 " bytes, expected at least %u, real count %zu",
+        TSLogDebug("short read %" PRId64 " bytes, expected at least %u, real count %zu",
                 nbytes, spdy::message_header::size,
                 count_bytes_available(io->input.reader));
         return;
@@ -235,7 +235,7 @@ next_frame:
 
     if (header.is_control) {
         if (header.control.version != spdy::PROTOCOL_VERSION) {
-            TSError("[spdy] client is version %u, but we implement version %u",
+            TSLogError("client is version %u, but we implement version %u",
                 header.control.version, spdy::PROTOCOL_VERSION);
         }
     } else {
@@ -257,7 +257,7 @@ next_frame:
         if (header.is_control) {
             dispatch_spdy_control_frame(header, io, ptr);
         } else {
-            TSError("[spdy] no data frame support yet");
+            TSLogError("no data frame support yet");
         }
 
         if (TSIOBufferReaderAvail(io->input.reader) >= spdy::message_header::size) {
@@ -281,14 +281,14 @@ spdy_vconn_io(TSCont contp, TSEvent ev, void * edata)
 
     // Experimentally, we recieve the read or write TSVIO pointer as the
     // callback data.
-    //debug_plugin("received IO event %s, VIO=%p", cstringof(ev), vio);
+    //TSLogDebug("received IO event %s, VIO=%p", cstringof(ev), vio);
 
     switch (ev) {
     case TS_EVENT_VCONN_READ_READY:
     case TS_EVENT_VCONN_READ_COMPLETE:
         io = spdy_io_control::get(contp);
         nbytes = TSIOBufferReaderAvail(io->input.reader);
-        debug_plugin("received %d bytes", nbytes);
+        TSLogDebug("received %d bytes", nbytes);
         if ((unsigned)nbytes >= spdy::message_header::size) {
             consume_spdy_frame(io);
         }
@@ -304,7 +304,7 @@ spdy_vconn_io(TSCont contp, TSEvent ev, void * edata)
     case TS_EVENT_VCONN_EOS: // fallthru
     default:
         if (ev != TS_EVENT_VCONN_EOS) {
-            debug_plugin("unexpected accept event %s", cstringof(ev));
+            TSLogDebug("unexpected accept event %s", cstringof(ev));
         }
         io = spdy_io_control::get(contp);
         TSVConnClose(io->vconn);
@@ -333,7 +333,7 @@ spdy_accept_io(TSCont contp, TSEvent ev, void * edata)
         debug_protocol("accepted new SPDY session %p", io);
         break;
     default:
-        debug_plugin("unexpected accept event %s", cstringof(ev));
+        TSLogDebug("unexpected accept event %s", cstringof(ev));
     }
 
     return TS_EVENT_NONE;
@@ -346,10 +346,10 @@ spdy_setup_protocol(TSCont /* contp ATS_UNUSED */, TSEvent ev, void * /* edata A
   case TS_EVENT_LIFECYCLE_PORTS_INITIALIZED:
     TSReleaseAssert(TSNetAcceptNamedProtocol(TSContCreate(spdy_accept_io, TSMutexCreate()),
                                              TS_NPN_PROTOCOL_SPDY_2) == TS_SUCCESS);
-    debug_plugin("registered named protocol endpoint for %s", TS_NPN_PROTOCOL_SPDY_2);
+    TSLogDebug("registered named protocol endpoint for %s", TS_NPN_PROTOCOL_SPDY_2);
     break;
   default:
-    TSError("[spdy] Protocol registration failed");
+    TSLogError("Protocol registration failed");
     break;
   }
 
@@ -371,10 +371,10 @@ TSPluginInit(int argc, const char * argv[])
     info.support_email = (char *)"jamespeach@me.com";
 
     if (TSPluginRegister(TS_SDK_VERSION_3_0, &info) != TS_SUCCESS) {
-        TSError("[spdy] Plugin registration failed");
+        TSLogError("Plugin registration failed");
     }
 
-    debug_plugin("initializing");
+    TSLogDebug("initializing");
 
     for (;;) {
         switch (getopt_long(argc, (char * const *)argv, "s", longopts, NULL)) {
@@ -384,7 +384,7 @@ TSPluginInit(int argc, const char * argv[])
         case -1:
             goto init;
         default:
-            TSError("[spdy] usage: spdy.so [--system-resolver]");
+            TSLogError("usage: spdy.so [--system-resolver]");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ea58dc2d/plugins/experimental/spdy/stream.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/spdy/stream.cc b/plugins/experimental/spdy/stream.cc
index b5a7474..9735895 100644
--- a/plugins/experimental/spdy/stream.cc
+++ b/plugins/experimental/spdy/stream.cc
@@ -246,7 +246,7 @@ spdy_stream_io(TSCont contp, TSEvent ev, void * edata)
         return TS_EVENT_NONE;
 
     default:
-        debug_plugin("unexpected stream event %s", cstringof(ev));
+        TSLogDebug("unexpected stream event %s", cstringof(ev));
     }
 
     return TS_EVENT_NONE;