]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Modify debugs() to automatically include file, line and function name for high-detail...
authorFrancesco Chemolli <kinkie@squid-cache.org>
Sun, 18 Nov 2012 11:21:41 +0000 (04:21 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 18 Nov 2012 11:21:41 +0000 (04:21 -0700)
src/Debug.h
src/comm.cc

index 60c9a55dd25bc47090d5e9a4fdcc8f8f244db924..3df1cfc0defe0f666fa7ffb16b99bca8a86a097f 100644 (file)
@@ -107,17 +107,28 @@ const char * SkipBuildPrefix(const char* path);
 #define debugs(SECTION, LEVEL, CONTENT) \
    do { \
         if ((Debug::level = (LEVEL)) <= Debug::Levels[SECTION]) { \
-                Debug::getDebugOut() << CONTENT; \
-                Debug::finishDebug(); \
+            std::ostream &_dbo=Debug::getDebugOut(); \
+            if (Debug::level > DBG_IMPORTANT) \
+                _dbo << SkipBuildPrefix(__FILE__)<<"("<<__LINE__<<") "<<__FUNCTION__<<": "; \
+            _dbo << CONTENT; \
+            Debug::finishDebug(); \
         } \
    } while (/*CONSTCOND*/ 0)
 
-/*
- * HERE is a macro that you can use like this:
+/** stream manipulator which does nothing.
+ * \deprecated Do not add to new code, and remove when editing old code
  *
+ * Its purpose is to inactivate calls made following previous debugs()
+ * guidelines such as
  * debugs(1,2, HERE << "some message");
+ *
+ * His former objective is now absorbed in the debugs call itself
  */
-#define HERE SkipBuildPrefix(__FILE__)<<"("<<__LINE__<<") "<<__FUNCTION__<<": "
+inline std::ostream&
+HERE(std::ostream& s)
+{
+    return s;
+}
 
 /*
  * MYNAME is for use at debug levels 0 and 1 where HERE is too messy.
index 78ed56d57c8ecacf5d1d9c00ae49e5b74a7d2066..8020e0c193243fb4d0786acb6da88c77cf4ca4f2 100644 (file)
@@ -2135,7 +2135,7 @@ comm_open_uds(int sock_type,
         return -1;
     }
 
-    debugs(50, 3, HERE "Opened UDS FD " << new_socket << " : family=" << AI.ai_family << ", type=" << AI.ai_socktype << ", protocol=" << AI.ai_protocol);
+    debugs(50, 3, "Opened UDS FD " << new_socket << " : family=" << AI.ai_family << ", type=" << AI.ai_socktype << ", protocol=" << AI.ai_protocol);
 
     /* update fdstat */
     debugs(50, 5, HERE << "FD " << new_socket << " is a new socket");