# uLog
Lightweight logging for embedded microcontrollers
## About uLog
uLog provides a structured logging mechanism for embedded microcontrollers or any system with limited resources.
It inherits the some concepts behind the popular Log4c and Log4j platforms, but with lower overhead.
Some features of uLog:
* uLog is easy to incorporate into nearly any environment, comprising one header file and one source file, and is written in pure C.
* uLog provides familiar severity levels (CRITICAL, ERROR, WARNING, INFO, DEBUG, TRACE).
* uLog supports multiple user-defined outputs (console, log file, in-memory buffer, etc), each with its own reporting threshold level.
* uLog is "aggressively standalone" with minimal dependencies, requiring only stdio.h, string.h and stdarg.h.
* uLog gets out of your way when you're not using it: if ULOG_ENABLED is undefined at compile time, no logging code is generated.
* uLog is well tested. See the accompanying ulog_test.c file for details.
## A quick intro by example:
```
#include <stdio.h>
#include "ulog.h"
// To use uLog, you must define a function to process logging messages. It can
// write the messages to a console, to a file, to an in-memory buffer: the
// choice is yours. And you get to choose the format of the message.
//
// The following example prints to the console.
//
// One caveat: msg is a static string and will be over-written at the next call
// to ULOG. This means you may print it or copy it, but saving a pointer to it
// will lead to confusion and astonishment.
//
void my_console_logger(ulog_level_t severity, const char *msg) {
printf("%s [%s]: %s\n",
get_timestamp(), // user defined function
ulog_level_name(severity),
msg);
}
int main() {
int arg = 42;
ULOG_INIT();
// log messages with a severity of WARNING or higher to the console. The
// user must supply a method for my_console_logger, e.g. along the lines
// of what is shown above.
ULOG_SUBSCRIBE(my_console_logger, ULOG_WARNING_LEVEL);
// log messages with a severity of DEBUG or higher to a file. The user must
// provide a method for my_file_logger (not shown here).
ULOG_SUBSCRIBE(my_file_logger, ULOG_DEBUG_LEVEL);
ULOG_INFO("Info, arg=%d", arg); // logs to file but not console
ULOG_CRITICAL("Critical, arg=%d", arg); // logs to file and console
// dynamically change the threshold for a specific logger
ULOG_SUBSCRIBE(my_console_logger, ULOG_INFO_LEVEL);
ULOG_INFO("Info, arg=%d", arg); // logs to file and console
// remove a logger
ULOG_UNSUBSCRIBE(my_file_logger);
ULOG_INFO("Info, arg=%d", arg); // logs to console only
}
```
## Questions? Comments? Improvements?
Comments and pull requests are welcome in https://github.com/rdpoor/ulog/issues
- R Dunbar Poor
June 2019
没有合适的资源?快使用搜索试试~ 我知道了~
嵌入式微控制器 的轻量级日志记录_C语言_代码_相关文件_下载
共7个文件
c:2个
h:2个
md:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 114 浏览量
2022-07-06
17:31:46
上传
评论
收藏 9KB ZIP 举报
温馨提示
嵌入式微控制器的轻量级日志记录 关于uLog uLog 为嵌入式微控制器或任何资源有限的系统提供结构化的日志记录机制。 它继承了流行的 Log4c 和 Log4j 平台背后的一些概念,但开销更低。 uLog的一些特点: uLog 易于集成到几乎任何环境中,由一个头文件和一个源文件组成,并且是用纯 C 语言编写的。 uLog 提供熟悉的严重级别(CRITICAL、ERROR、WARNING、INFO、DEBUG、TRACE)。 uLog 支持多个用户定义的输出(控制台、日志文件、内存缓冲区等),每个输出都有自己的报告阈值级别。 uLog 是具有最小依赖性的“积极独立”,仅需要 stdio.h、string.h 和 stdarg.h。 当你不使用 uLog 时,它不会妨碍你:如果 ULOG_ENABLED 在编译时未定义,则不会生成日志记录代码。 uLog 已经过很好的测试。有关详细信息,请参阅随附的 ulog_test.c 文件。 通过示例快速介绍: 更多详情、使用方法,请下载后阅读README.md文件
资源推荐
资源详情
资源评论
收起资源包目录
ulog-master.zip (7个子文件)
ulog-master
tests
ulog_test.c 6KB
ulog_test.h 1KB
LICENSE 1KB
src
ulog.h 5KB
ulog.c 4KB
.gitignore 430B
README.md 3KB
共 7 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功