开源嵌入式代码分析——EasyLogger

开源嵌入式代码分析——EasyLogger,第1张

开源嵌入式代码分析——EasyLogger

本文不提供移植使用说明,只进行代码分析

简介

EasyLogger是对智能<1.6K, RAM<0.3K等级别(ROM<1.6K, RAM<0.3K)、资源库的C/C++日志,非常适合敏感的软件项目,例如:IoT产品、可穿戴设备、家居相比 log4c、zlog 知名的 C/C++ 库,EasyLogger 的功能简单,提供给用户的插件接口更多的接口,但以动态形式进行上手会像实用功能支持扩展扩展。
地址:https://github.com/armink/EasyLogger

风格

函数及变量名采用下划线 例如

static const char *level_output_info[];
void elog_port_output(const char *log, size_t size);

而结构体定义则采用大驼峰例如:

typedef struct {
    uint8_t level;
    char tag[ELOG_FILTER_TAG_MAX_LEN + 1];
    bool tag_use_flag; /**< false : tag is no used   true: tag is used */
} ElogTagLvlFilter, *ElogTagLvlFilter_t;
文件路径&架构图

整个文件夹及代码非常清晰,核心代码easylogger文件下分了3个文件夹和7个文件,inc头文件路径,移植的时候只需要包含inc路径就可以,引用则只需要#include “elog.h”。port移植接口,与底层相关的代码实现,src是核心代码实现。

-easylogger // 核心代码
----inc // 头文件文件夹
------elog.h // 引用需要的头文件
------elog_cfg.h // 配置文件
----port
------elog_port.c // 接口文件
----src
------elog.c
------elog_async.c
------elog_buf.c
------elog_utils.c
-------------------------------------------------------------------------、
----plugins // 可选的文件系统和flash
--------file
--------flash
-demo // 相关例程
----non_os
----os
-docs // 文档说明

接口 plugins-文件 plugins-Flash 说明

cubeide + fatfs + easylogger
不能包含#include “sd_diskio.h”
改成#include "./drivers/sd_diskio.h"编译通过。问题待查

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1353718.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-14
下一篇 2022-06-14

发表评论

登录后才能评论

评论列表(0条)

保存