把zlog封装成模块,隐藏zlog

mylog.h

#ifndef _MY_LOG_H
#define _MY_LOG_H int init(char *filename);
void *get_category(char * cateory_name);
void info(void *category, char *message);
void debug(void *category, char *message);
void fini(); #endif

mylog.c

#include "zlog.h"
#include "mylog.h" int init(char *filename)
{
return zlog_init(filename);
} void *get_category(char *cateory_name)
{
return zlog_get_category(cateory_name);
} void debug(void *category, char *message)
{
zlog_debug(category, message);
} void info(void *category, char *message)
{
zlog_info(category, message);
} void fini()
{
zlog_fini();
}

test.c

#include <stdio.h>
#include "mylog.h" int main(int argc, char** argv) {
int rc;
void *category; rc = init("test_hello.conf");
if (rc) {
printf("init failed\n");
return -;
} category = get_category("my_cat");
if (!category) {
printf("get cat fail\n");
fini();
return -;
} info(category, "hello, zlog");
debug(category, "hello, zlog");
fini(); return ;
}
上一篇:JSONObject和JSONArray的简单使用(json-lib)


下一篇:jbpm 6 vs activities 5评估(持续更新、亲测实际项目评估)