linux c 编程 log输出:
//printlog.h
#ifndef __PRINT_LOG__H__ #define __PRINT_LOG__H__ #include #include #include #include #include #define ZDBG(msg...)\ do\ {\ struct timeval tv;\ struct timezone tz;\ struct tm *p;\ gettimeofday(&tv, &tz);\ p = localtime(&tv.tv_sec);\ printf("[DBG:pid=%d tid=%d %d-%d:%d:%d.%ld] ", getpid(), syscall(SYS_gettid),/*gettid(),*/ p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec, tv.tv_usec);\ printf("[\\\\\\ %s,%s, %d ///]---------------",__FILE__, __FUNCTION__, __LINE__);printf(msg);\ } while (0); #define ZERR(msg...)\ do\ {\ struct timeval tv;\ struct timezone tz;\ struct tm *p;\ gettimeofday(&tv, &tz);\ p = localtime(&tv.tv_sec);\ printf("[ERR:%d-%d:%d:%d.%ld] ", p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec, tv.tv_usec);\ printf("[\\\\\\ %s,%s, %d ///]!!!!!!!!!!!!!!!!!!!!---------------\n",__FILE__, __FUNCTION__, __LINE__);printf(msg);\ } while (0); #endif