/******************************************************************************* * * File Name : log.c * Decription : ·Î±× ¸Þ¼¼Áö ÆíÇÏ°Ô Ãâ·ÂÀ»... * Version : 1.0 * Date : Tue Oct 2 18:23:03 KST 2007 * Author : Ji Hun, SEO * Email : white23 at gmail.com white23 at suresofttech.com * TODO : fflush()¸¦ ¼±Åà ÇÒ ¼ö ÀÖµµ·Ï ¼öÁ¤. * ******************************************************************************/ /* checked compiler: - gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) - gcc version 3.3.2: Thread model: aix (AIX 1 5 00572BED4C00) - gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125) - Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86 - c89(HP-UX B.11.11 U 9000/800 136911531) - cc(SunOS 5.9 Generic_112233-12 sun4u sparc SUNW,Sun-Blade-1000) */ #include #define __DEBUG__ #if !defined(__FILE__) # define __FILE__ "__FILE__" #endif /* !__FILE__ */ #if !defined(__FUNCTION__) # define __FUNCTION__ "__FUNCTION__" #endif /* !__FUNCTION__ */ #if !defined(__LINE__) # define __LINE__ "__LINE__" #endif /* !__LINE__ */ #if defined(__func__) # define __FUNCTION__ __func__ #endif /* __func__ */ #if defined(_MSC_VER) /* check CL compiler */ # define __LOG_VA_ARGS__ __VAR_ARGS__ #else # if defined(VAR_ARG) # define __LOG_VA_ARGS__ VAR_ARG # else # define __LOG_VA_ARGS__ ... # endif /* VAR_ARG */ #endif #if defined(__DEBUG__) # define LOG_FORMAT1 " ## [%s:%s():%d]: " # define LOG_FORMAT2 __FILE__, __FUNCTION__, __LINE__ # define LOG_PRINT(FMT, __LOG_VA_ARGS__) printf(LOG_FORMAT1 FMT, LOG_FORMAT2, __LOG_VA_ARGS__); fflush(stdout) # define LOG_PRINT_F(FMT) printf(LOG_FORMAT1 FMT, LOG_FORMAT2); fflush(stdout) #else # define LOG_PRINT(__LOG_VA_ARGS__) while (0) # define LOG_PRINT_F(__LOG_VA_ARGS__) while (0) #endif int main(int argc, char *argv[]) { int i = 0, j = 1; LOG_PRINT( "LOG_PRINT format: %s%d, %s%d\n", "i = ", i, "j = ", j ); LOG_PRINT_F( "LOG_PRINT_F format: const string....\n" ); return 0; } /* vi: ts=4: sw=4: */