On Oct 18, 2024, at 2:50 PM, Ivica Siladic via Boost
wrote: In the absence of a better solution, we recommend users add their own logging code directly into the async_mqtt5 source during development. It’s very far from ideal, but we couldn’t come up with a better approach.
Sorry for the drive-by comment, but it seems that a policy-based metaprogramming approach would work here. There must be specific places in the code where it makes sense to (potentially) emit log messages. At those places you could put something like the following: using log_policy = typename type_traits::log_policy<T>::type; log_policy::apply(x,y,z) The following metafunctions would create a customization point for users who want to partially (or completely) specialize log_policy_customization<> for type-specific or universal logging. // default policy template < typename T > struct log_policy_default { using type = log_policy_default; template < typename … T > static void apply (T&& …) {} // no cost by default }; // customization point // _ is always void, so partial specializations can apply to all T template < typename T, typename _ > struct log_policy_customization : log_policy_default<T> {}; // main metafiction template < typename T > struct log_policy : log_policy_customization< T,void > {} Even if this is not a good solution for MQTT, I’m curious about general reactions to this strategy for customizing policies. It seems useful to me, but a broader perspective would help. Thanks a lot. Cheers, Brook