2019-06-04 00:09:16 +03:00
|
|
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
2016-04-20 11:57:49 +03:00
|
|
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
//
|
2017-04-06 20:16:49 -04:00
|
|
|
// base sink templated over a mutex (either dummy or real)
|
2018-07-07 12:12:45 +03:00
|
|
|
// concrete implementation should override the sink_it_() and flush_() methods.
|
2018-07-21 23:48:07 +03:00
|
|
|
// locking is taken care of in this class - no locking needed by the
|
|
|
|
// implementers..
|
2016-04-20 11:57:49 +03:00
|
|
|
//
|
|
|
|
|
2018-04-29 01:31:09 +03:00
|
|
|
#include "spdlog/common.h"
|
|
|
|
#include "spdlog/details/log_msg.h"
|
|
|
|
#include "spdlog/sinks/sink.h"
|
2016-04-20 11:57:49 +03:00
|
|
|
|
2018-03-17 12:47:46 +02:00
|
|
|
namespace spdlog {
|
|
|
|
namespace sinks {
|
2018-07-14 16:21:53 +03:00
|
|
|
template<typename Mutex>
|
2018-03-16 17:35:56 +02:00
|
|
|
class base_sink : public sink
|
2016-04-20 11:57:49 +03:00
|
|
|
{
|
|
|
|
public:
|
2019-06-27 23:56:37 +03:00
|
|
|
base_sink();
|
|
|
|
explicit base_sink(std::unique_ptr<spdlog::formatter> formatter);
|
2018-03-09 15:26:33 +02:00
|
|
|
base_sink(const base_sink &) = delete;
|
|
|
|
base_sink &operator=(const base_sink &) = delete;
|
2019-05-08 17:50:23 +03:00
|
|
|
void log(const details::log_msg &msg) final;
|
2019-05-10 18:48:03 +03:00
|
|
|
void flush() final;
|
|
|
|
void set_pattern(const std::string &pattern) final;
|
2019-05-08 17:50:23 +03:00
|
|
|
void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) final;
|
2018-07-14 16:21:53 +03:00
|
|
|
|
2016-04-20 11:57:49 +03:00
|
|
|
protected:
|
2019-06-27 23:56:37 +03:00
|
|
|
// sink formatter
|
|
|
|
std::unique_ptr<spdlog::formatter> formatter_;
|
|
|
|
Mutex mutex_;
|
|
|
|
|
2018-07-14 16:21:53 +03:00
|
|
|
virtual void sink_it_(const details::log_msg &msg) = 0;
|
2018-06-10 22:59:17 +03:00
|
|
|
virtual void flush_() = 0;
|
2019-05-08 17:50:23 +03:00
|
|
|
virtual void set_pattern_(const std::string &pattern);
|
|
|
|
virtual void set_formatter_(std::unique_ptr<spdlog::formatter> sink_formatter);
|
2016-04-20 11:57:49 +03:00
|
|
|
};
|
2018-03-17 12:47:46 +02:00
|
|
|
} // namespace sinks
|
|
|
|
} // namespace spdlog
|
2019-05-08 17:50:23 +03:00
|
|
|
|
2019-07-13 10:56:22 +02:00
|
|
|
#ifdef SPDLOG_HEADER_ONLY
|
2019-05-11 13:19:53 +03:00
|
|
|
#include "base_sink-inl.h"
|
2019-05-17 23:09:22 -05:00
|
|
|
#endif
|