Pull Request has been successfully merged by CANN-robot.
(Thank you for W4termy's contribution.)变更摘要
本次变更将日志时间相关功能从 error.h 与 log_manager.cpp 中解耦,抽离为独立的 log_time 模块。核心是把 TerminateHandler 的构造函数从 error.h 头文件内联定义移到 error.cpp 中实现,从而让错误头文件不再隐式依赖日志时间初始化逻辑;同时把原本位于 log_manager.cpp 的 GetCurrentTime、GetCurrentTimeStr 迁移到新增的 framework/src/utils/host_log/log_time.cpp,并新增显式的 InitializeLogTime() 初始化入口,配套增加了单元测试。
主要改动
TerminateHandler构造函数外移: 将framework/src/interface/utils/error.h中TerminateHandler的内联构造函数改为仅声明,实现在error.cpp中完成,避免错误头文件携带日志时间初始化依赖。- 新增显式初始化入口
InitializeLogTime(): 在error.cpp的TerminateHandler构造函数安装信号处理器与set_terminate之前调用InitializeLogTime(),确保处理回调可安全记录日志。 - 抽离时间模块: 新增
framework/src/utils/host_log/log_time.cpp与log_time.h,提供InitializeLogTime()、GetCurrentTime()、GetCurrentTimeStr()三个接口,并从log_manager.cpp删除原有同名时间函数、改为包含新头文件。 - 时间实现调整: 新模块使用
std::call_once加std::once_flag保证初始化仅执行一次,通过gettimeofday、tzset、localtime_r获取时区与 DST,并自行计算本地时间,GetCurrentTimeStr由GetCurrentTime去除分隔符生成。 - 新增单元测试: 增加
framework/tests/ut/machine/src/utils/test_log_time.cpp,覆盖本地时间戳格式、文件名时间戳格式及多线程并发生成的校验。


compile


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| 9.2.0 | ✅ gcw_kUomxQ2l, gaoxingwang (2/2) | ✅ gcw_kUomxQ2l (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
W4termy, thanks for your pull request. All authors of the commits have signed the CLA. 👍


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/approve


/lgtm


性能用例批跑时,若线程在 libc 时间转换过程中持有 tzset_lock,此时被信号打断,TerminateHandler 回调打印日志会再次通过 std::localtime() 申请同一把锁,导致线程自我死锁。
修改内容