Skip to content

ulog支持打印调用所在的函数,文件名和行数 #7724

Open

Description

@mysterywolf

ulog支持打印调用所在的函数以及文件和行数.

如果一起都打印出来会导致日志内容过场,可以分别定义三个宏,用户可以自由决定开启打印 函数 文件名 行数

Activity

  1. polarvid commented on Jul 23, 2023

    @polarvid
    Contributor

    RT_ASSERT 中是否也可以添加文件名的输出?

    #define RT_ASSERT(EX) \
    if (!(EX)) \
    { \
    rt_assert_handler(#EX, __FUNCTION__, __LINE__); \
    }

  2. mysterywolf commented on Jul 23, 2023

    @mysterywolf
    MemberAuthor

    赞同

  3. Guozhanxin commented on Aug 29, 2023

    @Guozhanxin
    Member

    RT_ASSERT 中是否也可以添加文件名的输出?

    #define RT_ASSERT(EX) \
    if (!(EX)) \
    { \
    rt_assert_handler(#EX, __FUNCTION__, __LINE__); \
    }

    好像文件名这个东西,不同的编译器行为不一样,我记得哪个编译器会把全路径打出来,就很烦人。。。

  4. polarvid commented on Sep 6, 2023

    @polarvid
    Contributor

    RT_ASSERT 中是否也可以添加文件名的输出?

    #define RT_ASSERT(EX) \
    if (!(EX)) \
    { \
    rt_assert_handler(#EX, __FUNCTION__, __LINE__); \
    }

    好像文件名这个东西,不同的编译器行为不一样,我记得哪个编译器会把全路径打出来,就很烦人。。。

    VS Code 有路径和行数可以直接生成超链接跳转,还是很方便的。

    image

    显示格式可以通过宏配置,这样有需要可以打开。特别是 assert。现在查 assert 还要全局搜索一下函数名,可能还有重名,查起来不是很方便……

  5. armink commented on Sep 17, 2023

    @armink
    Member

    文件名和行号信息对于断言是实用的,最好默认就有的。但对 ulog 而言,尤其是一些低级别日志,用处不见得多。以前 elog 我也加过,而且不同级别日志格式也是可配置的,但实用性较少,还会增加很多冗余 log ,后面 ulog 就暂时没做这块

  6. added
    v5.1.0version 5.1.0 (planned to be released by the end of 2023)
    and removed on Sep 27, 2023
  7. a1012112796 commented on Sep 27, 2023

    @a1012112796
    Contributor

    有额外flash 开销吧。。。, 并且如果真的需要的完全可以自己加呀:例如

    LOG_I("%s, %s(): %s: xxxxxxxx", __FILE__, __func__, __LINE__);
  8. ymj0440 commented on Oct 30, 2026

    @ymj0440
    Contributor

    /claim

  9. github-actions commented on Oct 30, 2026

    @github-actions

    @ymj0440 has claimed this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

good first issueGood for newcomers 新手任务in progressPR/issue in progress.v5.1.0version 5.1.0 (planned to be released by the end of 2023)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions