반응형
//Android debug message with LOGE

#ifdef DEBUG_MSG_ON
#define  GET_SHORT_FILENAME(longfilename)   \
    ( (strrchr(longfilename, '/')==NULL) ? \
        longfilename: ((char*)(strrchr(longfilename, '/')+1)))
#define gprintf(fmt, args...)      \
 LOGE("[%d],%s:%d, %s(): "fmt,           \
   gettid(), GET_SHORT_FILENAME(__FILE__), __LINE__, __FUNCTION__,     ##args) 
#else
#define gprintf(fmt, args...)
#endif


ALOGE
//----------------------------------------------------------------------------------------------------
#include <utils/Log.h>
#undef  LOG_TAG
#define LOG_TAG "BTRCU"
#if 1
#define gprintf(fmt, args...) ALOGE("%s(%d): " fmt, __FUNCTION__, __LINE__, ##args)
#else
#define gprintf(fmt, args...)
#endif
//----------------------------------------------------------------------------------------------------






//Android NDK 
//------------------------------------------------------------------------------
#include <android/log.h>

#define TAG "HoJNI"
#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__)
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)

#define GDEBUG
#ifdef GDEBUG
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
//#define gprintf(msg...) do { fprintf(stderr,"%s %s() %d: ", __FILE__, __FUNCTION__, __LINE__); fprintf (stderr,msg);} while (0)
#define gprintf(msg...) do { LOGE("%s:%d, %s(): %s", __FILENAME__, __LINE__, __FUNCTION__, msg);} while (0)
#else
#define gprintf(msg...)
#endif
//------------------------------------------------------------------------------


//C debug message with printf & fflush


#define gprintf(fmt, x... ) do { \
       if(1) {\
        printf( "%s(%d): " fmt, __FUNCTION__ , __LINE__, ## x);\
        fflush(stdout);\
       }} while (0)


//C debug message with fprintf




#define GDEBUG
#ifdef  GDEBUG

# define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#    define gprintf(msg...)  do { fprintf(stderr,"%s %s() %d: ", __FILE__, __FUNCTION__, __LINE__); fprintf (stderr,msg);} while (0)
#else
#    define gprintf(msg...)
#endif


파일 이름 짧게

//----------------------------------------------------------------------------------------------------

#define GDEBUG

#ifdef  GDEBUG

#   define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)

#   define gprintf(msg...)  do { fprintf(stderr,"%s %s() %d: ", __FILENAME__, __FUNCTION__, __LINE__); fprintf (stderr,msg);} while (0)

#else

#   define gprintf(msg...)

#endif

//----------------------------------------------------------------------------------------------------




//ffmpeg debug message with av_log

#define GDEBUG
#ifdef  GDEBUG
#    define gprintf(fmt, x...)  do { av_log(NULL, AV_LOG_DEBUG, "%s[%d]:" fmt, __FILE__, __LINE__,##x);} while (0)
#else
#    define  gprintf(fmt, x...)
#endif


#include <syslog.h>

#define GDEBUG
#ifdef  GDEBUG
//#    define gprintf(msg...)  do { fprintf(stderr,"\n%s %s() %d: ", __FILE__, __FUNCTION__, __LINE__); fprintf (stderr,msg);} while (0)
#    define gprintf(fmt, x...)  do { syslog(KERN_DEBUG,"%s %s() %d: " fmt, __FILE__, __FUNCTION__, __LINE__, ##x);} while (0)
#else
#    define gprintf(msg...)
#endif





반응형

'C & C++ 관련' 카테고리의 다른 글

_splitpath / 경로명에서 원하는 정보 분리하기  (0) 2009.08.10
스마트 포인터  (0) 2009.07.26
auto_ptr의 두 얼굴  (0) 2009.07.26
Posted by Real_G