From: Aditya Agarwal Date: Thu, 26 Oct 2006 03:31:34 +0000 (+0000) Subject: -- Change thrift logging macros to have a T_ prefix X-Git-Tag: 0.2.0~1621 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=35ae1c784ceb8e184e4b3ebc7b0a955f426a8fc8;p=common%2Fthrift.git -- Change thrift logging macros to have a T_ prefix Summary: -- don't want to cause naming conflicts with other packages/dirs Reviewed By: Mark Slee Test Plan: Compiled git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664851 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/cpp/src/TLogging.h b/lib/cpp/src/TLogging.h index 788174e5..3180d67a 100644 --- a/lib/cpp/src/TLogging.h +++ b/lib/cpp/src/TLogging.h @@ -11,45 +11,45 @@ #include /** - * GLOBAL_DEBUGGING_LEVEL = 0: all debugging turned off, debug macros undefined - * GLOBAL_DEBUGGING_LEVEL = 1: all debugging turned on + * T_GLOBAL_DEBUGGING_LEVEL = 0: all debugging turned off, debug macros undefined + * T_GLOBAL_DEBUGGING_LEVEL = 1: all debugging turned on */ -#define GLOBAL_DEBUGGING_LEVEL 0 +#define T_GLOBAL_DEBUGGING_LEVEL 0 /** - * GLOBAL_LOGGING_LEVEL = 0: all logging turned off, logging macros undefined - * GLOBAL_LOGGING_LEVEL = 1: all logging turned on + * T_GLOBAL_LOGGING_LEVEL = 0: all logging turned off, logging macros undefined + * T_GLOBAL_LOGGING_LEVEL = 1: all logging turned on */ -#define GLOBAL_LOGGING_LEVEL 1 +#define T_GLOBAL_LOGGING_LEVEL 1 /** * Standard wrapper around fprintf what will prefix the file name and line - * number to the line. Uses GLOBAL_DEBUGGING_LEVEL to control whether it is + * number to the line. Uses T_GLOBAL_DEBUGGING_LEVEL to control whether it is * turned on or off. * * @param format_string */ -#if GLOBAL_DEBUGGING_LEVEL > 0 - #define DEBUG(format_string,...) \ - if (GLOBAL_DEBUGGING_LEVEL > 0) { \ +#if T_GLOBAL_DEBUGGING_LEVEL > 0 + #define T_DEBUG(format_string,...) \ + if (T_GLOBAL_DEBUGGING_LEVEL > 0) { \ fprintf(stderr,"[%s,%d] " #format_string " \n", __FILE__, __LINE__,##__VA_ARGS__); \ } #else - #define DEBUG(format_string,...) + #define T_DEBUG(format_string,...) #endif /** - * analagous to DEBUG but also prints the time + * analagous to T_DEBUG but also prints the time * * @param string format_string input: printf style format string */ -#if GLOBAL_DEBUGGING_LEVEL > 0 - #define DEBUG_T(format_string,...) \ +#if T_GLOBAL_DEBUGGING_LEVEL > 0 + #define T_DEBUG_T(format_string,...) \ { \ - if (GLOBAL_DEBUGGING_LEVEL > 0) { \ + if (T_GLOBAL_DEBUGGING_LEVEL > 0) { \ time_t now; \ char dbgtime[26] ; \ time(&now); \ @@ -59,19 +59,19 @@ } \ } #else - #define DEBUG_T(format_string,...) + #define T_DEBUG_T(format_string,...) #endif /** - * analagous to DEBUG but uses input level to determine whether or not the string + * analagous to T_DEBUG but uses input level to determine whether or not the string * should be logged. * * @param int level: specified debug level * @param string format_string input: format string */ -#define DEBUG_L(level, format_string,...) \ - if ((level) > 0) { \ +#define T_DEBUG_L(level, format_string,...) \ + if ((level) > 0) { \ fprintf(stderr,"[%s,%d] " #format_string " \n", __FILE__, __LINE__,##__VA_ARGS__); \ } @@ -81,7 +81,7 @@ * * @param string format_string input: printf style format string */ -#define ERROR(format_string,...) \ +#define T_ERROR(format_string,...) \ { \ time_t now; \ char dbgtime[26] ; \ @@ -93,12 +93,12 @@ /** - * Analagous to ERROR, additionally aborting the process. + * Analagous to T_ERROR, additionally aborting the process. * WARNING: macro calls abort(), ending program execution * * @param string format_string input: printf style format string */ -#define ERROR_ABORT(format_string,...) \ +#define T_ERROR_ABORT(format_string,...) \ { \ time_t now; \ char dbgtime[26] ; \ @@ -115,20 +115,20 @@ * * @param string format_string input: printf style format string */ -#if GLOBAL_LOGGING_LEVEL > 0 - #define LOG_OPER(format_string,...) \ - { \ - if (GLOBAL_LOGGING_LEVEL > 0) { \ - time_t now; \ - char dbgtime[26] ; \ - time(&now); \ - ctime_r(&now, dbgtime); \ - dbgtime[24] = '\0'; \ - fprintf(stderr,"[%s] " #format_string " \n", dbgtime,##__VA_ARGS__); \ - } \ +#if T_GLOBAL_LOGGING_LEVEL > 0 + #define T_LOG_OPER(format_string,...) \ + { \ + if (T_GLOBAL_LOGGING_LEVEL > 0) { \ + time_t now; \ + char dbgtime[26] ; \ + time(&now); \ + ctime_r(&now, dbgtime); \ + dbgtime[24] = '\0'; \ + fprintf(stderr,"[%s] " #format_string " \n", dbgtime,##__VA_ARGS__); \ + } \ } #else - #define LOG_OPER(format_string,...) + #define T_LOG_OPER(format_string,...) #endif #endif // _THRIFT_LOGGING_H diff --git a/lib/cpp/src/transport/TBufferedFileWriter.cpp b/lib/cpp/src/transport/TBufferedFileWriter.cpp index ac46b97c..c3ed2500 100644 --- a/lib/cpp/src/transport/TBufferedFileWriter.cpp +++ b/lib/cpp/src/transport/TBufferedFileWriter.cpp @@ -94,12 +94,12 @@ TBufferedFileWriter::~TBufferedFileWriter() { void TBufferedFileWriter::enqueueEvent(const uint8_t* buf, uint32_t eventLen, bool blockUntilFlush) { // make sure that event size is valid if ( (maxEventSize_ > 0) && (eventLen > maxEventSize_) ) { - // ERROR("msg size is greater than max event size: %lu > %u\n", eventLen, maxEventSize_); + // T_ERROR("msg size is greater than max event size: %lu > %u\n", eventLen, maxEventSize_); return; } if (eventLen == 0) { - ERROR("cannot enqueue an empty event"); + T_ERROR("cannot enqueue an empty event"); return; } @@ -128,7 +128,7 @@ void TBufferedFileWriter::enqueueEvent(const eventInfo& toEnqueue, bool blockUnt // circular buffer has wrapped around (and is full) if(tailPos_ == headPos_) { - // DEBUG("queue is full"); + // T_DEBUG("queue is full"); isFull_ = true; } @@ -265,18 +265,18 @@ void TBufferedFileWriter::writerThread() { // sanity check on event if ( (maxEventSize_ > 0) && (outEvent.eventSize_ > maxEventSize_)) { - ERROR("msg size is greater than max event size: %u > %u\n", outEvent.eventSize_, maxEventSize_); + T_ERROR("msg size is greater than max event size: %u > %u\n", outEvent.eventSize_, maxEventSize_); continue; } //long long diff = now()-start; - //DEBUG("got a dequeue of size %d after %lld ms\n", (int)s.size(), diff/1000); + //T_DEBUG("got a dequeue of size %d after %lld ms\n", (int)s.size(), diff/1000); // If chunking is required, then make sure that msg does not cross chunk boundary if( (outEvent.eventSize_ > 0) && (chunkSize_ != 0)) { // event size must be less than chunk size if(outEvent.eventSize_ > chunkSize_) { - ERROR("TBufferedFileWriter: event size(%u) is greater than chunk size(%u): skipping event", + T_ERROR("TBufferedFileWriter: event size(%u) is greater than chunk size(%u): skipping event", outEvent.eventSize_, chunkSize_); continue; } @@ -290,14 +290,14 @@ void TBufferedFileWriter::writerThread() { // sanity check if (padding <= 0) { - DEBUG("Padding is empty, skipping event"); + T_DEBUG("Padding is empty, skipping event"); continue; } if (padding > (int32_t)chunkSize_) { - DEBUG("padding is larger than chunk size, skipping event"); + T_DEBUG("padding is larger than chunk size, skipping event"); continue; } - // DEBUG("padding %d zeros to get to chunk %lld\n", padding, chunk2); + // T_DEBUG("padding %d zeros to get to chunk %lld\n", padding, chunk2); uint8_t zeros[padding]; bzero(zeros, padding); if(-1 == ::write(fd_, zeros, padding)) { @@ -328,7 +328,7 @@ void TBufferedFileWriter::writerThread() { if((getCurrentTime() >= nextFlush && unflushed > 0) || unflushed > flushMaxBytes_ || (outEvent.eventSize_ == 0) ) { - //Debug("flushing %d bytes to %s (%d %d, full? %d)", unflushed, filename_.c_str(), headPos_, tailPos_, isFull_); + //T_DEBUG("flushing %d bytes to %s (%d %d, full? %d)", unflushed, filename_.c_str(), headPos_, tailPos_, isFull_); // sync (force flush) file to disk fsync(fd_);