mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 18:11:33 +08:00
Address PR review comments
This commit is contained in:
parent
714cf12822
commit
37dd6bb159
@ -25,13 +25,13 @@ inline spdlog::string_view_t to_string_view(const memory_buf_t &buf) SPDLOG_NOEX
|
|||||||
|
|
||||||
#ifdef SPDLOG_USE_STD_FORMAT
|
#ifdef SPDLOG_USE_STD_FORMAT
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::basic_string<T> to_string(const std::basic_string<T> &buf)
|
std::basic_string<T> to_string(std::basic_string<T> &&buf)
|
||||||
{
|
{
|
||||||
return buf;
|
return std::move(buf);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
template<typename T, size_t Size>
|
template<typename T, size_t Size>
|
||||||
std::basic_string<T> to_string(const fmt::basic_memory_buffer<T, Size> &buf)
|
std::basic_string<T> to_string(fmt::basic_memory_buffer<T, Size> &&buf)
|
||||||
{
|
{
|
||||||
return fmt::to_string(buf);
|
return fmt::to_string(buf);
|
||||||
}
|
}
|
||||||
|
@ -389,7 +389,7 @@ SPDLOG_INLINE std::string filename_to_str(const filename_t &filename)
|
|||||||
{
|
{
|
||||||
memory_buf_t buf;
|
memory_buf_t buf;
|
||||||
wstr_to_utf8buf(filename, buf);
|
wstr_to_utf8buf(filename, buf);
|
||||||
return fmt_helper::to_string(buf);
|
return fmt_helper::to_string(std::move(buf));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
SPDLOG_INLINE std::string filename_to_str(const filename_t &filename)
|
SPDLOG_INLINE std::string filename_to_str(const filename_t &filename)
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "spdlog/sinks/base_sink.h"
|
#include "spdlog/sinks/base_sink.h"
|
||||||
#include "spdlog/details/circular_q.h"
|
#include "spdlog/details/circular_q.h"
|
||||||
|
#include "spdlog/details/fmt_helper.h"
|
||||||
#include "spdlog/details/log_msg_buffer.h"
|
#include "spdlog/details/log_msg_buffer.h"
|
||||||
#include "spdlog/details/null_mutex.h"
|
#include "spdlog/details/null_mutex.h"
|
||||||
|
|
||||||
@ -50,7 +51,7 @@ public:
|
|||||||
{
|
{
|
||||||
memory_buf_t formatted;
|
memory_buf_t formatted;
|
||||||
base_sink<Mutex>::formatter_->format(q_.at(i), formatted);
|
base_sink<Mutex>::formatter_->format(q_.at(i), formatted);
|
||||||
ret.push_back(fmt_helper::to_string(formatted));
|
ret.push_back(details::fmt_helper::to_string(std::move(formatted)));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,16 @@ using filename_memory_buf_t = fmt::basic_memory_buffer<spdlog::filename_t::value
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SPDLOG_WCHAR_FILENAMES
|
#ifdef SPDLOG_WCHAR_FILENAMES
|
||||||
std::string filename_buf_to_utf8string(const filename_memory_buf_t &w)
|
std::string filename_buf_to_utf8string(filename_memory_buf_t &&w)
|
||||||
{
|
{
|
||||||
spdlog::memory_buf_t buf;
|
spdlog::memory_buf_t buf;
|
||||||
spdlog::details::os::wstr_to_utf8buf(spdlog::wstring_view_t(w.data(), w.size()), buf);
|
spdlog::details::os::wstr_to_utf8buf(spdlog::wstring_view_t(w.data(), w.size()), buf);
|
||||||
return spdlog::details::fmt_helper::to_string(buf);
|
return spdlog::details::fmt_helper::to_string(std::move(buf));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
std::string filename_buf_to_utf8string(const filename_memory_buf_t &w)
|
std::string filename_buf_to_utf8string(filename_memory_buf_t &&w)
|
||||||
{
|
{
|
||||||
return spdlog::details::fmt_helper::to_string(w);
|
return spdlog::details::fmt_helper::to_string(std::move(w));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ TEST_CASE("daily_logger with dateonly calculator", "[daily_logger]")
|
|||||||
}
|
}
|
||||||
logger->flush();
|
logger->flush();
|
||||||
|
|
||||||
require_message_count(filename_buf_to_utf8string(w), 10);
|
require_message_count(filename_buf_to_utf8string(std::move(w)), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct custom_daily_file_name_calculator
|
struct custom_daily_file_name_calculator
|
||||||
@ -55,7 +55,7 @@ struct custom_daily_file_name_calculator
|
|||||||
spdlog::fmt_lib::format_to(std::back_inserter(w), SPDLOG_FILENAME_T("{}{:04d}{:02d}{:02d}"), basename, now_tm.tm_year + 1900,
|
spdlog::fmt_lib::format_to(std::back_inserter(w), SPDLOG_FILENAME_T("{}{:04d}{:02d}{:02d}"), basename, now_tm.tm_year + 1900,
|
||||||
now_tm.tm_mon + 1, now_tm.tm_mday);
|
now_tm.tm_mon + 1, now_tm.tm_mday);
|
||||||
|
|
||||||
return spdlog::details::fmt_helper::to_string(w);
|
return spdlog::details::fmt_helper::to_string(std::move(w));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ TEST_CASE("daily_logger with custom calculator", "[daily_logger]")
|
|||||||
|
|
||||||
logger->flush();
|
logger->flush();
|
||||||
|
|
||||||
require_message_count(filename_buf_to_utf8string(w), 10);
|
require_message_count(filename_buf_to_utf8string(std::move(w)), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user