From 5f53b41dd7438906a43fb8ebf6984efe89862970 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 15 Sep 2021 17:33:33 +0200 Subject: Fixed logging.h so it doesn't leak `using namespace std::literals` declaration --- zencore/include/zencore/logging.h | 49 ++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'zencore/include') diff --git a/zencore/include/zencore/logging.h b/zencore/include/zencore/logging.h index 4eee20414..8e6b3a244 100644 --- a/zencore/include/zencore/logging.h +++ b/zencore/include/zencore/logging.h @@ -39,11 +39,44 @@ using zen::Log; // Helper macros for logging -using namespace std::literals; - -#define ZEN_TRACE(fmtstr, ...) Log().trace(fmtstr##sv, __VA_ARGS__) -#define ZEN_DEBUG(fmtstr, ...) Log().debug(fmtstr##sv, __VA_ARGS__) -#define ZEN_INFO(fmtstr, ...) Log().info(fmtstr##sv, __VA_ARGS__) -#define ZEN_WARN(fmtstr, ...) Log().warn(fmtstr##sv, __VA_ARGS__) -#define ZEN_ERROR(fmtstr, ...) Log().error(fmtstr##sv, __VA_ARGS__) -#define ZEN_CRITICAL(fmtstr, ...) Log().critical(fmtstr##sv, __VA_ARGS__) +#define ZEN_TRACE(fmtstr, ...) \ + do \ + { \ + using namespace std::literals; \ + Log().trace(fmtstr##sv, __VA_ARGS__); \ + } while (false) + +#define ZEN_DEBUG(fmtstr, ...) \ + do \ + { \ + using namespace std::literals; \ + Log().debug(fmtstr##sv, __VA_ARGS__); \ + } while (false) + +#define ZEN_INFO(fmtstr, ...) \ + do \ + { \ + using namespace std::literals; \ + Log().info(fmtstr##sv, __VA_ARGS__); \ + } while (false) + +#define ZEN_WARN(fmtstr, ...) \ + do \ + { \ + using namespace std::literals; \ + Log().warn(fmtstr##sv, __VA_ARGS__); \ + } while (false) + +#define ZEN_ERROR(fmtstr, ...) \ + do \ + { \ + using namespace std::literals; \ + Log().error(fmtstr##sv, __VA_ARGS__); \ + } while (false) + +#define ZEN_CRITICAL(fmtstr, ...) \ + do \ + { \ + using namespace std::literals; \ + Log().critical(fmtstr##sv, __VA_ARGS__); \ + } while (false) -- cgit v1.2.3