-
Notifications
You must be signed in to change notification settings - Fork 5.3k
feat(ulog): add emergency log flush mechanism #10872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: Maihuanyi Changed Files (Click to expand)
🏷️ Tag: kernelReviewers: GorrayLi ReviewSun hamburger-os lianux-mm wdfk-prog xu18838022837 Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2025-11-01 10:21 CST)
📝 Review Instructions
|
275c783 to
23f7bc6
Compare
|
系统异常时,是不是不使用 ulog 打印更好呢?毕竟系统都跑飞了,一些系统状态可能都是不对的,直接用 ulog 导致的连锁反应挺多的,可靠性严重不足。之前的 CMB 日志前端直接用 ulog ,现在看有些草率。 两个小建议:
|
#define cmb_println(...) ulog_e(CMB_LOG_TAG, __VA_ARGS__);ulog_flush() |
是的,总体感觉是要让开发者在使用时,通过 API 接口语义,显性的知道当前哪些接口可以用于系统正常状态或者系统异常状态。 这样,在 ulog 里面不需要考虑一些系统异常的处理,简化 ulog 实现。毕竟 ulog 在设计之初就是考虑了 超轻量级 的这个理念。 |
23f7bc6 to
588d9ed
Compare
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
在系统发生严重故障(例如线程栈溢出、硬件故障中断)时,标准的 ulog_flush() 函数可能无法被安全调用。这是因为常规的日志后端可能依赖于操作系统服务,如互斥锁、信号量、动态内存分配或复杂的文件系统操作,这些服务在中断上下文或系统锁定状态下可能不可用或导致系统彻底崩溃。这使得开发者无法在系统临终前获取到最关键的调试信息。
例如检测线程溢出函数中使用LOG_E打印线程溢出,在启用ULOG+异步输出的情况下将不会显示
就算LOG_E之后加入ULOG_FLUSH,将会打印异常.因为可能挂载了不同的后端输出函数,可能具有异常操作导致一直不断刷新或者输出其他异常情况
开启ULOG+异步输出+文件后端(输出到littlefs文件系统路径下)
线程溢出时,未修复的输出日志如下
你的解决方案是什么 (what is your solution)
主要变更 (Key Changes)
通过这些变更,系统的可调试性和健壮性得到了显著提升,尤其是在处理和诊断严重系统故障时。
请提供验证的bsp和config (provide the config and bsp)
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up