中国开发网: 论坛: 程序员情感CBD: 贴子 68180
haitao
具体来说,就是这样的需求
现有4个无条件写日志的函数
extern int commlogStr(const char* str,char withdate=-1);
extern int commlogStr2(const char* str,const char* str2,char withdate=-1);
extern int commlogStrs(char withdate=-1,...);
extern int commlogInt(const char* str,const int d,char withdate=-1);
如何加上日志级别,改成根据日志级别决定写或不写的

日志级别限制方法又有2种:
1、每种占1位,决定标志f是1个字节,位and的结果决定写或不写--这种可以任意决定各个级别的是否输出
2、决定标志f是一个值(0-8),大于等于它的才写,小于它的不写--按重要性决定输出

/*
0冗余信息
1调试信息
2运行信息
3变化信息
4警告信息
5错误信息
6异常信息
7失败信息
*/
这样好?
#define loglevel0
#define loglevel1
#define loglevel2
#define loglevel3
#define loglevel4
#define loglevel5
#define loglevel6
#define loglevel7
还是这样好?
#define loglevel0 1
#define loglevel1 2
#define loglevel2 4
#define loglevel3 8
#define loglevel4 0x10
#define loglevel5 0x20
#define loglevel6 0x40
#define loglevel7 0x80
我的blog:http://szhaitao.blog.hexun.com & http://www.hoolee.com/user/haitao
--以上均为泛泛之谈--
不尽牛人滚滚来,无边硬伤纷纷现 人在江湖(出来的),哪能不挨刀(总归是要的)
网络对话,歧义纷生;你以为明白了对方的话,其实呢?

您所在的IP暂时不能使用低版本的QQ,请到:http://im.qq.com/下载安装最新版的QQ,感谢您对QQ的支持和使用

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录