Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

47 lines
1.4KB

  1. // Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
  2. // Distributed under the MIT License (http://opensource.org/licenses/MIT)
  3. #pragma once
  4. //
  5. // base sink templated over a mutex (either dummy or real)
  6. // concrete implementation should override the sink_it_() and flush_() methods.
  7. // locking is taken care of in this class - no locking needed by the
  8. // implementers..
  9. //
  10. #include "spdlog/common.h"
  11. #include "spdlog/details/log_msg.h"
  12. #include "spdlog/sinks/sink.h"
  13. namespace spdlog {
  14. namespace sinks {
  15. template<typename Mutex>
  16. class base_sink : public sink
  17. {
  18. public:
  19. base_sink();
  20. explicit base_sink(std::unique_ptr<spdlog::formatter> formatter);
  21. base_sink(const base_sink &) = delete;
  22. base_sink &operator=(const base_sink &) = delete;
  23. void log(const details::log_msg &msg) final;
  24. void flush() final;
  25. void set_pattern(const std::string &pattern) final;
  26. void set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) final;
  27. protected:
  28. // sink formatter
  29. std::unique_ptr<spdlog::formatter> formatter_;
  30. Mutex mutex_;
  31. virtual void sink_it_(const details::log_msg &msg) = 0;
  32. virtual void flush_() = 0;
  33. virtual void set_pattern_(const std::string &pattern);
  34. virtual void set_formatter_(std::unique_ptr<spdlog::formatter> sink_formatter);
  35. };
  36. } // namespace sinks
  37. } // namespace spdlog
  38. #ifdef SPDLOG_HEADER_ONLY
  39. #include "base_sink-inl.h"
  40. #endif