Removed swap from logger and renamed source location macro to SPDLOG_USE_SOURCE_LOCATION

This commit is contained in:
gabime 2023-09-16 00:07:10 +03:00
parent 5882bfd0ad
commit af2f24de07
3 changed files with 4 additions and 37 deletions

View File

@ -29,38 +29,8 @@ SPDLOG_INLINE logger::logger(logger &&other) noexcept
, level_(other.level_.load(std::memory_order_relaxed))
, flush_level_(other.flush_level_.load(std::memory_order_relaxed))
, custom_err_handler_(std::move(other.custom_err_handler_))
{}
SPDLOG_INLINE logger &logger::operator=(logger other) noexcept
{
this->swap(other);
return *this;
}
SPDLOG_INLINE void logger::swap(spdlog::logger &other) noexcept
{
name_.swap(other.name_);
sinks_.swap(other.sinks_);
// swap level_
auto other_level = other.level_.load();
auto my_level = level_.exchange(other_level);
other.level_.store(my_level);
// swap flush level_
other_level = other.flush_level_.load();
my_level = flush_level_.exchange(other_level);
other.flush_level_.store(my_level);
custom_err_handler_.swap(other.custom_err_handler_);
}
SPDLOG_INLINE void swap(logger &a, logger &b)
{
a.swap(b);
}
SPDLOG_INLINE void logger::set_level(level::level_enum log_level)
{
level_.store(log_level);

View File

@ -70,12 +70,10 @@ public:
: logger(std::move(name), sinks.begin(), sinks.end())
{}
virtual ~logger() = default;
logger(const logger &other) noexcept;
logger(logger &&other) noexcept;
logger &operator=(logger other) noexcept;
void swap(spdlog::logger &other) noexcept;
virtual ~logger() = default;
// log functions
template<typename... Args>
@ -129,8 +127,7 @@ public:
}
}
#ifdef SPDLOG_EMIT_SOURCE_LOCATION
#ifdef SPDLOG_USE_SOURCE_LOCATION
template<typename... Args>
void trace(loc_with_fmt fmt, Args &&...args)
{

View File

@ -155,7 +155,7 @@ void log(level::level_enum lvl, S fmt, Args &&...args)
default_logger_raw()->log(lvl, fmt, std::forward<Args>(args)...);
}
#ifdef SPDLOG_EMIT_SOURCE_LOCATION
#ifdef SPDLOG_USE_SOURCE_LOCATION
template<typename... Args>
void trace(loc_with_fmt fmt, Args &&...args)
{