项目日志

当一个项目中需要输出内容或者打印日志时
一般不直接使用printf()
printf(“file:%s function:%s line:%d xxx”,FILE,func,LINE)
日志级别:
企业开发打印 一般都是按级别打印
TRACE DEBUG INFO WARRING ERROR FATAL
下面一般都在项目中显示你需要的输出,可以知道具体输出的是哪一行的内容,或者是你哪一行代码出错,查起来也方便。
#define LOG_FATAL(format,args…)
if(loglevel>0){
time_t t = time(NULL);
printf("[fatal] %s %s %s() %d : "format,ctime(&t),FILE,func,LINE,##args);}

#define LOG_ERROR(format,args…)
if(loglevel>1){
time_t t = time(NULL);
printf("[error] %s %s %s() %d : "format,ctime(&t),FILE,func,LINE,##args);}

#define LOG_INFO(format,args…)
if(loglevel>2) {
time_t t = time(NULL);
printf("[info] %s %s %s() %d : "format,ctime(&t),FILE,func,LINE,##args);}
写项目时用来输出,判错

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值