mgLog简单使用

mgLog最简单的使用

在不指定输出函数时,其将指定输出到标准输出设备中去


代码如下

int main(int argc, char **argv)
{ 
	mglog_level(MG_LOG_DEBUG, "This is test %s, %d\n", "DEBUG", 1); 
	mglog_level(MG_LOG_TRACE, "This is test %s, %d\n", "trace", 2);
	mglog_level(MG_LOG_MSG, "This is test %s, %d\n", "msg", 3); 
	mglog_level(MG_LOG_WARN, "This is test %s, %d\n", "warn", 4); 
	mglog_level(MG_LOG_ERR, "This is test %s, %d\n", "err", 5); 
	mglog_level(MG_LOG_ERR+1, "This is test %s, %d\n", "unkonw", 6); 
	mglog_debug("This is log test %s, %d\n", "lDebug", 11); 
	mglog_msg("this is log test %s, %d\n", "lmsg", 12); 
	mglog_warn("this is log test %s, %d\n", "lwarn", 13); 
	mglog_err("This is log test %s, %d\n", "lerr", 14); 
	mglog_other("HAHA", "This is other test %s, %d\n", "haha", 21); 
	mglog_other("HOHO", "This is ohter test %s, %d", "hoho", 22); 
	mglog_trace_x("Nofile", 33232, "mglog_trace_x", "This is trace test %s, %d", "xtrace", 31); 
	mglog_trace("This is trace test %s, %d", "ltrace", 41); 
	return 0; 
}

输出结果如下

[root@localhost src]$ ./mgLogtest 
[DEBUG] This is test DEBUG, 1
[TRACE] This is test trace, 2
[MSG] This is test msg, 3
[WARN] This is test warn, 4
[ERR] This is test err, 5
[UNKNOW] This is test unkonw, 6
[DEBUG] This is log test lDebug, 11
[MSG] this is log test lmsg, 12
[WARN] this is log test lwarn, 13
[ERR] This is log test lerr, 14
[HAHA] This is other test haha, 21
[HOHO] This is ohter test hoho, 22
[TRACE] <Nofile:33232(mglog_trace_x)[16688]>This is trace test xtrace, 31
[TRACE] <mgLogtest.c:34(main)[16688]>This is trace test ltrace, 41


其中需要说明的是trace模式

mglog_trance是标准的,基含义为:[日志模式]<文件名:行号(函数)[进程号]>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值