代码拉取完成,页面将自动刷新
Lightweight logging for embedded microcontrollers
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:
#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_severity_t severity, const char *msg) {
printf("%s [%s]: %s\n",
get_timestamp(), // user defined function
ulog_severity_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
}
Comments and pull requests are welcome in https://github.com/rdpoor/ulog/issues
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。