c日志宏

仅供参考,不推荐

#ifdef _DEBUG
#define LOGDEBUG(format, ...)\
{\
FILE *fp = fopen("nccli.log", "ab+");if(fp!=NULL){\
time_t t = time(0);\
struct tm ttt = *localtime(&t);\
fprintf(fp, "[DEBUG] [%5d %4d-%02d-%02d %02d:%02d:%02d] [%s:%d] " format "",\
GetCurrentProcessId(), ttt.tm_year + 1900, ttt.tm_mon + 1, ttt.tm_mday, ttt.tm_hour,\
ttt.tm_min, ttt.tm_sec, __FUNCTION__ , __LINE__, ##__VA_ARGS__);\
fclose(fp);}\
} #define LOGERROR(format, ...)\
{\
FILE *fp = fopen("nccli.log", "ab+");if(fp!=NULL){\
time_t t = time(0);\
struct tm ttt = *localtime(&t);\
fprintf(fp, "[ERROR] [%5d %4d-%02d-%02d %02d:%02d:%02d] [%s:%d] " format "",\
GetCurrentProcessId(), ttt.tm_year + 1900, ttt.tm_mon + 1, ttt.tm_mday, ttt.tm_hour,\
ttt.tm_min, ttt.tm_sec, __FUNCTION__ , __LINE__, ##__VA_ARGS__);\
fclose(fp);}\
}
#else
#define LOGDEBUG(format, ...)\
{\
time_t t = time(0);\
struct tm ttt = *localtime(&t);\
fprintf(stdout, "[DEBUG] [%5d %4d-%02d-%02d %02d:%02d:%02d] [%s:%d] " format "",\
GetCurrentProcessId(), 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 LOGERROR(format, ...)\
{\
time_t t = time(0);\
struct tm ttt = *localtime(&t);\
fprintf(stderr, "[ERROR] [%5d %4d-%02d-%02d %02d:%02d:%02d] [%s:%d] " format "",\
GetCurrentProcessId(), ttt.tm_year + 1900, ttt.tm_mon + 1, ttt.tm_mday, ttt.tm_hour,\
ttt.tm_min, ttt.tm_sec, __FUNCTION__ , __LINE__, ##__VA_ARGS__);\
}
#endif
上一篇:IdentityServer4 中文文档 -11- (快速入门)添加基于 OpenID Connect 的用户认证


下一篇:mysqldump中master-data和dump-slave的区别