# clog **Repository Path**: fishmwei/clog ## Basic Information - **Project Name**: clog - **Description**: 这是一个tiny 迷你的C语言编写的日志库 - **Primary Language**: C - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2022-05-02 - **Last Updated**: 2023-03-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # clog #### 介绍 clog是一个C语言写的简单的log库,大部分处理逻辑参考sysrepo的log.c文件。 支持往标准错误stderr输出日志、支持往syslog输出日志 #### 软件架构 软件架构说明 #### 安装教程 ```shell # download source git clone git@gitee.com:fishmwei/clog.git # make cd clog mkdir build; cd build cmake .. make make install # 默认安装到/usr/local/lib /usr/local/include 下面 # pkg-config pkg-config --libs libclog pkg-config --cflags libclog ``` #### 使用说明 reference to clog/test ```c #include #include void main() { /* turn logging on */ clog_log_stderr(CLOG_LL_WRN); #ifdef CLOG_SYSLOG clog_log_syslog("test-log", CLOG_LL_WRN); #endif CLOG_LOG_WRN("This is a message\r\n"); } ``` 选项设置 ```shell # 可以通过 -DCLOG_SYSLOG=no关掉syslog的功能 cmake -DCLOG_SYSLOG=no .. make make install ``` 支持hook每个日志的输出 ```c int err_msg_count = 0; void custom_log_cb(clog_log_level_t level, const char *message) { if (level == CLOG_LL_ERR) { err_msg_count++; // do other things , such as send msg to monitor server ... } } void main() { /* turn logging on */ clog_log_stderr(CLOG_LL_WRN); clog_log_set_cb(custom_log_cb); ... } ``` #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request