Comments (9)
不会添加代码,好尴尬啊
from easylogger.
你需要的应该是上面的那种 hex_dump 功能吧?
from easylogger.
嗯嗯 是这个功能 easylogger 里没找到这个函数啊
from easylogger.
EasyLogger 还不支持这个功能。我把 ulog 的这个功能贴出来,你方便改造一下,好用以后,提个 pr 吗 :)
/**
* dump the hex format data to log
*
* @param name name for hex object, it will show on log header
* @param width hex number for every line, such as: 16, 32
* @param buf hex buffer
* @param size buffer size
*/
void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t size)
{
#define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ')
rt_size_t i, j;
rt_size_t log_len = 0;
char *log_buf = NULL, dump_string[8];
int fmt_result;
RT_ASSERT(ulog.init_ok);
/* get log buffer */
log_buf = get_log_buf();
/* lock output */
output_lock();
for (i = 0, log_len = 0; i < size; i += width)
{
/* package header */
fmt_result = rt_snprintf(log_buf, ULOG_LINE_BUF_SIZE, "D/HEX %s: %04X-%04X: ", name, i, i + width);
/* calculate log length */
if ((fmt_result > -1) && (fmt_result <= ULOG_LINE_BUF_SIZE))
{
log_len = fmt_result;
}
else
{
log_len = ULOG_LINE_BUF_SIZE;
}
/* dump hex */
for (j = 0; j < width; j++)
{
if (i + j < size)
{
rt_snprintf(dump_string, sizeof(dump_string), "%02X ", buf[i + j]);
}
else
{
rt_strncpy(dump_string, " ", sizeof(dump_string));
}
log_len += ulog_strcpy(log_len, log_buf + log_len, dump_string);
if ((j + 1) % 8 == 0)
{
log_len += ulog_strcpy(log_len, log_buf + log_len, " ");
}
}
log_len += ulog_strcpy(log_len, log_buf + log_len, " ");
/* dump char for hex */
for (j = 0; j < width; j++)
{
if (i + j < size)
{
rt_snprintf(dump_string, sizeof(dump_string), "%c", __is_print(buf[i + j]) ? buf[i + j] : '.');
log_len += ulog_strcpy(log_len, log_buf + log_len, dump_string);
}
}
/* overflow check and reserve some space for newline sign */
if (log_len + rt_strlen(ULOG_NEWLINE_SIGN) > ULOG_LINE_BUF_SIZE)
{
log_len = ULOG_LINE_BUF_SIZE - rt_strlen(ULOG_NEWLINE_SIGN);
}
/* package newline sign */
log_len += ulog_strcpy(log_len, log_buf + log_len, ULOG_NEWLINE_SIGN);
/* do log output */
do_output(LOG_LVL_DBG, NULL, RT_TRUE, log_buf, log_len);
}
/* unlock output */
output_unlock();
}
from easylogger.
可以的
from easylogger.
ulog 哪个的 开源吗? 看类型定义应给是rtthread的? 我怎么没找到
from easylogger.
很快会开源出来,可以关注下 RT-Thread 公众号
from easylogger.
ok
from easylogger.
ulog 已经开源出来了,你可以对比看下哈
from easylogger.
Related Issues (20)
- demo中的ef_port_read实现问题
- RTOS中连续打印,出现异常 HOT 1
- 有些代码并不是可跨平台移植的 HOT 1
- 用户希望只有某些level的LOG才写入文件 HOT 1
- easylogger支持输出到RTTView吗?
- 是否考虑添加Lock失败,放弃本次log的机制 HOT 2
- 异步输出时的效率和完整性问题
- 能否将等级标签的静态过滤改成动态 HOT 1
- 怎么在FATFS上移植集成? HOT 2
- C++使用方法
- 异步输出丢弃问题?
- 不支持centos9stream
- Linux C++编译异常 HOT 1
- EasyLogger和FlashDB一起使用时重新定义问题 HOT 4
- 动态关闭控制台打印
- A potential data race problem 一个潜在的数据竞争问题 HOT 1
- Improper Restriction of Operations within the Bounds of a Memory Buffer HOT 1
- [FR]添加function、file、line的宏开关
- 有日志老化功能吗 HOT 1
- easylogger交叉编译之后导致ELOG_TERMINAL_ENABLE 无效??
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easylogger.