Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 10:29:01

0001 // Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
0002 // Distributed under the MIT License (http://opensource.org/licenses/MIT)
0003 
0004 #pragma once
0005 
0006 #ifndef SPDLOG_HEADER_ONLY
0007     #include <spdlog/sinks/base_sink.h>
0008 #endif
0009 
0010 #include <spdlog/common.h>
0011 #include <spdlog/pattern_formatter.h>
0012 
0013 #include <memory>
0014 #include <mutex>
0015 
0016 template <typename Mutex>
0017 SPDLOG_INLINE spdlog::sinks::base_sink<Mutex>::base_sink()
0018     : formatter_{details::make_unique<spdlog::pattern_formatter>()} {}
0019 
0020 template <typename Mutex>
0021 SPDLOG_INLINE spdlog::sinks::base_sink<Mutex>::base_sink(
0022     std::unique_ptr<spdlog::formatter> formatter)
0023     : formatter_{std::move(formatter)} {}
0024 
0025 template <typename Mutex>
0026 void SPDLOG_INLINE spdlog::sinks::base_sink<Mutex>::log(const details::log_msg &msg) {
0027     std::lock_guard<Mutex> lock(mutex_);
0028     sink_it_(msg);
0029 }
0030 
0031 template <typename Mutex>
0032 void SPDLOG_INLINE spdlog::sinks::base_sink<Mutex>::flush() {
0033     std::lock_guard<Mutex> lock(mutex_);
0034     flush_();
0035 }
0036 
0037 template <typename Mutex>
0038 void SPDLOG_INLINE spdlog::sinks::base_sink<Mutex>::set_pattern(const std::string &pattern) {
0039     std::lock_guard<Mutex> lock(mutex_);
0040     set_pattern_(pattern);
0041 }
0042 
0043 template <typename Mutex>
0044 void SPDLOG_INLINE
0045 spdlog::sinks::base_sink<Mutex>::set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter) {
0046     std::lock_guard<Mutex> lock(mutex_);
0047     set_formatter_(std::move(sink_formatter));
0048 }
0049 
0050 template <typename Mutex>
0051 void SPDLOG_INLINE spdlog::sinks::base_sink<Mutex>::set_pattern_(const std::string &pattern) {
0052     set_formatter_(details::make_unique<spdlog::pattern_formatter>(pattern));
0053 }
0054 
0055 template <typename Mutex>
0056 void SPDLOG_INLINE
0057 spdlog::sinks::base_sink<Mutex>::set_formatter_(std::unique_ptr<spdlog::formatter> sink_formatter) {
0058     formatter_ = std::move(sink_formatter);
0059 }