mirror of https://github.com/gabime/spdlog.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.8 KiB
C++
66 lines
1.8 KiB
C++
![]()
6 years ago
|
// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
|
||
![]()
6 years ago
|
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||
|
|
||
|
|
||
![]()
6 years ago
|
|
||
![]()
2 years ago
|
#include <spdlog/sinks/base_sink.h>
|
||
![]()
6 years ago
|
#include <spdlog/common.h>
|
||
![]()
6 years ago
|
#include <spdlog/pattern_formatter.h>
|
||
![]()
6 years ago
|
|
||
![]()
6 years ago
|
#include <memory>
|
||
![]()
2 years ago
|
#include <mutex>
|
||
![]()
6 years ago
|
|
||
|
template<typename Mutex>
|
||
![]()
2 years ago
|
spdlog::sinks::base_sink<Mutex>::base_sink()
|
||
![]()
2 years ago
|
: formatter_{std::make_unique<spdlog::pattern_formatter>()}
|
||
![]()
6 years ago
|
{}
|
||
|
|
||
|
template<typename Mutex>
|
||
![]()
2 years ago
|
spdlog::sinks::base_sink<Mutex>::base_sink(std::unique_ptr<spdlog::formatter> formatter)
|
||
![]()
6 years ago
|
: formatter_{std::move(formatter)}
|
||
|
{}
|
||
|
|
||
![]()
6 years ago
|
template<typename Mutex>
|
||
![]()
2 years ago
|
void spdlog::sinks::base_sink<Mutex>::log(const details::log_msg &msg)
|
||
![]()
6 years ago
|
{
|
||
|
std::lock_guard<Mutex> lock(mutex_);
|
||
|
sink_it_(msg);
|
||
|
}
|
||
|
|
||
![]()
6 years ago
|
template<typename Mutex>
|
||
![]()
2 years ago
|
void spdlog::sinks::base_sink<Mutex>::flush()
|
||
![]()
6 years ago
|
{
|
||
|
std::lock_guard<Mutex> lock(mutex_);
|
||
|
flush_();
|
||
|
}
|
||
|
|
||
![]()
6 years ago
|
template<typename Mutex>
|
||
![]()
2 years ago
|
void spdlog::sinks::base_sink<Mutex>::set_pattern(const std::string &pattern)
|
||
![]()
6 years ago
|
{
|
||
|
std::lock_guard<Mutex> lock(mutex_);
|
||
|
set_pattern_(pattern);
|
||
|
}
|
||
|
|
||
![]()
6 years ago
|
template<typename Mutex>
|
||
![]()
2 years ago
|
void spdlog::sinks::base_sink<Mutex>::set_formatter(std::unique_ptr<spdlog::formatter> sink_formatter)
|
||
![]()
6 years ago
|
{
|
||
|
std::lock_guard<Mutex> lock(mutex_);
|
||
|
set_formatter_(std::move(sink_formatter));
|
||
|
}
|
||
|
|
||
![]()
6 years ago
|
template<typename Mutex>
|
||
![]()
2 years ago
|
void spdlog::sinks::base_sink<Mutex>::set_pattern_(const std::string &pattern)
|
||
![]()
6 years ago
|
{
|
||
![]()
2 years ago
|
set_formatter_(std::make_unique<spdlog::pattern_formatter>(pattern));
|
||
![]()
6 years ago
|
}
|
||
|
|
||
![]()
6 years ago
|
template<typename Mutex>
|
||
![]()
2 years ago
|
void spdlog::sinks::base_sink<Mutex>::set_formatter_(std::unique_ptr<spdlog::formatter> sink_formatter)
|
||
![]()
6 years ago
|
{
|
||
|
formatter_ = std::move(sink_formatter);
|
||
|
}
|
||
![]()
2 years ago
|
|
||
|
// template instantiations
|
||
|
|
||
|
template class SPDLOG_API spdlog::sinks::base_sink<std::mutex>;
|
||
|
template class SPDLOG_API spdlog::sinks::base_sink<spdlog::details::null_mutex>;
|