2019-06-03 17:09:16 -04:00
|
|
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
2016-04-20 04:57:49 -04: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 05:12:45 -04:00
|
|
|
// concrete implementation should override the sink_it_() and flush_() methods.
|
2018-07-21 16:48:07 -04:00
|
|
|
// locking is taken care of in this class - no locking needed by the
|
|
|
|
// implementers..
|
2016-04-20 04:57:49 -04:00
|
|
|
//
|
|
|
|
|
2018-04-28 18:31:09 -04:00
|
|
|
#include "spdlog/common.h"
|
|
|
|
#include "spdlog/details/log_msg.h"
|
|
|
|
#include "spdlog/sinks/sink.h"
|
2016-04-20 04:57:49 -04:00
|
|
|
|
2018-03-17 06:47:46 -04:00
|
|
|
namespace spdlog {
|
|
|
|
namespace sinks {
|
2018-07-14 09:21:53 -04:00
|
|
|
template<typename Mutex>
|
2018-03-16 11:35:56 -04:00
|
|
|
class base_sink : public sink
|
2016-04-20 04:57:49 -04:00
|
|
|
{
|
|
|
|
public:
|
2018-09-26 08:41:57 -04:00
|
|
|
base_sink() = default;
|
2018-03-09 08:26:33 -05:00
|
|
|
base_sink(const base_sink &) = delete;
|
|
|
|
base_sink &operator=(const base_sink &) = delete;
|
2019-05-08 10:50:23 -04:00
|
|
|
void log(const details::log_msg &msg) final;
|
2019-05-10 11:48:03 -04:00
|
|
|
void flush() final;
|
|
|
|
void set_pattern(const std::string &pattern) final;
|
2019-05-08 10:50:23 -04:00
|
|
|
void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) final;
|
2018-07-14 09:21:53 -04:00
|
|
|
|
2016-04-20 04:57:49 -04:00
|
|
|
protected:
|
2018-07-14 09:21:53 -04:00
|
|
|
virtual void sink_it_(const details::log_msg &msg) = 0;
|
2018-06-10 15:59:17 -04:00
|
|
|
virtual void flush_() = 0;
|
2019-05-08 10:50:23 -04:00
|
|
|
virtual void set_pattern_(const std::string &pattern);
|
|
|
|
virtual void set_formatter_(std::unique_ptr<spdlog::formatter> sink_formatter);
|
2018-06-10 15:59:17 -04:00
|
|
|
Mutex mutex_;
|
2016-04-20 04:57:49 -04:00
|
|
|
};
|
2018-03-17 06:47:46 -04:00
|
|
|
} // namespace sinks
|
|
|
|
} // namespace spdlog
|
2019-05-08 10:50:23 -04:00
|
|
|
|
2019-05-18 00:09:22 -04:00
|
|
|
#ifndef SPDLOG_COMPILED_LIB
|
2019-05-11 06:19:53 -04:00
|
|
|
#include "base_sink-inl.h"
|
2019-05-18 00:09:22 -04:00
|
|
|
#endif
|