mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-30 10:29:02 +08:00
Gabime/visibilty-hidden 2.x (#3324)
Set CMAKE_CXX_VISIBILITY_PRESET and VISIBILITY_INLINES_HIDDEN when build shared lib
This commit is contained in:
@@ -13,7 +13,7 @@ namespace sinks {
|
||||
|
||||
template <typename Mutex>
|
||||
ansicolor_sink<Mutex>::ansicolor_sink(FILE *target_file, color_mode mode) : target_file_(target_file) {
|
||||
set_color_mode(mode);
|
||||
set_color_mode_(mode);
|
||||
colors_.at(level_to_number(level::trace)) = to_string_(white);
|
||||
colors_.at(level_to_number(level::debug)) = to_string_(cyan);
|
||||
colors_.at(level_to_number(level::info)) = to_string_(green);
|
||||
@@ -37,22 +37,27 @@ bool ansicolor_sink<Mutex>::should_color() const {
|
||||
|
||||
template <typename Mutex>
|
||||
void ansicolor_sink<Mutex>::set_color_mode(color_mode mode) {
|
||||
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
|
||||
set_color_mode_(mode);
|
||||
}
|
||||
|
||||
template <typename Mutex>
|
||||
void ansicolor_sink<Mutex>::set_color_mode_(color_mode mode) {
|
||||
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
|
||||
switch (mode) {
|
||||
case color_mode::always:
|
||||
should_do_colors_ = true;
|
||||
return;
|
||||
return;
|
||||
case color_mode::automatic:
|
||||
should_do_colors_ = details::os::in_terminal(target_file_) && details::os::is_color_terminal();
|
||||
return;
|
||||
return;
|
||||
case color_mode::never:
|
||||
should_do_colors_ = false;
|
||||
return;
|
||||
return;
|
||||
default:
|
||||
should_do_colors_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Mutex>
|
||||
void ansicolor_sink<Mutex>::sink_it_(const details::log_msg &msg) {
|
||||
// Wrap the originally formatted message in color codes.
|
||||
@@ -83,12 +88,12 @@ void ansicolor_sink<Mutex>::flush_() {
|
||||
}
|
||||
|
||||
template <typename Mutex>
|
||||
void ansicolor_sink<Mutex>::print_ccode_(const string_view_t color_code) {
|
||||
void ansicolor_sink<Mutex>::print_ccode_(const string_view_t color_code) const {
|
||||
details::os::fwrite_bytes(color_code.data(), color_code.size(), target_file_);
|
||||
}
|
||||
|
||||
template <typename Mutex>
|
||||
void ansicolor_sink<Mutex>::print_range_(const memory_buf_t &formatted, size_t start, size_t end) {
|
||||
void ansicolor_sink<Mutex>::print_range_(const memory_buf_t &formatted, size_t start, size_t end) const {
|
||||
details::os::fwrite_bytes(formatted.data() + start, end - start, target_file_);
|
||||
}
|
||||
|
||||
@@ -112,6 +117,8 @@ ansicolor_stderr_sink<Mutex>::ansicolor_stderr_sink(color_mode mode)
|
||||
|
||||
// template instantiations
|
||||
#include "spdlog/details/null_mutex.h"
|
||||
template class SPDLOG_API spdlog::sinks::ansicolor_sink<std::mutex>;
|
||||
template class SPDLOG_API spdlog::sinks::ansicolor_sink<spdlog::details::null_mutex>;
|
||||
template class SPDLOG_API spdlog::sinks::ansicolor_stdout_sink<std::mutex>;
|
||||
template class SPDLOG_API spdlog::sinks::ansicolor_stdout_sink<spdlog::details::null_mutex>;
|
||||
template class SPDLOG_API spdlog::sinks::ansicolor_stderr_sink<std::mutex>;
|
||||
|
@@ -142,4 +142,4 @@ bool rotating_file_sink<Mutex>::rename_file_(const filename_t &src_filename, con
|
||||
// template instantiations
|
||||
#include "spdlog/details/null_mutex.h"
|
||||
template class SPDLOG_API spdlog::sinks::rotating_file_sink<std::mutex>;
|
||||
template class SPDLOG_API spdlog::sinks::rotating_file_sink<spdlog::details::null_mutex>;
|
||||
template class SPDLOG_API spdlog::sinks::rotating_file_sink<spdlog::details::null_mutex>;
|
||||
|
Reference in New Issue
Block a user