From: Francesco Chemolli Date: Mon, 26 Nov 2012 08:28:09 +0000 (-0700) Subject: Modify debugs() to automatically include file, line and function name for high-detail... X-Git-Tag: SQUID_3_2_4~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef8b18fbd2f18beee5caa2053bfbe30537433a8f;p=thirdparty%2Fsquid.git Modify debugs() to automatically include file, line and function name for high-detail cache log lines. --- diff --git a/src/Debug.h b/src/Debug.h index 2e13080734..d96ec5a656 100644 --- a/src/Debug.h +++ b/src/Debug.h @@ -109,17 +109,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. diff --git a/src/comm.cc b/src/comm.cc index 3f3238dfc2..d7057863ee 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -2130,7 +2130,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");