| 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. |
| 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include <spdlog/details/log_msg.h> |
| 7 | #include <spdlog/formatter.h> |
| 8 | |
| 9 | namespace spdlog { |
| 10 | |
| 11 | namespace sinks { |
| 12 | class SPDLOG_API sink { |
| 13 | public: |
| 14 | virtual ~sink() = default; |
| 15 | virtual void log(const details::log_msg &msg) = 0; |
| 16 | virtual void flush() = 0; |
| 17 | virtual void set_pattern(const std::string &pattern) = 0; |
| 18 | virtual void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) = 0; |
| 19 | |
| 20 | void set_level(level::level_enum log_level); |
| 21 | level::level_enum level() const; |
| 22 | bool should_log(level::level_enum msg_level) const; |
| 23 | |
| 24 | protected: |
| 25 | // sink log level - default is all |
| 26 | level_t level_{level::trace}; |
| 27 | }; |
| 28 | |
| 29 | } // namespace sinks |
| 30 | } // namespace spdlog |
| 31 | |
| 32 | #ifdef SPDLOG_HEADER_ONLY |
| 33 | #include "sink-inl.h" |
| 34 | #endif |
| 35 | |