mirror of
https://github.com/gabime/spdlog.git
synced 2025-04-01 02:42:41 +08:00
alwaus use std::string_view
This commit is contained in:
parent
62534f2e4e
commit
fb3969d540
@ -95,28 +95,28 @@ using sink_ptr = std::shared_ptr<sinks::sink>;
|
|||||||
using sinks_init_list = std::initializer_list<sink_ptr>;
|
using sinks_init_list = std::initializer_list<sink_ptr>;
|
||||||
using err_handler = std::function<void(const std::string &err_msg)>;
|
using err_handler = std::function<void(const std::string &err_msg)>;
|
||||||
|
|
||||||
|
using string_view_t = std::basic_string_view<char>;
|
||||||
|
using wstring_view_t = std::basic_string_view<wchar_t>;
|
||||||
|
|
||||||
#ifdef SPDLOG_USE_STD_FORMAT
|
#ifdef SPDLOG_USE_STD_FORMAT
|
||||||
namespace fmt_lib = std;
|
namespace fmt_lib = std;
|
||||||
using string_view_t = std::string_view;
|
|
||||||
using memory_buf_t = std::string;
|
using memory_buf_t = std::string;
|
||||||
using wstring_view_t = std::wstring_view;
|
|
||||||
using wmemory_buf_t = std::wstring;
|
using wmemory_buf_t = std::wstring;
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
#if __cpp_lib_format >= 202207L
|
#if __cpp_lib_format >= 202207L
|
||||||
using format_string_t = std::format_string<Args...>;
|
using format_string_t = std::format_string<Args...>;
|
||||||
#else
|
#else
|
||||||
using format_string_t = std::string_view;
|
using format_string_t = std::string_view;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SPDLOG_BUF_TO_STRING(x) x
|
#define SPDLOG_BUF_TO_STRING(x) x
|
||||||
#else // use fmt lib instead of std::format
|
#else // use fmt lib instead of std::format
|
||||||
namespace fmt_lib = fmt;
|
namespace fmt_lib = fmt;
|
||||||
using string_view_t = fmt::basic_string_view<char>;
|
|
||||||
using memory_buf_t = fmt::basic_memory_buffer<char, 250>;
|
using memory_buf_t = fmt::basic_memory_buffer<char, 250>;
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
using format_string_t = fmt::format_string<Args...>;
|
using format_string_t = fmt::format_string<Args...>;
|
||||||
using wstring_view_t = fmt::basic_string_view<wchar_t>;
|
|
||||||
using wmemory_buf_t = fmt::basic_memory_buffer<wchar_t, 250>;
|
using wmemory_buf_t = fmt::basic_memory_buffer<wchar_t, 250>;
|
||||||
#define SPDLOG_BUF_TO_STRING(x) fmt::to_string(x)
|
#define SPDLOG_BUF_TO_STRING(x) fmt::to_string(x)
|
||||||
#endif // SPDLOG_USE_STD_FORMAT
|
#endif // SPDLOG_USE_STD_FORMAT
|
||||||
|
@ -192,7 +192,7 @@ protected:
|
|||||||
// common implementation for after templated public api has been resolved to format string and
|
// common implementation for after templated public api has been resolved to format string and
|
||||||
// args
|
// args
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void log_with_format_(source_loc loc, level lvl, string_view_t fmt, Args &&...args) {
|
void log_with_format_(source_loc loc, level lvl, format_string_t<Args...> fmt, Args &&...args) {
|
||||||
assert(should_log(lvl));
|
assert(should_log(lvl));
|
||||||
SPDLOG_TRY {
|
SPDLOG_TRY {
|
||||||
#ifdef SPDLOG_USE_STD_FORMAT
|
#ifdef SPDLOG_USE_STD_FORMAT
|
||||||
|
Loading…
Reference in New Issue
Block a user