• 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
    
  • 相关阅读:
    github上的每日学习 13
    github上的每日学习 12
    github上的每日学习 11
    github上的每日学习 10
    github上的每日学习 9
    github上的每日学习 8
    github上的每日学习 7
    面向对象程序设计寒假作业2
    MySQL安装和配置
    Fast Packet Processing with eBPF and XDP部分
  • 原文地址:https://www.cnblogs.com/cqvoip/p/8078857.html
Copyright © 2020-2023  润新知