From be33f5eb8981084b277c6e6d7d66cbfc8762e907 Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Sat, 6 Jul 2019 18:59:45 +0200 Subject: [PATCH 1/3] Added wstring_view_t --- include/spdlog/common.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 2f23e9e4..f0a5736b 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -94,6 +94,13 @@ template using basic_string_view_t = fmt::basic_string_view; #endif using string_view_t = basic_string_view_t; +#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT +#ifndef _WIN32 +#error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows +#else +using wstring_view_t = basic_string_view_t; +#endif // _WIN32 +#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT #if defined(SPDLOG_NO_ATOMIC_LEVELS) using level_t = details::null_atomic_int; From ae92279f5c6f6e770ee4ab0c951341325a860166 Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Sat, 6 Jul 2019 19:00:17 +0200 Subject: [PATCH 2/3] Update spdlog.h --- include/spdlog/spdlog.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 319d4d6f..4abb3098 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -115,49 +115,49 @@ spdlog::logger *default_logger_raw(); void set_default_logger(std::shared_ptr default_logger); template -inline void log(source_loc source, level::level_enum lvl, const char *fmt, const Args &... args) +inline void log(source_loc source, level::level_enum lvl, string_view_t fmt, const Args &... args) { default_logger_raw()->log(source, lvl, fmt, args...); } template -inline void log(level::level_enum lvl, const char *fmt, const Args &... args) +inline void log(level::level_enum lvl, string_view_t fmt, const Args &... args) { default_logger_raw()->log(source_loc{}, lvl, fmt, args...); } template -inline void trace(const char *fmt, const Args &... args) +inline void trace(string_view_t fmt, const Args &... args) { default_logger_raw()->trace(fmt, args...); } template -inline void debug(const char *fmt, const Args &... args) +inline void debug(string_view_t fmt, const Args &... args) { default_logger_raw()->debug(fmt, args...); } template -inline void info(const char *fmt, const Args &... args) +inline void info(string_view_t fmt, const Args &... args) { default_logger_raw()->info(fmt, args...); } template -inline void warn(const char *fmt, const Args &... args) +inline void warn(string_view_t fmt, const Args &... args) { default_logger_raw()->warn(fmt, args...); } template -inline void error(const char *fmt, const Args &... args) +inline void error(string_view_t fmt, const Args &... args) { default_logger_raw()->error(fmt, args...); } template -inline void critical(const char *fmt, const Args &... args) +inline void critical(string_view_t fmt, const Args &... args) { default_logger_raw()->critical(fmt, args...); } @@ -206,43 +206,43 @@ inline void critical(const T &msg) #ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT template -inline void log(level::level_enum lvl, const wchar_t *fmt, const Args &... args) +inline void log(level::level_enum lvl, wstring_view_t fmt, const Args &... args) { default_logger_raw()->log(lvl, fmt, args...); } template -inline void trace(const wchar_t *fmt, const Args &... args) +inline void trace(wstring_view_t fmt, const Args &... args) { default_logger_raw()->trace(fmt, args...); } template -inline void debug(const wchar_t *fmt, const Args &... args) +inline void debug(wstring_view_t fmt, const Args &... args) { default_logger_raw()->debug(fmt, args...); } template -inline void info(const wchar_t *fmt, const Args &... args) +inline void info(wstring_view_t fmt, const Args &... args) { default_logger_raw()->info(fmt, args...); } template -inline void warn(const wchar_t *fmt, const Args &... args) +inline void warn(wstring_view_t fmt, const Args &... args) { default_logger_raw()->warn(fmt, args...); } template -inline void error(const wchar_t *fmt, const Args &... args) +inline void error(wstring_view_t fmt, const Args &... args) { default_logger_raw()->error(fmt, args...); } template -inline void critical(const wchar_t *fmt, const Args &... args) +inline void critical(wstring_view_t fmt, const Args &... args) { default_logger_raw()->critical(fmt, args...); } From 5a7bcd0a4fa167cc254013c24703ea10a7562cdf Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Sat, 6 Jul 2019 19:00:49 +0200 Subject: [PATCH 3/3] Update logger.h --- include/spdlog/logger.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index 1d831362..6e120e41 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -63,7 +63,7 @@ public: void swap(spdlog::logger &other); template - void force_log(source_loc loc, level::level_enum lvl, const char *fmt, const Args &... args) + void force_log(source_loc loc, level::level_enum lvl, string_view_t fmt, const Args &... args) { try { @@ -83,7 +83,7 @@ public: } template - void log(source_loc loc, level::level_enum lvl, const char *fmt, const Args &... args) + void log(source_loc loc, level::level_enum lvl, string_view_t fmt, const Args &... args) { if (should_log(lvl)) { @@ -92,7 +92,7 @@ public: } template - void log(level::level_enum lvl, const char *fmt, const Args &... args) + void log(level::level_enum lvl, string_view_t fmt, const Args &... args) { log(source_loc{}, lvl, fmt, args...); } @@ -101,37 +101,37 @@ public: void log(level::level_enum lvl, const char *msg); template - void trace(const char *fmt, const Args &... args) + void trace(string_view_t fmt, const Args &... args) { log(level::trace, fmt, args...); } template - void debug(const char *fmt, const Args &... args) + void debug(string_view_t fmt, const Args &... args) { log(level::debug, fmt, args...); } template - void info(const char *fmt, const Args &... args) + void info(string_view_t fmt, const Args &... args) { log(level::info, fmt, args...); } template - void warn(const char *fmt, const Args &... args) + void warn(string_view_t fmt, const Args &... args) { log(level::warn, fmt, args...); } template - void error(const char *fmt, const Args &... args) + void error(string_view_t fmt, const Args &... args) { log(level::err, fmt, args...); } template - void critical(const char *fmt, const Args &... args) + void critical(string_view_t fmt, const Args &... args) { log(level::critical, fmt, args...); } @@ -231,7 +231,7 @@ public: #error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows #else template - void log(source_loc source, level::level_enum lvl, const wchar_t *fmt, const Args &... args) + void log(source_loc source, level::level_enum lvl, wstring_view_t fmt, const Args &... args) { if (!should_log(lvl)) { @@ -261,43 +261,43 @@ public: } template - void log(level::level_enum lvl, const wchar_t *fmt, const Args &... args) + void log(level::level_enum lvl, wstring_view_t fmt, const Args &... args) { log(source_loc{}, lvl, fmt, args...); } template - void trace(const wchar_t *fmt, const Args &... args) + void trace(wstring_view_t fmt, const Args &... args) { log(level::trace, fmt, args...); } template - void debug(const wchar_t *fmt, const Args &... args) + void debug(wstring_view_t fmt, const Args &... args) { log(level::debug, fmt, args...); } template - void info(const wchar_t *fmt, const Args &... args) + void info(wstring_view_t fmt, const Args &... args) { log(level::info, fmt, args...); } template - void warn(const wchar_t *fmt, const Args &... args) + void warn(wstring_view_t fmt, const Args &... args) { log(level::warn, fmt, args...); } template - void error(const wchar_t *fmt, const Args &... args) + void error(wstring_view_t fmt, const Args &... args) { log(level::err, fmt, args...); } template - void critical(const wchar_t *fmt, const Args &... args) + void critical(wstring_view_t fmt, const Args &... args) { log(level::critical, fmt, args...); }