2021-10-22 13:40:37 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-10-28 10:28:20 +00:00
|
|
|
#include <spdlog/spdlog.h>
|
2021-10-22 13:40:37 +00:00
|
|
|
#include "Overlay.h"
|
|
|
|
|
2021-10-28 10:28:20 +00:00
|
|
|
|
2021-10-22 13:40:37 +00:00
|
|
|
namespace spdlog {
|
|
|
|
namespace sinks {
|
|
|
|
|
|
|
|
template <typename Mutex>
|
|
|
|
class overlay_sink : public spdlog::sinks::base_sink<Mutex> {
|
|
|
|
public:
|
|
|
|
overlay_sink() = default;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void sink_it_(const spdlog::details::log_msg& msg) override
|
|
|
|
{
|
2021-10-22 14:35:35 +00:00
|
|
|
Overlay::AddLog(msg);
|
2021-10-22 13:40:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void flush_() override
|
|
|
|
{
|
|
|
|
// Do nothing because statement executed in sink_it_().
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_pattern_(const std::string& pattern) override
|
|
|
|
{
|
|
|
|
// Don't format log message.
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_formatter_(std::unique_ptr<spdlog::formatter> sink_formatter) override
|
|
|
|
{
|
|
|
|
// Don't format log message.
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
using overlay_sink_mt = overlay_sink<std::mutex>;
|
|
|
|
|
|
|
|
} // namespace sinks
|
|
|
|
} // namespace spdlog
|