Date: Wed, 28 Oct 2026 09:25:37 +0000
I’ve seen several implementations of logging facilities, and “the good ones” seem to converge on the exact same solution (that we can almost consider a standard 😝)
Yeah, macros are evil, but this one I can live with. And unless you can find different use cases where this would be useful (other than this exact logging pattern), then I’m afraid the proposal is not worth it.
Yes, you can make this logging thing slightly nicer, but are you getting a significant improvement to be worth the trouble?
From: Std-Proposals <std-proposals-bounces_at_[hidden]pp.org> On Behalf Of Pavel Vazharov via Std-Proposals
Sent: Wednesday, October 28, 2026 10:10
To: std-proposals_at_[hidden]
Cc: Pavel Vazharov <freakpv_at_[hidden]>
Subject: Re: [std-proposals] Modularized logging library - prevent parameter evaluation before calling
Hi,
In my ideal world, I could define my logging function like this:
[[ConditionalDiscard = IsShipping()]]
template<typename... Ts>
void LogWarn(std::string_view fmt, Ts&&... args) { /* ... */ }
I assume the function IsShipping() to be constexpr.
And the effect would be a function call completely stripped
What about the other cases where the decision for logging based on the log level is taken at runtime?
For example, I've worked with systems where the logging level for a given sub-system of the application (or the whole application) can be changed at runtime and this helps collect more information about specific production issues.
However, we still wanted lazy evaluation of the parameters because these logs are still disabled 99% of the time.
We used macros for our logging systems. At least I don't know a better alternative for this.
Regards,
Pavel.
Yeah, macros are evil, but this one I can live with. And unless you can find different use cases where this would be useful (other than this exact logging pattern), then I’m afraid the proposal is not worth it.
Yes, you can make this logging thing slightly nicer, but are you getting a significant improvement to be worth the trouble?
From: Std-Proposals <std-proposals-bounces_at_[hidden]pp.org> On Behalf Of Pavel Vazharov via Std-Proposals
Sent: Wednesday, October 28, 2026 10:10
To: std-proposals_at_[hidden]
Cc: Pavel Vazharov <freakpv_at_[hidden]>
Subject: Re: [std-proposals] Modularized logging library - prevent parameter evaluation before calling
Hi,
In my ideal world, I could define my logging function like this:
[[ConditionalDiscard = IsShipping()]]
template<typename... Ts>
void LogWarn(std::string_view fmt, Ts&&... args) { /* ... */ }
I assume the function IsShipping() to be constexpr.
And the effect would be a function call completely stripped
What about the other cases where the decision for logging based on the log level is taken at runtime?
For example, I've worked with systems where the logging level for a given sub-system of the application (or the whole application) can be changed at runtime and this helps collect more information about specific production issues.
However, we still wanted lazy evaluation of the parameters because these logs are still disabled 99% of the time.
We used macros for our logging systems. At least I don't know a better alternative for this.
Regards,
Pavel.
Received on 2026-10-28 09:25:41
