estk / log4rs

A highly configurable logging framework for Rust
Apache License 2.0
973 stars 143 forks source link

[bug] wrong thread id in linux #340

Closed fawdlstty closed 5 months ago

fawdlstty commented 5 months ago

Linux cannot obtain the real thread ID through configuration because the thread id library uses libc::pthread_self instead of libc::syscall(libc::SYS_gettid). The author seems unwilling to make changes and suggests replacing the thread id library ref: https://github.com/ruuda/thread-id/pull/16

estk commented 5 months ago

@fawdlstty if you would like to open a PR to add an additional format parameter I would be open to accepting it.

fawdlstty commented 5 months ago

I want to change the meaning of the formatting parameter i to get it under linux using SYS_gettid. Do you agree or disagree?

estk commented 5 months ago

@fawdlstty im not open to changing current functionality, but i would be open to adding a format parameter.

fawdlstty commented 5 months ago

But the current function of the i and I formatting parameters is the same. What I want is that without adding new parameters, the new function and the old function can be used normally

estk commented 5 months ago

@fawdlstty just because is a solution is right for your use case it does not mean it is right for others. In case i wasn't clear the two other times, I will not accept a change and will not continue to discuss it.

To solve your issue I would suggest calling gettid in your application code and logging it as part of the message body.

fawdlstty commented 5 months ago

I'm sorry. Because of I firmly believe that the existing way of getting thread ids is useless under linux, and for that I want disruptive changes. Adding a new formatting parameter would confuse usage, so I also don't think it's necessary to add new formatting parameters for a particular unexpected use case. Therefore, I am obsessed with modifying the existing formatting parameters. I respect your choice not to change, and I hope you'll forgive my offense.