Files
spdlog/include/spdlog/sinks/base_sink.h

44 lines
1.2 KiB
C
Raw Normal View History

2016-04-20 11:57:49 +03:00
//
// Copyright(c) 2015 Gabi Melman.
// 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)
// 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 {
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:
2018-09-26 15:41:57 +03:00
base_sink() = default;
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;
2016-04-20 11:57:49 +03:00
protected:
virtual void sink_it_(const details::log_msg &msg) = 0;
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);
Mutex mutex_;
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
#ifndef SPDLOG_STATIC_LIB
#include "spdlog/impl/base_sink.cpp"
#endif