zoukankan      html  css  js  c++  java
  • 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
    
  • 相关阅读:
    IOC基础
    spring ioc原理
    spring ioc原理
    2014年度辛星css教程夏季版第一节
    2014年度辛星html教程夏季版第八节
    2014年度辛星html教程夏季版第七节
    2014年度辛星html教程夏季版第六节
    2014年度辛星html教程夏季版第五节
    2014年度辛星html教程夏季版第四节
    2014年度辛星html教程夏季版第三节
  • 原文地址:https://www.cnblogs.com/cqvoip/p/8078857.html
Copyright © 2011-2022 走看看