feat(hlog): add %p (pid) / %t (tid) format specifiers (standalone, supersedes #742) - #865
Closed
ithewei wants to merge 1 commit into
Closed
feat(hlog): add %p (pid) / %t (tid) format specifiers (standalone, supersedes #742)#865ithewei wants to merge 1 commit into
ithewei wants to merge 1 commit into
Conversation
Adds %p/%t to the log format. hlog is meant to be usable standalone (depending only on hexport.h), so instead of pulling in hthread.h this inlines the pid/tid platform primitives using the headers hlog.c already includes (windows.h / pthread.h + sys/syscall.h on Linux, pthread_ threadid_np on macOS). Verified: hlog.c still compiles standalone (only -I. -Ibase, no hthread.h/hplatform.h) and %p/%t print the correct process/thread id. Supersedes #742 (same feature; reworked to keep hlog dependency-free).
Owner
Author
|
撤回:hlog 的 %p/%t 目前没有实际需求,用户如需可自行在 message 里拼接 pid/tid(如 hlogi("[%ld] ...", (long)hv_gettid()))。保持 hlog 格式符最小化。 |
Contributor
|
多线程应用,平时都不打印线程id的么?进程id可能没用,但我觉得线程id还是挺有用的。。发自我的荣耀手机-------- 原始邮件 --------发件人: ithewei ***@***.***>日期: 2026年8月6日周四 12:08收件人: ithewei/libhv ***@***.***>抄送: mtdxc ***@***.***>, Mention ***@***.***>主 题: Re: [ithewei/libhv] feat(hlog): add %p (pid) / %t (tid) format specifiers (standalone, supersedes #742) (PR #865)ithewei left a comment (ithewei/libhv#865)
撤回:hlog 的 %p/%t 目前没有实际需求,用户如需可自行在 message 里拼接 pid/tid(如 hlogi("[%ld] ...", (long)hv_gettid()))。保持 hlog 格式符最小化。
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
%p(process id) and%t(thread id) log format specifiers.Reworked version of #742 to respect a design constraint:
hlog.h/hlog.care meant to be usable standalone (depending only onhexport.h). #742 did#include <hthread.h>to gethv_getpid()/hv_gettid(), which pulls inhplatform.hand breaks that independence.Instead, this inlines the pid/tid platform primitives directly in
hlog.c, using the headers it already includes (windows.hon Windows;pthread.h+sys/syscall.h/SYS_gettidon Linux,pthread_threadid_npon macOS,pthread_selffallback) — nohthread.h/hplatform.hdependency.Usage
Verified
hlog.ccompiles standalone (cc -I. -Ibase hlog.c+ a tiny main) — no hthread.h/hplatform.h needed.%pprints the process id,%tthe thread id.make libhvbuilds clean; format doc inhlog.hupdated.Supersedes #742 (thanks @mtdxc for the original idea).