trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iga...@apache.org
Subject [07/15] git commit: move APIs into ts/ts-debug.h
Date Thu, 08 Aug 2013 17:47:02 GMT
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.galic@brainsware.org>
Authored: Thu Aug 8 17:03:51 2013 +0200
Committer: Igor Galić <i.galic@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 */


Mime
View raw message