diff --git a/include/spdlog/async_logger-inl.h b/include/spdlog/async_logger-inl.h index 027366c8..ce2e8d2b 100644 --- a/include/spdlog/async_logger-inl.h +++ b/include/spdlog/async_logger-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/async_logger.h" +#endif + #include "spdlog/sinks/sink.h" #include "spdlog/details/thread_pool.h" diff --git a/include/spdlog/common-inl.h b/include/spdlog/common-inl.h index dd619a57..6076b8cb 100644 --- a/include/spdlog/common-inl.h +++ b/include/spdlog/common-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/common.h" +#endif + namespace spdlog { namespace level { static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES; diff --git a/include/spdlog/details/file_helper-inl.h b/include/spdlog/details/file_helper-inl.h index fef3be01..1460fc2b 100644 --- a/include/spdlog/details/file_helper-inl.h +++ b/include/spdlog/details/file_helper-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/details/file_helper.h" +#endif + #include "spdlog/details/os.h" #include diff --git a/include/spdlog/details/log_msg-inl.h b/include/spdlog/details/log_msg-inl.h index b619f7ce..0df717f9 100644 --- a/include/spdlog/details/log_msg-inl.h +++ b/include/spdlog/details/log_msg-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/details/log_msg.h" +#endif + #include "spdlog/details/os.h" #include "spdlog/sinks/sink.h" diff --git a/include/spdlog/details/os-inl.h b/include/spdlog/details/os-inl.h index cc4690d6..e96d1d38 100644 --- a/include/spdlog/details/os-inl.h +++ b/include/spdlog/details/os-inl.h @@ -2,6 +2,11 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) #pragma once + +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/details/os.h" +#endif + #include #include #include diff --git a/include/spdlog/details/pattern_formatter-inl.h b/include/spdlog/details/pattern_formatter-inl.h index 9275d8ef..a6951e47 100644 --- a/include/spdlog/details/pattern_formatter-inl.h +++ b/include/spdlog/details/pattern_formatter-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/details/pattern_formatter.h" +#endif + #include "spdlog/details/fmt_helper.h" #include "spdlog/details/log_msg.h" #include "spdlog/details/os.h" diff --git a/include/spdlog/details/periodic_worker-inl.h b/include/spdlog/details/periodic_worker-inl.h index cfc9af72..f97ed4d1 100644 --- a/include/spdlog/details/periodic_worker-inl.h +++ b/include/spdlog/details/periodic_worker-inl.h @@ -2,8 +2,14 @@ // Distributed under the MIT License (http://opensource.org/licenses/MIT) #pragma once + +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/details/periodic_worker.h" +#endif + namespace spdlog { namespace details { + SPDLOG_INLINE periodic_worker::periodic_worker(const std::function &callback_fun, std::chrono::seconds interval) { active_ = (interval > std::chrono::seconds::zero()); diff --git a/include/spdlog/details/registry-inl.h b/include/spdlog/details/registry-inl.h index 168c4c54..9ea46237 100644 --- a/include/spdlog/details/registry-inl.h +++ b/include/spdlog/details/registry-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/details/registry.h" +#endif + #include "spdlog/common.h" #include "spdlog/details/periodic_worker.h" #include "spdlog/logger.h" diff --git a/include/spdlog/details/thread_pool-inl.h b/include/spdlog/details/thread_pool-inl.h index a7b77437..61b94380 100644 --- a/include/spdlog/details/thread_pool-inl.h +++ b/include/spdlog/details/thread_pool-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/details/thread_pool.h" +#endif + #include "spdlog/common.h" namespace spdlog { diff --git a/include/spdlog/logger-inl.h b/include/spdlog/logger-inl.h index 4d0c5e24..374376be 100644 --- a/include/spdlog/logger-inl.h +++ b/include/spdlog/logger-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/logger.h" +#endif + #include "spdlog/sinks/sink.h" #include "spdlog/details/pattern_formatter.h" diff --git a/include/spdlog/sinks/ansicolor_sink-inl.h b/include/spdlog/sinks/ansicolor_sink-inl.h index 63da482e..7f7cd751 100644 --- a/include/spdlog/sinks/ansicolor_sink-inl.h +++ b/include/spdlog/sinks/ansicolor_sink-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/sinks/ansicolor_sink.h" +#endif + #include "spdlog/details/os.h" template diff --git a/include/spdlog/sinks/base_sink-inl.h b/include/spdlog/sinks/base_sink-inl.h index 177bbb69..4ee23439 100644 --- a/include/spdlog/sinks/base_sink-inl.h +++ b/include/spdlog/sinks/base_sink-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/sinks/base_sink.h" +#endif + #include "spdlog/common.h" #include "spdlog/details/pattern_formatter.h" diff --git a/include/spdlog/sinks/basic_file_sink-inl.h b/include/spdlog/sinks/basic_file_sink-inl.h index edcee4fa..254e5085 100644 --- a/include/spdlog/sinks/basic_file_sink-inl.h +++ b/include/spdlog/sinks/basic_file_sink-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/sinks/basic_file_sink.h" +#endif + #include "spdlog/common.h" #include "spdlog/details/os.h" diff --git a/include/spdlog/sinks/rotating_file_sink-inl.h b/include/spdlog/sinks/rotating_file_sink-inl.h index db13a738..f871c820 100644 --- a/include/spdlog/sinks/rotating_file_sink-inl.h +++ b/include/spdlog/sinks/rotating_file_sink-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/sinks/rotating_file_sink.h" +#endif + #include "spdlog/common.h" #include "spdlog/details/file_helper.h" diff --git a/include/spdlog/sinks/sink-inl.h b/include/spdlog/sinks/sink-inl.h index 8599795c..52227696 100644 --- a/include/spdlog/sinks/sink-inl.h +++ b/include/spdlog/sinks/sink-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/sinks/sink.h" +#endif + #include "spdlog/common.h" #include "spdlog/details/pattern_formatter.h" diff --git a/include/spdlog/sinks/stdout_color_sinks-inl.h b/include/spdlog/sinks/stdout_color_sinks-inl.h index 018aaf5e..d001a5fd 100644 --- a/include/spdlog/sinks/stdout_color_sinks-inl.h +++ b/include/spdlog/sinks/stdout_color_sinks-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/sinks/stdout_color_sinks.h" +#endif + #include "spdlog/logger.h" #include "spdlog/common.h" diff --git a/include/spdlog/sinks/wincolor_sink-inl.h b/include/spdlog/sinks/wincolor_sink-inl.h index da5262b3..912f2a6f 100644 --- a/include/spdlog/sinks/wincolor_sink-inl.h +++ b/include/spdlog/sinks/wincolor_sink-inl.h @@ -3,8 +3,15 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/sinks/wincolor_sink.h" +#endif + +#include "spdlog/common.h" + namespace spdlog { namespace sinks { + template SPDLOG_INLINE wincolor_sink::wincolor_sink() : out_handle_(TargetStream::handle()) diff --git a/include/spdlog/spdlog-inl.h b/include/spdlog/spdlog-inl.h index e2cd60ac..c8aa1c8e 100644 --- a/include/spdlog/spdlog-inl.h +++ b/include/spdlog/spdlog-inl.h @@ -3,6 +3,10 @@ #pragma once +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/spdlog.h" +#endif + #include "spdlog/common.h" #include "spdlog/details/pattern_formatter.h" diff --git a/src/spdlog.cpp b/src/spdlog.cpp index ebe2fc9f..d98458ca 100644 --- a/src/spdlog.cpp +++ b/src/spdlog.cpp @@ -8,72 +8,48 @@ #include #include -#include "spdlog/spdlog.h" -#include "spdlog/spdlog-inl.h" - +#include "spdlog/details/null_mutex.h" #include "spdlog/async.h" -#include "spdlog/common.h" +#include "spdlog/spdlog-inl.h" #include "spdlog/common-inl.h" -#include "spdlog/details/null_mutex.h" - -#include "spdlog/logger.h" #include "spdlog/logger-inl.h" template spdlog::logger::logger(std::string name, sinks_init_list::iterator begin, sinks_init_list::iterator end); -#include "spdlog/async_logger.h" #include "spdlog/async_logger-inl.h" - -#include "spdlog/details/log_msg.h" #include "spdlog/details/log_msg-inl.h" - -#include "spdlog/sinks/sink.h" #include "spdlog/sinks/sink-inl.h" -#include "spdlog/sinks/base_sink.h" #include "spdlog/sinks/base_sink-inl.h" template class spdlog::sinks::base_sink; template class spdlog::sinks::base_sink; -#include "spdlog/sinks/basic_file_sink.h" #include "spdlog/sinks/basic_file_sink-inl.h" template class spdlog::sinks::basic_file_sink; template class spdlog::sinks::basic_file_sink; -#include "spdlog/sinks/rotating_file_sink.h" #include "spdlog/sinks/rotating_file_sink-inl.h" template class spdlog::sinks::rotating_file_sink; template class spdlog::sinks::rotating_file_sink; -#include "spdlog/details/registry.h" #include "spdlog/details/registry-inl.h" -#include "spdlog/details/os.h" #include "spdlog/details/os-inl.h" - -#include "spdlog/details/periodic_worker.h" #include "spdlog/details/periodic_worker-inl.h" - -#include "spdlog/details/file_helper.h" #include "spdlog/details/file_helper-inl.h" - -#include "spdlog/details/pattern_formatter.h" #include "spdlog/details/pattern_formatter-inl.h" -#include "spdlog/details/thread_pool.h" #include "spdlog/details/thread_pool-inl.h" template class spdlog::details::mpmc_blocking_queue; #ifdef _WIN32 -#include "spdlog/sinks/wincolor_sink.h" #include "spdlog/sinks/wincolor_sink-inl.h" template class spdlog::sinks::wincolor_sink; template class spdlog::sinks::wincolor_sink; template class spdlog::sinks::wincolor_sink; template class spdlog::sinks::wincolor_sink; #else -#include "spdlog/sinks/ansicolor_sink.h" #include "spdlog/sinks/ansicolor_sink-inl.h" template class spdlog::sinks::ansicolor_sink; template class spdlog::sinks::ansicolor_sink; @@ -81,7 +57,6 @@ template class spdlog::sinks::ansicolor_sink; #endif -#include "spdlog/sinks/stdout_color_sinks.h" #include "spdlog/sinks/stdout_color_sinks-inl.h" template std::shared_ptr spdlog::stdout_color_mt(const std::string &logger_name); template std::shared_ptr spdlog::stdout_color_st(const std::string &logger_name); @@ -93,11 +68,6 @@ template std::shared_ptr spdlog::stdout_color_st spdlog::stderr_color_mt(const std::string &logger_name); template std::shared_ptr spdlog::stderr_color_st(const std::string &logger_name); -// fmt_helper templates -#include "spdlog/details/fmt_helper.h" -template void spdlog::details::fmt_helper::append_string_view(spdlog::string_view_t view, fmt::memory_buffer &dest); -template spdlog::string_view_t spdlog::details::fmt_helper::to_string_view(const fmt::memory_buffer &buf) SPDLOG_NOEXCEPT; - // Slightly modified version of fmt lib's format.cc source file. // Copyright (c) 2012 - 2016, Victor Zverovich // All rights reserved. diff --git a/tests/includes.h b/tests/includes.h index 85d4a1bd..4e0eaf8a 100644 --- a/tests/includes.h +++ b/tests/includes.h @@ -20,4 +20,4 @@ #include "spdlog/sinks/ostream_sink.h" #include "spdlog/sinks/rotating_file_sink.h" #include "spdlog/sinks/stdout_color_sinks.h" -#include "spdlog/details/pattern_formatter.h" +#include "spdlog/details/pattern_formatter.h" \ No newline at end of file diff --git a/tests/test_fmt_helper.cpp b/tests/test_fmt_helper.cpp index 97a61960..5af6f8a7 100644 --- a/tests/test_fmt_helper.cpp +++ b/tests/test_fmt_helper.cpp @@ -1,5 +1,6 @@ #include "includes.h" +#include "spdlog/details/fmt_helper.h" void test_pad2(int n, const char *expected) {