mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-12 17:00:25 +08:00
Renamed string_view_type -> string_view_t
This commit is contained in:
parent
871cca2401
commit
392d126372
@ -58,9 +58,9 @@ using log_err_handler = std::function<void(const std::string &err_msg)>;
|
|||||||
|
|
||||||
// string_view type - either std::string_view or fmt::string_view (pre c++17)
|
// string_view type - either std::string_view or fmt::string_view (pre c++17)
|
||||||
#if defined(FMT_USE_STD_STRING_VIEW)
|
#if defined(FMT_USE_STD_STRING_VIEW)
|
||||||
using string_view_type = std::string_view;
|
using string_view_t = std::string_view;
|
||||||
#else
|
#else
|
||||||
using string_view_type = fmt::string_view;
|
using string_view_t = fmt::string_view;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SPDLOG_NO_ATOMIC_LEVELS)
|
#if defined(SPDLOG_NO_ATOMIC_LEVELS)
|
||||||
|
@ -14,9 +14,9 @@ namespace details {
|
|||||||
namespace fmt_helper {
|
namespace fmt_helper {
|
||||||
|
|
||||||
template<size_t Buffer_Size>
|
template<size_t Buffer_Size>
|
||||||
inline spdlog::string_view_type to_string_view(const fmt::basic_memory_buffer<char, Buffer_Size> &buf) SPDLOG_NOEXCEPT
|
inline spdlog::string_view_t to_string_view(const fmt::basic_memory_buffer<char, Buffer_Size> &buf) SPDLOG_NOEXCEPT
|
||||||
{
|
{
|
||||||
return spdlog::string_view_type(buf.data(), buf.size());
|
return spdlog::string_view_t(buf.data(), buf.size());
|
||||||
}
|
}
|
||||||
template<size_t Buffer_Size1, size_t Buffer_Size2>
|
template<size_t Buffer_Size1, size_t Buffer_Size2>
|
||||||
inline void append_buf(const fmt::basic_memory_buffer<char, Buffer_Size1> &buf, fmt::basic_memory_buffer<char, Buffer_Size2> &dest)
|
inline void append_buf(const fmt::basic_memory_buffer<char, Buffer_Size1> &buf, fmt::basic_memory_buffer<char, Buffer_Size2> &dest)
|
||||||
@ -26,7 +26,7 @@ inline void append_buf(const fmt::basic_memory_buffer<char, Buffer_Size1> &buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<size_t Buffer_Size>
|
template<size_t Buffer_Size>
|
||||||
inline void append_string_view(spdlog::string_view_type view, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
|
inline void append_string_view(spdlog::string_view_t view, fmt::basic_memory_buffer<char, Buffer_Size> &dest)
|
||||||
{
|
{
|
||||||
auto *buf_ptr = view.data();
|
auto *buf_ptr = view.data();
|
||||||
if (buf_ptr != nullptr)
|
if (buf_ptr != nullptr)
|
||||||
|
@ -17,7 +17,7 @@ struct log_msg
|
|||||||
{
|
{
|
||||||
log_msg() = default;
|
log_msg() = default;
|
||||||
|
|
||||||
log_msg(const std::string *loggers_name, level::level_enum lvl, string_view_type view)
|
log_msg(const std::string *loggers_name, level::level_enum lvl, string_view_t view)
|
||||||
: logger_name(loggers_name)
|
: logger_name(loggers_name)
|
||||||
, level(lvl)
|
, level(lvl)
|
||||||
#ifndef SPDLOG_NO_DATETIME
|
#ifndef SPDLOG_NO_DATETIME
|
||||||
@ -44,7 +44,7 @@ struct log_msg
|
|||||||
mutable size_t color_range_start{0};
|
mutable size_t color_range_start{0};
|
||||||
mutable size_t color_range_end{0};
|
mutable size_t color_range_end{0};
|
||||||
|
|
||||||
const string_view_type payload;
|
const string_view_t payload;
|
||||||
};
|
};
|
||||||
} // namespace details
|
} // namespace details
|
||||||
} // namespace spdlog
|
} // namespace spdlog
|
||||||
|
@ -81,13 +81,13 @@ inline void spdlog::logger::log(level::level_enum lvl, const char *msg)
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
details::log_msg log_msg(&name_, lvl, spdlog::string_view_type(msg));
|
details::log_msg log_msg(&name_, lvl, spdlog::string_view_t(msg));
|
||||||
sink_it_(log_msg);
|
sink_it_(log_msg);
|
||||||
}
|
}
|
||||||
SPDLOG_CATCH_AND_HANDLE
|
SPDLOG_CATCH_AND_HANDLE
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, typename std::enable_if<std::is_convertible<T, spdlog::string_view_type>::value, T>::type *>
|
template<class T, typename std::enable_if<std::is_convertible<T, spdlog::string_view_t>::value, T>::type *>
|
||||||
inline void spdlog::logger::log(level::level_enum lvl, const T &msg)
|
inline void spdlog::logger::log(level::level_enum lvl, const T &msg)
|
||||||
{
|
{
|
||||||
if (!should_log(lvl))
|
if (!should_log(lvl))
|
||||||
@ -96,13 +96,13 @@ inline void spdlog::logger::log(level::level_enum lvl, const T &msg)
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
details::log_msg log_msg(&name_, lvl, spdlog::string_view_type(msg));
|
details::log_msg log_msg(&name_, lvl, spdlog::string_view_t(msg));
|
||||||
sink_it_(log_msg);
|
sink_it_(log_msg);
|
||||||
}
|
}
|
||||||
SPDLOG_CATCH_AND_HANDLE
|
SPDLOG_CATCH_AND_HANDLE
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, typename std::enable_if<!std::is_convertible<T, spdlog::string_view_type>::value, T>::type *>
|
template<class T, typename std::enable_if<!std::is_convertible<T, spdlog::string_view_t>::value, T>::type *>
|
||||||
inline void spdlog::logger::log(level::level_enum lvl, const T &msg)
|
inline void spdlog::logger::log(level::level_enum lvl, const T &msg)
|
||||||
{
|
{
|
||||||
if (!should_log(lvl))
|
if (!should_log(lvl))
|
||||||
|
@ -38,7 +38,7 @@ class name_formatter : public flag_formatter
|
|||||||
{
|
{
|
||||||
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
|
void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override
|
||||||
{
|
{
|
||||||
fmt_helper::append_string_view(string_view_type(*msg.logger_name), dest);
|
fmt_helper::append_string_view(string_view_t(*msg.logger_name), dest);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ struct async_msg
|
|||||||
// copy into log_msg
|
// copy into log_msg
|
||||||
log_msg to_log_msg()
|
log_msg to_log_msg()
|
||||||
{
|
{
|
||||||
log_msg msg(&worker_ptr->name(), level, string_view_type(raw.data(), raw.size()));
|
log_msg msg(&worker_ptr->name(), level, string_view_t(raw.data(), raw.size()));
|
||||||
msg.time = time;
|
msg.time = time;
|
||||||
msg.thread_id = thread_id;
|
msg.thread_id = thread_id;
|
||||||
msg.msg_id = msg_id;
|
msg.msg_id = msg_id;
|
||||||
|
@ -94,11 +94,11 @@ public:
|
|||||||
#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||||
|
|
||||||
// T can be statically converted to string_view
|
// T can be statically converted to string_view
|
||||||
template<class T, typename std::enable_if<std::is_convertible<T, spdlog::string_view_type>::value, T>::type * = nullptr>
|
template<class T, typename std::enable_if<std::is_convertible<T, spdlog::string_view_t>::value, T>::type * = nullptr>
|
||||||
void log(level::level_enum lvl, const T &);
|
void log(level::level_enum lvl, const T &);
|
||||||
|
|
||||||
// T cannot be statically converted to string_view
|
// T cannot be statically converted to string_view
|
||||||
template<class T, typename std::enable_if<!std::is_convertible<T, spdlog::string_view_type>::value, T>::type * = nullptr>
|
template<class T, typename std::enable_if<!std::is_convertible<T, spdlog::string_view_t>::value, T>::type * = nullptr>
|
||||||
void log(level::level_enum lvl, const T &);
|
void log(level::level_enum lvl, const T &);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
Loading…
Reference in New Issue
Block a user