zoukankan      html  css  js  c++  java
  • 宏打印函数

    可带参数的宏打印函数

    最简单的红打印函数(显示行列)

    1 #define ANITA_PRINTF(fmt, args...)  
    2 {
    3     printf("[%s][%d][anita]", __FUNCTION__,__LINE__);
    4     printf(fmt, ##args);
    5 }

    在项目中,常常需要一些定义的宏打印函数,在此分享一个简单的宏打印函数;

     1 enum DEBUG_LEVEL    /*打印等级*/
     2 {
     3     DEBUG_NONE = 0,
     4     DEBUG_INFO,
     5     DEBUG_ERROR,
     6     DEBUG_MAX_LEVEL,
     7 };
     8 static char const *debug_color[] = {
     9     "33[0m",         /* no color */
    10     "33[0;32m",      /* green */
    11     "33[0;31m",      /* red */
    12     "33[0;33m",      /* yellow */
    13 };
    14 #define NO_COLOR "33[0m"
    15 
    16 #define CGI_DEBUG(debug_level, fmt, args...) 
    17     do{
    18         char cgi_debug[16] = {0}; 
    19         unsigned char level = (debug_level >= DEBUG_MAX_LEVEL) ? DEBUG_INFO : debug_level;
    20         if (DEBUG_INFO == level || ((0 != GetValue("cgi_debug", cgi_debug)) && (0 == strcmp("on", cgi_debug)))) { 
    21             printf("%s[%s:%s:%d] %s" fmt NO_COLOR, debug_color[DEBUG_MAX_LEVEL], "anita", __func__, 
    22                     __LINE__, debug_color[level], ##args);}
    23     while(0);

     

  • 相关阅读:
    12.3
    团队项目第一阶段冲刺第一天
    4.22
    4.21 re重要功能
    12.1
    12.2
    4.17
    4.16
    css设置子元素相对于父元素保持位置不变(含有滚动条的父元素)
    git操作和npm操作清单
  • 原文地址:https://www.cnblogs.com/anitaguangzi/p/13901779.html
Copyright © 2011-2022 走看看