1 Star 1 Fork 0

Lux1206 / elog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

elog

简介

elog 是一个用于嵌入式设备的微小 log 输出插件,代码量极小,非常适合用于资源受限的嵌入式设备,当然也同样支持多线程设备。

使用方法

  1. 注册并初始化 elog,在初始化的同时会自动创建一个默认输出终端,默认名称 “TERM”,默认输出所有日志,日志输出等级为 LOG_TRACE;
elog_init(LOG_TRACE, buff, sizeof(buff), elog_user_output1);
  1. 设置全局 log 输出等级,大于这个等级的日志输出项,将不会被输出到显示终端;
elog_set_global_level(LOG_INFO);
  1. 你也可以添加新的日志打印模块,目前最大支持 8 个,可以通过宏来修改个数;
elog_add_terminal("lux1", LOG_NOTICE, elog_user_output2);
  1. 同时支持指定模块输出;
    ELOG_WARN("hello world5"); 
    ELOG_MDU_WARN("lux1","hello world7");

Examples

#include "elog.h"

void elog_user_output1(const char *str)
{
    printf(" %s", str);
}

void elog_user_output2(const char *str)
{
    printf(" %s", str);
}

int main(void)
{
    uint8_t buff[128] = {0};

    elog_init(LOG_TRACE, buff, sizeof(buff), elog_user_output1);
    elog_set_global_level(LOG_INFO);
    elog_add_terminal("lux1", LOG_NOTICE, elog_user_output2);
    
    ELOG_TRACE("hello world1");
    ELOG_DEBUG("hello world2");
    ELOG_INFO("hello world3"); 
    ELOG_NOTICE("hello world4");
    ELOG_WARN("hello world5"); 
    ELOG_ERROR("hello world6");
    
    ELOG_MDU_WARN("lux1","hello world7");

    return 0;      
}
MIT License Copyright (c) 2022 Lux1206 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

The embedded device log output plug-in has a small code size, which is very suitable for devices with limited resources. It also supports multithreading 展开 收起
C 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C
1
https://gitee.com/Lux-Li/elog.git
git@gitee.com:Lux-Li/elog.git
Lux-Li
elog
elog
main

搜索帮助