2019-06-04 05:09:16 +08:00
|
|
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
2016-08-23 01:54:18 +08:00
|
|
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-11-07 03:09:30 +08:00
|
|
|
#include <spdlog/tweakme.h>
|
|
|
|
#include <spdlog/details/null_mutex.h>
|
2018-02-23 20:34:25 +08:00
|
|
|
|
2016-08-23 01:54:18 +08:00
|
|
|
#include <atomic>
|
2018-03-09 21:24:37 +08:00
|
|
|
#include <chrono>
|
|
|
|
#include <initializer_list>
|
|
|
|
#include <memory>
|
2019-07-16 20:50:42 +08:00
|
|
|
#include <exception>
|
2018-03-09 21:24:37 +08:00
|
|
|
#include <string>
|
2019-04-06 06:44:03 +08:00
|
|
|
#include <type_traits>
|
2019-04-27 07:33:33 +08:00
|
|
|
#include <functional>
|
2021-11-11 00:08:24 +08:00
|
|
|
#include <cstdio>
|
2023-09-15 20:49:52 +08:00
|
|
|
#include <cstdint>
|
|
|
|
#include <version>
|
|
|
|
|
2023-09-16 02:10:47 +08:00
|
|
|
#if __cpp_lib_source_location >= 201907
|
|
|
|
# include <source_location>
|
|
|
|
# define SPDLOG_STD_SOURCE_LOCATION
|
|
|
|
#elif __has_include(<experimental/source_location>)
|
|
|
|
# include <experimental/source_location>
|
|
|
|
# define SPDLOG_EXPERIMENTAL_SOURCE_LOCATION
|
|
|
|
#endif
|
2016-08-23 01:54:18 +08:00
|
|
|
|
2021-11-14 00:29:05 +08:00
|
|
|
#ifdef SPDLOG_USE_STD_FORMAT
|
2022-11-13 05:07:11 +08:00
|
|
|
# if __cpp_lib_format >= 202207L
|
|
|
|
# include <format>
|
|
|
|
# else
|
|
|
|
# include <string_view>
|
|
|
|
# endif
|
2021-11-14 00:29:05 +08:00
|
|
|
#endif
|
|
|
|
|
2019-05-18 12:09:22 +08:00
|
|
|
#ifdef SPDLOG_COMPILED_LIB
|
2021-06-26 22:36:57 +08:00
|
|
|
# undef SPDLOG_HEADER_ONLY
|
2021-11-25 07:16:28 +08:00
|
|
|
# if defined(SPDLOG_SHARED_LIB)
|
|
|
|
# if defined(_WIN32)
|
|
|
|
# ifdef spdlog_EXPORTS
|
|
|
|
# define SPDLOG_API __declspec(dllexport)
|
|
|
|
# else // !spdlog_EXPORTS
|
|
|
|
# define SPDLOG_API __declspec(dllimport)
|
|
|
|
# endif
|
|
|
|
# else // !defined(_WIN32)
|
2021-12-20 01:37:21 +08:00
|
|
|
# define SPDLOG_API __attribute__((visibility("default")))
|
2021-06-26 22:36:57 +08:00
|
|
|
# endif
|
2021-11-25 07:16:28 +08:00
|
|
|
# else // !defined(SPDLOG_SHARED_LIB)
|
2021-06-26 22:36:57 +08:00
|
|
|
# define SPDLOG_API
|
|
|
|
# endif
|
|
|
|
# define SPDLOG_INLINE
|
2020-04-28 23:42:59 +08:00
|
|
|
#else // !defined(SPDLOG_COMPILED_LIB)
|
2021-06-26 22:36:57 +08:00
|
|
|
# define SPDLOG_API
|
|
|
|
# define SPDLOG_HEADER_ONLY
|
|
|
|
# define SPDLOG_INLINE inline
|
2020-04-28 23:37:57 +08:00
|
|
|
#endif // #ifdef SPDLOG_COMPILED_LIB
|
2019-04-05 21:44:17 +08:00
|
|
|
|
2019-11-07 03:09:30 +08:00
|
|
|
#include <spdlog/fmt/fmt.h>
|
2019-05-12 05:32:57 +08:00
|
|
|
|
2022-04-22 09:46:58 +08:00
|
|
|
#if !defined(SPDLOG_USE_STD_FORMAT) && FMT_VERSION >= 80000 // backward compatibility with fmt versions older than 8
|
|
|
|
# define SPDLOG_FMT_RUNTIME(format_string) fmt::runtime(format_string)
|
2022-05-19 07:30:36 +08:00
|
|
|
# define SPDLOG_FMT_STRING(format_string) FMT_STRING(format_string)
|
2022-04-22 09:46:58 +08:00
|
|
|
#else
|
|
|
|
# define SPDLOG_FMT_RUNTIME(format_string) format_string
|
2022-05-19 07:30:36 +08:00
|
|
|
# define SPDLOG_FMT_STRING(format_string) format_string
|
2021-06-27 00:43:37 +08:00
|
|
|
#endif
|
|
|
|
|
2019-01-11 01:18:31 +08:00
|
|
|
#ifndef SPDLOG_FUNCTION
|
2021-06-26 22:36:57 +08:00
|
|
|
# define SPDLOG_FUNCTION static_cast<const char *>(__FUNCTION__)
|
2019-01-11 01:18:31 +08:00
|
|
|
#endif
|
|
|
|
|
2019-08-19 00:46:28 +08:00
|
|
|
#ifdef SPDLOG_NO_EXCEPTIONS
|
2021-06-26 22:36:57 +08:00
|
|
|
# define SPDLOG_TRY
|
|
|
|
# define SPDLOG_THROW(ex) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
printf("spdlog fatal error: %s\n", ex.what()); \
|
|
|
|
std::abort(); \
|
|
|
|
} while (0)
|
|
|
|
# define SPDLOG_CATCH_STD
|
2019-08-19 00:46:28 +08:00
|
|
|
#else
|
2021-06-26 22:36:57 +08:00
|
|
|
# define SPDLOG_TRY try
|
|
|
|
# define SPDLOG_THROW(ex) throw(ex)
|
|
|
|
# define SPDLOG_CATCH_STD \
|
2023-06-07 18:23:44 +08:00
|
|
|
catch (const std::exception &) \
|
|
|
|
{}
|
2019-08-19 00:46:28 +08:00
|
|
|
#endif
|
|
|
|
|
2019-04-06 18:45:33 +08:00
|
|
|
namespace spdlog {
|
|
|
|
|
|
|
|
class formatter;
|
|
|
|
|
|
|
|
namespace sinks {
|
|
|
|
class sink;
|
|
|
|
}
|
|
|
|
|
2019-04-06 04:05:46 +08:00
|
|
|
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
2019-04-06 06:37:27 +08:00
|
|
|
using filename_t = std::wstring;
|
2021-01-06 16:55:46 +08:00
|
|
|
// allow macro expansion to occur in SPDLOG_FILENAME_T
|
2021-06-26 22:36:57 +08:00
|
|
|
# define SPDLOG_FILENAME_T_INNER(s) L##s
|
|
|
|
# define SPDLOG_FILENAME_T(s) SPDLOG_FILENAME_T_INNER(s)
|
2019-04-06 04:05:46 +08:00
|
|
|
#else
|
2019-04-06 06:37:27 +08:00
|
|
|
using filename_t = std::string;
|
2021-06-26 22:36:57 +08:00
|
|
|
# define SPDLOG_FILENAME_T(s) s
|
2019-04-06 04:05:46 +08:00
|
|
|
#endif
|
|
|
|
|
2016-08-23 01:54:18 +08:00
|
|
|
using log_clock = std::chrono::system_clock;
|
2018-03-09 21:24:37 +08:00
|
|
|
using sink_ptr = std::shared_ptr<sinks::sink>;
|
|
|
|
using sinks_init_list = std::initializer_list<sink_ptr>;
|
2019-04-27 07:33:33 +08:00
|
|
|
using err_handler = std::function<void(const std::string &err_msg)>;
|
2021-11-14 00:29:05 +08:00
|
|
|
#ifdef SPDLOG_USE_STD_FORMAT
|
|
|
|
namespace fmt_lib = std;
|
|
|
|
|
|
|
|
using string_view_t = std::string_view;
|
|
|
|
using memory_buf_t = std::string;
|
|
|
|
|
|
|
|
template<typename... Args>
|
2022-11-13 05:07:11 +08:00
|
|
|
# if __cpp_lib_format >= 202207L
|
|
|
|
using format_string_t = std::format_string<Args...>;
|
|
|
|
# else
|
2021-11-14 00:29:05 +08:00
|
|
|
using format_string_t = std::string_view;
|
2022-11-13 05:07:11 +08:00
|
|
|
# endif
|
2021-11-14 00:29:05 +08:00
|
|
|
|
2022-04-27 11:25:35 +08:00
|
|
|
# define SPDLOG_BUF_TO_STRING(x) x
|
2021-11-17 05:42:06 +08:00
|
|
|
#else // use fmt lib instead of std::format
|
2021-11-14 00:29:05 +08:00
|
|
|
namespace fmt_lib = fmt;
|
|
|
|
|
2019-09-20 05:18:36 +08:00
|
|
|
using string_view_t = fmt::basic_string_view<char>;
|
2019-08-28 23:46:09 +08:00
|
|
|
using memory_buf_t = fmt::basic_memory_buffer<char, 250>;
|
|
|
|
|
2021-11-14 00:29:05 +08:00
|
|
|
template<typename... Args>
|
|
|
|
using format_string_t = fmt::format_string<Args...>;
|
|
|
|
|
2023-07-28 22:15:10 +08:00
|
|
|
# if defined(SPDLOG_WCHAR_FILENAMES)
|
2021-11-16 23:10:02 +08:00
|
|
|
using wstring_view_t = fmt::basic_string_view<wchar_t>;
|
2021-11-17 05:42:06 +08:00
|
|
|
using wmemory_buf_t = fmt::basic_memory_buffer<wchar_t, 250>;
|
2021-11-16 23:10:02 +08:00
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
using wformat_string_t = fmt::wformat_string<Args...>;
|
|
|
|
# endif
|
2022-04-27 11:25:35 +08:00
|
|
|
# define SPDLOG_BUF_TO_STRING(x) fmt::to_string(x)
|
2021-11-14 00:29:05 +08:00
|
|
|
#endif
|
2021-08-09 16:20:59 +08:00
|
|
|
|
2016-08-23 01:54:18 +08:00
|
|
|
#if defined(SPDLOG_NO_ATOMIC_LEVELS)
|
|
|
|
using level_t = details::null_atomic_int;
|
|
|
|
#else
|
2016-10-09 06:55:47 +08:00
|
|
|
using level_t = std::atomic<int>;
|
2016-08-23 01:54:18 +08:00
|
|
|
#endif
|
|
|
|
|
2018-11-12 00:15:24 +08:00
|
|
|
#define SPDLOG_LEVEL_TRACE 0
|
|
|
|
#define SPDLOG_LEVEL_DEBUG 1
|
|
|
|
#define SPDLOG_LEVEL_INFO 2
|
|
|
|
#define SPDLOG_LEVEL_WARN 3
|
|
|
|
#define SPDLOG_LEVEL_ERROR 4
|
|
|
|
#define SPDLOG_LEVEL_CRITICAL 5
|
|
|
|
#define SPDLOG_LEVEL_OFF 6
|
|
|
|
|
|
|
|
#if !defined(SPDLOG_ACTIVE_LEVEL)
|
2021-06-26 22:36:57 +08:00
|
|
|
# define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
|
2018-11-12 00:15:24 +08:00
|
|
|
#endif
|
|
|
|
|
2023-09-15 20:49:52 +08:00
|
|
|
// Is convertable to string_view_t ?
|
2023-09-16 02:10:47 +08:00
|
|
|
template<typename T>
|
2023-09-15 20:49:52 +08:00
|
|
|
using is_convertible_to_sv = std::enable_if_t<std::is_convertible_v<T, string_view_t>>;
|
|
|
|
|
2018-03-09 21:24:37 +08:00
|
|
|
// Log level enum
|
|
|
|
namespace level {
|
2022-01-11 22:58:58 +08:00
|
|
|
enum level_enum : int
|
2016-08-23 01:54:18 +08:00
|
|
|
{
|
2018-11-12 00:15:24 +08:00
|
|
|
trace = SPDLOG_LEVEL_TRACE,
|
|
|
|
debug = SPDLOG_LEVEL_DEBUG,
|
|
|
|
info = SPDLOG_LEVEL_INFO,
|
|
|
|
warn = SPDLOG_LEVEL_WARN,
|
|
|
|
err = SPDLOG_LEVEL_ERROR,
|
|
|
|
critical = SPDLOG_LEVEL_CRITICAL,
|
|
|
|
off = SPDLOG_LEVEL_OFF,
|
2020-02-15 18:06:01 +08:00
|
|
|
n_levels
|
2018-02-25 05:35:09 +08:00
|
|
|
};
|
2016-08-23 01:54:18 +08:00
|
|
|
|
2021-07-29 15:09:52 +08:00
|
|
|
#define SPDLOG_LEVEL_NAME_TRACE spdlog::string_view_t("trace", 5)
|
|
|
|
#define SPDLOG_LEVEL_NAME_DEBUG spdlog::string_view_t("debug", 5)
|
|
|
|
#define SPDLOG_LEVEL_NAME_INFO spdlog::string_view_t("info", 4)
|
|
|
|
#define SPDLOG_LEVEL_NAME_WARNING spdlog::string_view_t("warning", 7)
|
|
|
|
#define SPDLOG_LEVEL_NAME_ERROR spdlog::string_view_t("error", 5)
|
|
|
|
#define SPDLOG_LEVEL_NAME_CRITICAL spdlog::string_view_t("critical", 8)
|
|
|
|
#define SPDLOG_LEVEL_NAME_OFF spdlog::string_view_t("off", 3)
|
2021-05-19 07:36:45 +08:00
|
|
|
|
2017-07-05 08:46:45 +08:00
|
|
|
#if !defined(SPDLOG_LEVEL_NAMES)
|
2021-06-26 22:36:57 +08:00
|
|
|
# define SPDLOG_LEVEL_NAMES \
|
|
|
|
{ \
|
|
|
|
SPDLOG_LEVEL_NAME_TRACE, SPDLOG_LEVEL_NAME_DEBUG, SPDLOG_LEVEL_NAME_INFO, SPDLOG_LEVEL_NAME_WARNING, SPDLOG_LEVEL_NAME_ERROR, \
|
|
|
|
SPDLOG_LEVEL_NAME_CRITICAL, SPDLOG_LEVEL_NAME_OFF \
|
|
|
|
}
|
2017-07-05 08:46:45 +08:00
|
|
|
#endif
|
2019-02-19 05:33:41 +08:00
|
|
|
|
|
|
|
#if !defined(SPDLOG_SHORT_LEVEL_NAMES)
|
2019-05-12 05:22:39 +08:00
|
|
|
|
2021-06-26 22:36:57 +08:00
|
|
|
# define SPDLOG_SHORT_LEVEL_NAMES \
|
|
|
|
{ \
|
|
|
|
"T", "D", "I", "W", "E", "C", "O" \
|
|
|
|
}
|
2019-02-19 05:33:41 +08:00
|
|
|
#endif
|
2016-08-23 01:54:18 +08:00
|
|
|
|
2023-07-28 23:27:05 +08:00
|
|
|
SPDLOG_API const string_view_t &to_string_view(spdlog::level::level_enum l) noexcept;
|
|
|
|
SPDLOG_API const char *to_short_c_str(spdlog::level::level_enum l) noexcept;
|
|
|
|
SPDLOG_API spdlog::level::level_enum from_str(const std::string &name) noexcept;
|
2018-03-09 06:08:24 +08:00
|
|
|
|
2018-03-09 21:24:37 +08:00
|
|
|
} // namespace level
|
2016-08-23 01:54:18 +08:00
|
|
|
|
2019-05-09 19:16:38 +08:00
|
|
|
//
|
|
|
|
// Color mode used by sinks with color support.
|
|
|
|
//
|
|
|
|
enum class color_mode
|
|
|
|
{
|
|
|
|
always,
|
|
|
|
automatic,
|
|
|
|
never
|
|
|
|
};
|
|
|
|
|
2017-05-31 06:05:25 +08:00
|
|
|
//
|
|
|
|
// Pattern time - specific time getting to use for pattern_formatter.
|
|
|
|
// local time by default
|
|
|
|
//
|
2017-06-01 00:52:12 +08:00
|
|
|
enum class pattern_time_type
|
2017-05-31 06:05:25 +08:00
|
|
|
{
|
2017-06-01 08:42:10 +08:00
|
|
|
local, // log localtime
|
|
|
|
utc // log utc
|
2017-05-31 06:05:25 +08:00
|
|
|
};
|
2016-08-23 01:54:18 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Log exception
|
|
|
|
//
|
2020-03-10 03:02:16 +08:00
|
|
|
class SPDLOG_API spdlog_ex : public std::exception
|
2016-08-23 01:54:18 +08:00
|
|
|
{
|
|
|
|
public:
|
2019-05-12 01:15:03 +08:00
|
|
|
explicit spdlog_ex(std::string msg);
|
|
|
|
spdlog_ex(const std::string &msg, int last_errno);
|
2023-07-28 23:27:05 +08:00
|
|
|
const char *what() const noexcept override;
|
2018-06-14 01:16:31 +08:00
|
|
|
|
2016-08-23 01:54:18 +08:00
|
|
|
private:
|
2018-08-16 00:01:44 +08:00
|
|
|
std::string msg_;
|
2016-08-23 01:54:18 +08:00
|
|
|
};
|
|
|
|
|
2021-03-17 06:25:26 +08:00
|
|
|
[[noreturn]] SPDLOG_API void throw_spdlog_ex(const std::string &msg, int last_errno);
|
|
|
|
[[noreturn]] SPDLOG_API void throw_spdlog_ex(std::string msg);
|
2020-03-22 05:25:12 +08:00
|
|
|
|
2018-11-23 00:47:50 +08:00
|
|
|
struct source_loc
|
|
|
|
{
|
2023-07-28 23:27:05 +08:00
|
|
|
constexpr source_loc() = default;
|
2023-09-15 20:49:52 +08:00
|
|
|
constexpr source_loc(const char *filename_in, std::uint_least32_t line_in, const char *funcname_in)
|
2019-02-01 20:59:50 +08:00
|
|
|
: filename{filename_in}
|
2019-04-06 06:44:03 +08:00
|
|
|
, line{line_in}
|
2019-02-01 20:59:50 +08:00
|
|
|
, funcname{funcname_in}
|
2019-05-12 05:22:39 +08:00
|
|
|
{}
|
2018-11-25 06:44:51 +08:00
|
|
|
|
2023-09-15 20:49:52 +08:00
|
|
|
#ifdef SPDLOG_STD_SOURCE_LOCATION
|
|
|
|
static constexpr source_loc current(const std::source_location source_location = std::source_location::current())
|
|
|
|
{
|
|
|
|
return source_loc{source_location.file_name(), source_location.line(), source_location.function_name()};
|
|
|
|
}
|
|
|
|
#elif defined(SPDLOG_EXPERIMENTAL_SOURCE_LOCATION)
|
2023-09-16 02:10:47 +08:00
|
|
|
static constexpr source_loc current(
|
|
|
|
const std::experimental::source_location source_location = std::experimental::source_location::current())
|
2023-09-15 20:49:52 +08:00
|
|
|
{
|
|
|
|
return source_loc{source_location.file_name(), source_location.line(), source_location.function_name()};
|
|
|
|
}
|
|
|
|
#else // no source location support
|
|
|
|
static constexpr source_loc current()
|
|
|
|
{
|
2023-09-16 02:10:47 +08:00
|
|
|
return source_loc{};
|
2023-09-15 20:49:52 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
[[nodiscard]] constexpr bool empty() const noexcept
|
2018-11-25 06:44:51 +08:00
|
|
|
{
|
|
|
|
return line == 0;
|
|
|
|
}
|
2019-04-06 06:44:03 +08:00
|
|
|
const char *filename{nullptr};
|
2023-09-15 20:49:52 +08:00
|
|
|
std::uint_least32_t line{0};
|
2019-04-06 06:44:03 +08:00
|
|
|
const char *funcname{nullptr};
|
2018-11-23 00:47:50 +08:00
|
|
|
};
|
|
|
|
|
2023-09-16 02:07:09 +08:00
|
|
|
// to capture caller's current source location and format string at compile time.
|
2023-09-15 20:49:52 +08:00
|
|
|
struct loc_with_fmt
|
|
|
|
{
|
|
|
|
source_loc loc;
|
|
|
|
string_view_t fmt_string;
|
|
|
|
template<typename S, typename = is_convertible_to_sv<S>>
|
2023-09-16 02:10:47 +08:00
|
|
|
constexpr loc_with_fmt(S fmt_str, source_loc loc = source_loc::current()) noexcept
|
|
|
|
: loc(loc)
|
|
|
|
, fmt_string(fmt_str)
|
|
|
|
{}
|
2023-09-16 06:00:55 +08:00
|
|
|
|
|
|
|
#ifndef SPDLOG_USE_STD_FORMAT
|
|
|
|
constexpr loc_with_fmt(fmt::runtime_format_string<char> fmt_str, source_loc loc = source_loc::current()) noexcept
|
|
|
|
: loc(loc)
|
|
|
|
, fmt_string(fmt_str.str)
|
|
|
|
{}
|
|
|
|
#endif
|
2023-09-15 20:49:52 +08:00
|
|
|
};
|
|
|
|
|
2021-11-16 22:41:04 +08:00
|
|
|
struct file_event_handlers
|
2021-11-11 00:08:24 +08:00
|
|
|
{
|
2022-05-13 08:49:01 +08:00
|
|
|
file_event_handlers()
|
2022-05-14 04:06:11 +08:00
|
|
|
: before_open(nullptr)
|
2022-05-19 07:30:36 +08:00
|
|
|
, after_open(nullptr)
|
2022-05-14 04:06:11 +08:00
|
|
|
, before_close(nullptr)
|
|
|
|
, after_close(nullptr)
|
2022-05-13 08:49:01 +08:00
|
|
|
{}
|
|
|
|
|
2021-11-13 17:19:23 +08:00
|
|
|
std::function<void(const filename_t &filename)> before_open;
|
2021-11-11 00:08:24 +08:00
|
|
|
std::function<void(const filename_t &filename, std::FILE *file_stream)> after_open;
|
|
|
|
std::function<void(const filename_t &filename, std::FILE *file_stream)> before_close;
|
|
|
|
std::function<void(const filename_t &filename)> after_close;
|
2021-11-16 22:41:04 +08:00
|
|
|
};
|
2021-11-11 00:08:24 +08:00
|
|
|
|
2018-09-27 04:48:36 +08:00
|
|
|
namespace details {
|
2021-12-20 01:37:21 +08:00
|
|
|
|
2022-11-13 05:07:11 +08:00
|
|
|
// to_string_view
|
|
|
|
|
2023-07-28 23:27:05 +08:00
|
|
|
constexpr spdlog::string_view_t to_string_view(const memory_buf_t &buf) noexcept
|
2022-11-13 05:07:11 +08:00
|
|
|
{
|
|
|
|
return spdlog::string_view_t{buf.data(), buf.size()};
|
|
|
|
}
|
|
|
|
|
2023-07-28 23:27:05 +08:00
|
|
|
constexpr spdlog::string_view_t to_string_view(spdlog::string_view_t str) noexcept
|
2022-11-13 05:07:11 +08:00
|
|
|
{
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2023-07-28 22:15:10 +08:00
|
|
|
#if defined(SPDLOG_WCHAR_FILENAMES)
|
2023-07-28 23:27:05 +08:00
|
|
|
constexpr spdlog::wstring_view_t to_string_view(const wmemory_buf_t &buf) noexcept
|
2022-11-13 05:07:11 +08:00
|
|
|
{
|
|
|
|
return spdlog::wstring_view_t{buf.data(), buf.size()};
|
|
|
|
}
|
|
|
|
|
2023-07-28 23:27:05 +08:00
|
|
|
constexpr spdlog::wstring_view_t to_string_view(spdlog::wstring_view_t str) noexcept
|
2022-11-13 05:07:11 +08:00
|
|
|
{
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SPDLOG_USE_STD_FORMAT
|
|
|
|
template<typename T, typename... Args>
|
|
|
|
inline fmt::basic_string_view<T> to_string_view(fmt::basic_format_string<T, Args...> fmt)
|
|
|
|
{
|
|
|
|
return fmt;
|
|
|
|
}
|
|
|
|
#elif __cpp_lib_format >= 202207L
|
|
|
|
template<typename T, typename... Args>
|
2023-07-28 23:27:05 +08:00
|
|
|
constexpr std::basic_string_view<T> to_string_view(std::basic_format_string<T, Args...> fmt) noexcept
|
2022-11-13 05:07:11 +08:00
|
|
|
{
|
|
|
|
return fmt.get();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-09-27 04:48:36 +08:00
|
|
|
} // namespace details
|
2018-03-09 21:24:37 +08:00
|
|
|
} // namespace spdlog
|
2019-05-12 01:15:03 +08:00
|
|
|
|
2019-05-12 05:22:39 +08:00
|
|
|
#ifdef SPDLOG_HEADER_ONLY
|
2021-06-26 22:36:57 +08:00
|
|
|
# include "common-inl.h"
|
2019-05-18 12:09:22 +08:00
|
|
|
#endif
|