交叉编译
make PREFIX=$(pwd)/_install CC=arm-rockchip-linux-gnueabihf-gcc
zlog使用手册
http://hardysimpson.github.io/zlog/UsersGuide-CN.html
zlog配置文件示例
[global]
strict init = true //
buffer min= 1024
buffer max= 4096
file perms = 777
# rotate lock file = /tmp/zlog.lock
default format = "%d %V [%p:%F:%L] %m%n"
[formats]
fileformat = "%d %V [%p:%F:%L] %m%n"
simple = "%V [%F:%L] %m%n"
[rules]
*.* >stdout; simple
*.DEBUG "./x50.log", 1KB * 3 ~ "./x50.#r.log"; fileformat
zlog代码使用示例1(dzlog默认打印)
#include "zlog.h"
int rc = dzlog_init("zlog.conf", "default");
if (rc)
{
printf("dzlog_init failed\n");
return -1;
}
dzlog_info("main start");
while(1)
{
}
zlog_fini();
zlog代码使用示例2(zlog打印)
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include "zlog.h"
int main(int argc, char** argv)
{
int rc;
zlog_category_t *zc;
rc = zlog_init("test_mdc.conf");
if (rc) {
printf("init failed\n");
return -1;
}
zc = zlog_get_category("my_cat");
if (!zc) {
printf("get cat fail\n");
zlog_fini();
return -2;
}
zlog_info(zc, "1.hello, zlog");
zlog_put_mdc("myname", "Zhang");
zlog_info(zc, "2.hello, zlog");
zlog_put_mdc("myname", "Li");
zlog_info(zc, "3.hello, zlog");
zlog_fini();
return 0;
}