workaround MSVC weirdness

This commit is contained in:
Michael Davidsaver
2020-04-13 07:07:47 -07:00
parent f1cc5a2aa6
commit 5d7de7254f
+10
View File
@@ -74,11 +74,21 @@ void xerrlogHexPrintf(const void *buf, size_t buflen);
* log_info_printf(blah, "blah happened with %d\n", x);
* @endcode
*/
#ifndef _MSC_VER
#define log_printf(LOGGER, LVL, FMT, ...) do{ \
if((LOGGER).test(LVL)) \
::pvxs::detail:: _log_printf(unsigned(LVL), "%s " FMT, ::pvxs::detail::log_prefix((LOGGER).name, LVL), __VA_ARGS__); \
}while(0)
#else
// for some strange reason, trying to prepend any string to the format spec.
// doesn't work right with MSVC
#define log_printf(LOGGER, LVL, FMT, ...) do{ \
if((LOGGER).test(LVL)) \
::pvxs::detail:: _log_printf(unsigned(LVL), "X " FMT, __VA_ARGS__); \
}while(0)
#endif
#define log_crit_printf(LOGGER, ...) log_printf(LOGGER, ::pvxs::Level::Crit, __VA_ARGS__)
#define log_err_printf(LOGGER, ...) log_printf(LOGGER, ::pvxs::Level::Err, __VA_ARGS__)
#define log_warn_printf(LOGGER, ...) log_printf(LOGGER, ::pvxs::Level::Warn, __VA_ARGS__)