Conversation
|
Thanks very much for this PR! |
|
Could this become a alternative log macro rather than the default one? |
I think it's OK, but no idea about a proper naming. |
| fatal | ||
| }; | ||
|
|
||
| static constexpr const char* FileName(const char* path) |
There was a problem hiding this comment.
- 该方法相比于 C++ 更适合 C,
C 使用C++ 可以考虑使用strrchr(),std::string_view. - 这种判断方法不适用于处理 Windows 的路径, 比如在 MSVC 中宏
__FILE__的值.
There was a problem hiding this comment.
- 这里其实用到了c++14 起的一个特性,constexpr 函数的编译期计算,可以看这里 https://godbolt.org/z/jjYqfjz7s , O1级别以上的优化都会在编译期算出表达式,也就是执行期不会call function

- 没有理解
- 确实,只做了简单的测试,用
std::filesystem::path::preferred_separator替代即可
There was a problem hiding this comment.
没注意到 constexpr, 抱歉. strrchr() 确实不支持, 不过 std::string_view 需要使用到的成员函数应该支持.
There was a problem hiding this comment.
static constexpr std::string_view FileName(std::string_view path)
{
return path.substr(path.find_last_of(std::filesystem::path::preferred_separator) + 1);
}仅供参考.
Maybe make log pattern configurable |
|
feat:
|
feat:Prettier log output with log src file and line, looks like:
test pr