1
0
mirror of https://github.com/gabime/spdlog.git synced 2025-03-14 18:19:54 +08:00
spdlog/include/spdlog/sinks/sink.h

36 lines
876 B
C
Raw Normal View History

2019-06-04 05:09:16 +08:00
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
2016-04-20 16:57:49 +08:00
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
2018-04-29 06:31:09 +08:00
#include "spdlog/details/log_msg.h"
2018-06-24 06:32:39 +08:00
#include "spdlog/formatter.h"
2016-04-20 16:57:49 +08:00
2018-03-17 18:47:46 +08:00
namespace spdlog {
2019-04-05 21:44:17 +08:00
2018-03-17 18:47:46 +08:00
namespace sinks {
2016-04-20 16:57:49 +08:00
class sink
{
public:
virtual ~sink() = default;
2018-03-09 21:26:33 +08:00
virtual void log(const details::log_msg &msg) = 0;
2016-04-20 16:57:49 +08:00
virtual void flush() = 0;
virtual void set_pattern(const std::string &pattern) = 0;
virtual void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) = 0;
2019-04-05 21:44:17 +08:00
void set_level(level::level_enum log_level);
level::level_enum level() const;
bool should_log(level::level_enum msg_level) const;
2018-06-24 06:32:39 +08:00
protected:
// sink log level - default is all
2019-02-03 23:12:00 +08:00
level_t level_{level::trace};
2018-06-24 06:32:39 +08:00
};
2018-03-17 18:47:46 +08:00
} // namespace sinks
} // namespace spdlog
2019-04-05 21:44:17 +08:00
#ifdef SPDLOG_HEADER_ONLY
2019-05-11 18:19:53 +08:00
#include "sink-inl.h"
2019-04-27 23:44:48 +08:00
#endif