总结几种log打印printf函数的宏定义
来源:互联网 发布:老白老婆 知乎 编辑:程序博客网 时间:2024/05/01 06:53
http://blog.chinaunix.net/u1/38994/showart_1168773.html
#include <stdio.h>
#define lU_DEBUG_PREFIX "##########"
#define LU_DEBUG_CMD 0x01
#define LU_DEBUG_DATA 0x02
#define LU_DEBUG_ERROR 0x04
#define LU_PRINTF_cmd(msg...) do{if(lu_debugs & LU_DEBUG_CMD)printf(lU_DEBUG_PREFIX msg);}while(0)
#define LU_PRINTF_data(msg...) do{if(lu_debugs & LU_DEBUG_DATA)printf(lU_DEBUG_PREFIX msg);}while(0)
#define LU_PRINTF_error(msg...) do{if(lu_debugs & LU_DEBUG_ERROR)printf(lU_DEBUG_PREFIX msg);}while(0)
#define lu_printf(level, msg...) LU_PRINTF_##level(msg)
#define lu_printf2(...) printf(__VA_ARGS__)
#define lu_printf3(...) lu_printf(__VA_ARGS__)
static int lu_printf4_format(int prio, const char *fmt, ...);
#define lu_printf4(prio, fmt...) lu_printf4_format(prio, fmt)
int lu_debugs;
int main(int argc, char *argv[])
{
lu_debugs |= LU_DEBUG_CMD | LU_DEBUG_DATA | LU_DEBUG_ERROR;
printf("lu_debugs = %p/n", lu_debugs);
lu_printf(cmd,"this is cmd/n");
lu_printf(data,"this is data/n");
lu_printf(error,"this is error/n");
lu_debugs &= ~(LU_DEBUG_CMD | LU_DEBUG_DATA);
printf("lu_debugs = %p/n", lu_debugs);
lu_printf(cmd,"this is cmd/n");
lu_printf(data,"this is data/n");
lu_printf(error,"this is error/n");
lu_printf2("aa%d,%s,%dbbbbb/n", 20, "eeeeeee", 100);
lu_debugs |= LU_DEBUG_CMD | LU_DEBUG_DATA | LU_DEBUG_ERROR;
printf("lu_debugs = %p/n", lu_debugs);
lu_printf3(cmd,"this is cmd /n");
lu_printf3(data,"this is data/n");
lu_printf3(error,"this is error/n");
lu_printf4(0,"luther %s ,%d ,%d/n", "gliethttp", 1, 2);
return 0;
}
#include <stdarg.h>
static int lu_printf4_format(int prio, const char *fmt, ...)
{
#define LOG_BUF_SIZE (4096)
va_list ap;
char buf[LOG_BUF_SIZE];
va_start(ap, fmt);
vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
va_end(ap);
printf("<%d>: %s", prio, buf);
printf("------------------------/n");
printf(buf);
}
#define ENTER() LOGD("enter into %s", __FUNCTION__)
#define LOGD(...) ((void)LOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
#define LOG(priority, tag, ...) /
LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__)
#define LOG_PRI(priority, tag, ...) /
android_printLog(priority, tag, __VA_ARGS__)
#define android_printLog(prio, tag, fmt...) /
__android_log_print(prio, tag, fmt)
- 总结几种log打印printf函数的宏定义
- 总结几种log打印printf函数的宏定义
- 总结几种log打印printf函数的宏定义
- 总结几种log打印printf函数的宏定义
- 总结几种log打印printf函数的宏定义
- 总结几种log打印printf函数的宏定义
- 总结几种log打印printf函数的宏定义
- #define 宏函数实现printf打印log
- printf Log打印封装
- 封装printf函数,让log可以打印文件名和行号
- printf的宏定义
- c 宏定义log日志简单打印
- iOS 宏定义~log(打印日志)
- 记录log宏定义可变参数的几种处理方式
- 添加自己的printf 打印函数
- 关于移植过程中,存在大量LCD log(不定形参...)等调试属性函数宏定义到printf
- 关于printf()函数的总结
- printf 的宏定义版本
- wince 中文乱码
- at91sam7x256之IIC(TWI)实验_PCF8563_AT24C02
- c#
- Applications of graph theory to an English rhyming corpus
- log4j 日志服务器_项目实际使用日记
- 总结几种log打印printf函数的宏定义
- 世界杯小组赛积分所有可能情况
- 三星cpu s3c2440 的中断向量表问题
- 第一月工作心得
- mysql输出格式调整
- Informix onstat 命令详解
- android 编译系统阅读与分析(1)-envsetup.sh
- 左值 右值 (转)
- U-Boot-1.2.0源码学习(2)