gabime / spdlog

Fast C++ logging library.
Other
23.92k stars 4.49k forks source link

MDC ignores `SPDLOG_NO_TLS` #3101

Open GaryOderNichts opened 3 months ago

GaryOderNichts commented 3 months ago

The in version 1.14.0 added Mapped Diagnostic Context (MDC) support ignores the SPDLOG_NO_TLS define and always creates a thread_local variable in mdc::get_context. https://github.com/gabime/spdlog/blob/c3aed4b68373955e1cc94307683d44dca1515d2b/include/spdlog/mdc.h#L40-L43 This breaks support for systems where thread local storage isn't available.

AntoineMurat commented 2 weeks ago

I confirm the issue; we are also affected. While it could be mitigated with a (slow) workaround that would use the tid, I believe a reasonable hotfix would be to disable MDC entirely when SPDLOG_NO_TLS is set.

gabime commented 2 weeks ago

I agree. PR is welcome