mirror of
https://github.com/gabime/spdlog.git
synced 2025-11-16 09:28:56 +08:00
wip
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
|
||||
#include "spdlog/common.h"
|
||||
#include "spdlog/details/log_msg.h"
|
||||
#include "spdlog/formatter.h"
|
||||
#include "spdlog/sinks/sink.h"
|
||||
|
||||
namespace spdlog {
|
||||
@@ -25,45 +24,21 @@ public:
|
||||
base_sink() = default;
|
||||
base_sink(const base_sink &) = delete;
|
||||
base_sink &operator=(const base_sink &) = delete;
|
||||
|
||||
void log(const details::log_msg &msg) final
|
||||
{
|
||||
std::lock_guard<Mutex> lock(mutex_);
|
||||
sink_it_(msg);
|
||||
}
|
||||
|
||||
void flush() final
|
||||
{
|
||||
std::lock_guard<Mutex> lock(mutex_);
|
||||
flush_();
|
||||
}
|
||||
|
||||
void set_pattern(const std::string &pattern) final
|
||||
{
|
||||
std::lock_guard<Mutex> lock(mutex_);
|
||||
set_pattern_(pattern);
|
||||
}
|
||||
|
||||
void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) final
|
||||
{
|
||||
std::lock_guard<Mutex> lock(mutex_);
|
||||
set_formatter_(std::move(sink_formatter));
|
||||
}
|
||||
void log(const details::log_msg &msg) final;
|
||||
void flush() final;void set_pattern(const std::string &pattern) final;
|
||||
void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) final;
|
||||
|
||||
protected:
|
||||
virtual void sink_it_(const details::log_msg &msg) = 0;
|
||||
virtual void flush_() = 0;
|
||||
|
||||
virtual void set_pattern_(const std::string &pattern)
|
||||
{
|
||||
set_formatter_(details::make_unique<spdlog::pattern_formatter>(pattern));
|
||||
}
|
||||
|
||||
virtual void set_formatter_(std::unique_ptr<spdlog::formatter> sink_formatter)
|
||||
{
|
||||
formatter_ = std::move(sink_formatter);
|
||||
}
|
||||
virtual void set_pattern_(const std::string &pattern);
|
||||
virtual void set_formatter_(std::unique_ptr<spdlog::formatter> sink_formatter);
|
||||
Mutex mutex_;
|
||||
};
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
||||
|
||||
#ifndef SPDLOG_STATIC_LIB
|
||||
#include "spdlog/impl/base_sink.cpp"
|
||||
#endif
|
||||
Reference in New Issue
Block a user