#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <string.h>
#define debug_out(format, ...) \
{ \
time_t t = time(NULL); \
struct tm ttt = *localtime(&t); \
fprintf(stdout, "["__FILE__"][%4d-%02d-%02d %02d:%02d:%02d][%s:%d] " format "\n", \
ttt.tm_year + 1900, ttt.tm_mon + 1, ttt.tm_mday, ttt.tm_hour, \
ttt.tm_min, ttt.tm_sec, __FUNCTION__ , __LINE__, ##__VA_ARGS__); \
}
#define err_out(format, ...) \
{ \
time_t t = time(NULL); \
struct tm ttt = *localtime(&t); \
fprintf(stderr,"["__FILE__"][%4d-%02d-%02d %02d:%02d:%02d][%s:%d] " format ":%s\n", \
ttt.tm_year + 1900, ttt.tm_mon + 1, ttt.tm_mday, \
ttt.tm_hour, ttt.tm_min, ttt.tm_sec, \
__FUNCTION__ , __LINE__,##__VA_ARGS__, \
strerror(errno)); \
}
包含时间、行号、文件名等信息的打印
猜你喜欢
转载自blog.csdn.net/qu1993/article/details/81477178
今日推荐
周排行