diff --git a/CMakeLists.txt b/CMakeLists.txt index 017db67e..1ed6a21b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,6 @@ else() set(SPDLOG_MASTER_PROJECT OFF) endif() -option(SPDLOG_STATIC_LIB "Build as static lib" ON) option(SPDLOG_BUILD_EXAMPLES "Build examples" ${SPDLOG_MASTER_PROJECT}) option(SPDLOG_BUILD_BENCH "Build benchmarks (Requires https://github.com/google/benchmark.git to be installed)" OFF) option(SPDLOG_BUILD_TESTS "Build tests" ON) @@ -55,29 +54,31 @@ option(SPDLOG_INSTALL "Generate the install target." ${SPDLOG_MASTER_PROJECT}) set(HEADER_BASE "${CMAKE_CURRENT_SOURCE_DIR}/include/spdlog") message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) -message(STATUS "Static lib: " ${SPDLOG_STATIC_LIB}) -if(SPDLOG_STATIC_LIB) - add_definitions(-DSPDLOG_STATIC_LIB) - set(SRC_BASE "${CMAKE_CURRENT_SOURCE_DIR}/src") - set(SRC_FILES "${SRC_BASE}/spdlog.cpp") - add_library(spdlog STATIC ${SRC_FILES}) - target_include_directories(spdlog PUBLIC "$") - target_link_libraries(spdlog) -else() - add_library(spdlog INTERFACE) - target_include_directories(spdlog INTERFACE "$") -endif() +# Build static lib +set(SRC_BASE "${CMAKE_CURRENT_SOURCE_DIR}/src") +set(STATIC_SRC_FILES "${SRC_BASE}/spdlog.cpp") +add_library(spdlog_static STATIC ${STATIC_SRC_FILES}) +add_library(spdlog::static ALIAS spdlog_static) +target_compile_definitions(spdlog_static PUBLIC SPDLOG_STATIC_LIB ) +target_include_directories(spdlog_static PUBLIC "$") +set_target_properties(spdlog_static PROPERTIES OUTPUT_NAME "spdlog") +set_target_properties(spdlog_static PROPERTIES DEBUG_POSTFIX "-debug") -add_library(spdlog::spdlog ALIAS spdlog) +# Headr only +add_library(spdlog_header_only INTERFACE) +target_include_directories(spdlog_header_only INTERFACE "$") +add_library(spdlog::header_only ALIAS spdlog_header_only) if(SPDLOG_FMT_EXTERNAL AND NOT TARGET fmt::fmt) find_package(fmt REQUIRED CONFIG) endif() if(SPDLOG_FMT_EXTERNAL) - target_compile_definitions(spdlog INTERFACE SPDLOG_FMT_EXTERNAL) - target_link_libraries(spdlog INTERFACE fmt::fmt) + target_compile_definitions(spdlog_static INTERFACE SPDLOG_FMT_EXTERNAL) + target_link_libraries(spdlog_static INTERFACE fmt::fmt) + target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_FMT_EXTERNAL) + target_link_libraries(spdlog_header_only INTERFACE fmt::fmt) endif() if(SPDLOG_BUILD_EXAMPLES) @@ -97,10 +98,7 @@ endif() # install #--------------------------------------------------------------------------------------- install(DIRECTORY ${HEADER_BASE} DESTINATION include) - -if(SPDLOG_STATIC_LIB) - install(TARGETS spdlog ARCHIVE DESTINATION lib) -endif() +install(TARGETS spdlog_static ARCHIVE DESTINATION lib) #--------------------------------------------------------------------------------------- # register project in CMake user registry diff --git a/bench/CMakeLists.txt b/bench/CMakeLists.txt index 3c4a3f9d..9280ebad 100644 --- a/bench/CMakeLists.txt +++ b/bench/CMakeLists.txt @@ -33,16 +33,16 @@ find_package(Threads REQUIRED) find_package(benchmark CONFIG REQUIRED) add_executable(bench bench.cpp) -target_link_libraries(bench PRIVATE spdlog::spdlog Threads::Threads) +target_link_libraries(bench PRIVATE spdlog::static Threads::Threads) add_executable(async_bench async_bench.cpp) -target_link_libraries(async_bench PRIVATE spdlog::spdlog Threads::Threads) +target_link_libraries(async_bench PRIVATE spdlog::static Threads::Threads) add_executable(latency latency.cpp) -target_link_libraries(latency PRIVATE benchmark::benchmark spdlog::spdlog Threads::Threads) +target_link_libraries(latency PRIVATE benchmark::benchmark spdlog::static Threads::Threads) add_executable(formatter-bench formatter-bench.cpp) -target_link_libraries(formatter-bench PRIVATE benchmark::benchmark spdlog::spdlog Threads::Threads) +target_link_libraries(formatter-bench PRIVATE benchmark::benchmark spdlog::static Threads::Threads) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs") diff --git a/bench/Makefile b/bench/Makefile deleted file mode 100644 index 868a7335..00000000 --- a/bench/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -CXX ?= g++ -CXXFLAGS = -march=native -Wall -Wextra -pedantic -Wconversion -std=c++11 -pthread -I../include -fmax-errors=1 -CXX_RELEASE_FLAGS = -O3 -flto -Wl,--no-as-needed - - -binaries=bench async_bench latency formatter-bench - -all: $(binaries) - -bench: bench.cpp - $(CXX) bench.cpp -o bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS) - - -async_bench: async_bench.cpp - $(CXX) async_bench.cpp -o async_bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS) - - -latency: latency.cpp - $(CXX) latency.cpp -o latency $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -lbenchmark - - -formatter-bench: formatter-bench.cpp - $(CXX) formatter-bench.cpp -o formatter-bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS) -lbenchmark - - -.PHONY: clean - -clean: - rm -f *.o logs/* latecy_logs $(binaries) - -rebuild: clean all diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index a404682a..f0a917f2 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -34,14 +34,14 @@ find_package(Threads REQUIRED) add_executable(example example.cpp) if(CMAKE_SYSTEM_NAME STREQUAL "Android") find_library(log-lib log) - target_link_libraries(example spdlog::spdlog Threads::Threads log) + target_link_libraries(example spdlog::static Threads::Threads log) else() - target_link_libraries(example spdlog::spdlog Threads::Threads) + target_link_libraries(example spdlog::static Threads::Threads) endif() add_executable(multisink multisink.cpp) -target_link_libraries(multisink spdlog::spdlog Threads::Threads) +target_link_libraries(multisink spdlog::static Threads::Threads) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs") diff --git a/example/Makefile b/example/Makefile deleted file mode 100644 index bd6b2922..00000000 --- a/example/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -CXX ?= g++ -CXX_FLAGS = -Wall -Wextra -pedantic -std=c++11 -pthread -I../include -fmax-errors=1 -Wconversion -CXX_RELEASE_FLAGS = -O3 -march=native -CXX_DEBUG_FLAGS= -g - -all: example -debug: example-debug - -example: example.cpp - $(CXX) example.cpp -o example $(CXX_FLAGS) $(CXX_RELEASE_FLAGS) $(CXXFLAGS) - - -example-debug: example.cpp - $(CXX) example.cpp -o example-debug $(CXX_FLAGS) $(CXX_DEBUG_FLAGS) $(CXXFLAGS) - -clean: - rm -f *.o logs/*.txt example example-debug - - -rebuild: clean all -rebuild-debug: clean debug diff --git a/example/Makefile-all-warn b/example/Makefile-all-warn deleted file mode 100644 index 2ba68e2a..00000000 --- a/example/Makefile-all-warn +++ /dev/null @@ -1,22 +0,0 @@ -#-Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -CXX ?= g++ -CXX_FLAGS = -Wall -Wextra -pedantic -std=c++11 -pthread -I../include -fmax-errors=1 -Wconversion -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-weak-vtables -Wno-global-constructors -CXX_RELEASE_FLAGS = -O3 -march=native -CXX_DEBUG_FLAGS= -g - -all: example -debug: example-debug - -example: example.cpp - $(CXX) example.cpp -o example $(CXX_FLAGS) $(CXX_RELEASE_FLAGS) $(CXXFLAGS) - - -example-debug: example.cpp - $(CXX) example.cpp -o example-debug $(CXX_FLAGS) $(CXX_DEBUG_FLAGS) $(CXXFLAGS) - -clean: - rm -f *.o logs/*.txt example example-debug - - -rebuild: clean all -rebuild-debug: clean debug diff --git a/example/Makefile.clang b/example/Makefile.clang deleted file mode 100644 index 475855db..00000000 --- a/example/Makefile.clang +++ /dev/null @@ -1,26 +0,0 @@ -CXX = clang++ -CXXFLAGS = -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -I../include -CXX_RELEASE_FLAGS = -O2 -CXX_DEBUG_FLAGS= -g - - -all: example -debug: example-debug - -example: example.cpp - $(CXX) example.cpp -o example-clang $(CXXFLAGS) $(CXX_RELEASE_FLAGS) - - - -example-debug: example.cpp - $(CXX) example.cpp -o example-clang-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS) - - -clean: - rm -f *.o logs/*.txt example-clang example-clang-debug - - -rebuild: clean all -rebuild-debug: clean debug - - diff --git a/example/Makefile.mingw b/example/Makefile.mingw deleted file mode 100644 index 247a818b..00000000 --- a/example/Makefile.mingw +++ /dev/null @@ -1,25 +0,0 @@ -CXX ?= g++ -CXXFLAGS = -D_WIN32_WINNT=0x600 -march=native -Wall -Wextra -pedantic -std=gnu++0x -pthread -Wl,--no-as-needed -I../include -CXX_RELEASE_FLAGS = -O3 -CXX_DEBUG_FLAGS= -g - - -all: example -debug: example-debug - -example: example.cpp - $(CXX) example.cpp -o example $(CXXFLAGS) $(CXX_RELEASE_FLAGS) - - -example-debug: example.cpp - $(CXX) example.cpp -o example-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS) - - -clean: - rm -f *.o logs/*.txt example example-debug - - -rebuild: clean all -rebuild-debug: clean debug - - diff --git a/example/example.cpp b/example/example.cpp index 80da45bb..ce57fc9d 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -2,7 +2,6 @@ // Copyright(c) 2015 Gabi Melman. // Distributed under the MIT License (http://opensource.org/licenses/MIT) - // spdlog usage example #include diff --git a/example/example.sln b/example/example.sln deleted file mode 100644 index b29a9e47..00000000 --- a/example/example.sln +++ /dev/null @@ -1,106 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2018 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example.vcxproj", "{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "spdlog", "spdlog", "{7FC6AB76-AD88-4135-888C-0568E81475AF}" - ProjectSection(SolutionItems) = preProject - ..\include\spdlog\async.h = ..\include\spdlog\async.h - ..\include\spdlog\async_logger.h = ..\include\spdlog\async_logger.h - ..\include\spdlog\common.h = ..\include\spdlog\common.h - ..\include\spdlog\formatter.h = ..\include\spdlog\formatter.h - ..\include\spdlog\logger.h = ..\include\spdlog\logger.h - ..\include\spdlog\spdlog.h = ..\include\spdlog\spdlog.h - ..\include\spdlog\tweakme.h = ..\include\spdlog\tweakme.h - ..\include\spdlog\version.h = ..\include\spdlog\version.h - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "details", "details", "{08E93803-E650-42D9-BBB4-3C16979F850E}" - ProjectSection(SolutionItems) = preProject - ..\include\spdlog\details\async_logger_impl.h = ..\include\spdlog\details\async_logger_impl.h - ..\include\spdlog\details\circular_q.h = ..\include\spdlog\details\circular_q.h - ..\include\spdlog\details\console_globals.h = ..\include\spdlog\details\console_globals.h - ..\include\spdlog\details\file_helper.h = ..\include\spdlog\details\file_helper.h - ..\include\spdlog\details\fmt_helper.h = ..\include\spdlog\details\fmt_helper.h - ..\include\spdlog\details\log_msg.h = ..\include\spdlog\details\log_msg.h - ..\include\spdlog\details\logger_impl.h = ..\include\spdlog\details\logger_impl.h - ..\include\spdlog\details\mpmc_blocking_q.h = ..\include\spdlog\details\mpmc_blocking_q.h - ..\include\spdlog\details\null_mutex.h = ..\include\spdlog\details\null_mutex.h - ..\include\spdlog\details\os.h = ..\include\spdlog\details\os.h - ..\include\spdlog\details\pattern_formatter.h = ..\include\spdlog\details\pattern_formatter.h - ..\include\spdlog\details\periodic_worker.h = ..\include\spdlog\details\periodic_worker.h - ..\include\spdlog\details\registry.h = ..\include\spdlog\details\registry.h - ..\include\spdlog\details\spdlog_impl.h = ..\include\spdlog\details\spdlog_impl.h - ..\include\spdlog\details\thread_pool.h = ..\include\spdlog\details\thread_pool.h - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fmt", "fmt", "{82378DE1-8463-4F91-91A0-C2C40E2AEA2A}" - ProjectSection(SolutionItems) = preProject - ..\include\spdlog\fmt\fmt.h = ..\include\spdlog\fmt\fmt.h - ..\include\spdlog\fmt\ostr.h = ..\include\spdlog\fmt\ostr.h - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bundled", "bundled", "{D9CA4494-80D1-48D1-A897-D3564F7B27FF}" - ProjectSection(SolutionItems) = preProject - ..\include\spdlog\fmt\bundled\format.cc = ..\include\spdlog\fmt\bundled\format.cc - ..\include\spdlog\fmt\bundled\format.h = ..\include\spdlog\fmt\bundled\format.h - ..\include\spdlog\fmt\bundled\LICENSE.rst = ..\include\spdlog\fmt\bundled\LICENSE.rst - ..\include\spdlog\fmt\bundled\ostream.cc = ..\include\spdlog\fmt\bundled\ostream.cc - ..\include\spdlog\fmt\bundled\ostream.h = ..\include\spdlog\fmt\bundled\ostream.h - ..\include\spdlog\fmt\bundled\posix.cc = ..\include\spdlog\fmt\bundled\posix.cc - ..\include\spdlog\fmt\bundled\posix.h = ..\include\spdlog\fmt\bundled\posix.h - ..\include\spdlog\fmt\bundled\printf.cc = ..\include\spdlog\fmt\bundled\printf.cc - ..\include\spdlog\fmt\bundled\printf.h = ..\include\spdlog\fmt\bundled\printf.h - ..\include\spdlog\fmt\bundled\time.h = ..\include\spdlog\fmt\bundled\time.h - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sinks", "sinks", "{27D16BB9-2B81-4F61-80EC-0C7A777248E4}" - ProjectSection(SolutionItems) = preProject - ..\include\spdlog\sinks\android_sink.h = ..\include\spdlog\sinks\android_sink.h - ..\include\spdlog\sinks\ansicolor_sink.h = ..\include\spdlog\sinks\ansicolor_sink.h - ..\include\spdlog\sinks\base_sink.h = ..\include\spdlog\sinks\base_sink.h - ..\include\spdlog\sinks\dist_sink.h = ..\include\spdlog\sinks\dist_sink.h - ..\include\spdlog\sinks\file_sinks.h = ..\include\spdlog\sinks\file_sinks.h - ..\include\spdlog\sinks\msvc_sink.h = ..\include\spdlog\sinks\msvc_sink.h - ..\include\spdlog\sinks\null_sink.h = ..\include\spdlog\sinks\null_sink.h - ..\include\spdlog\sinks\ostream_sink.h = ..\include\spdlog\sinks\ostream_sink.h - ..\include\spdlog\sinks\sink.h = ..\include\spdlog\sinks\sink.h - ..\include\spdlog\sinks\stdout_color_sinks.h = ..\include\spdlog\sinks\stdout_color_sinks.h - ..\include\spdlog\sinks\stdout_sinks.h = ..\include\spdlog\sinks\stdout_sinks.h - ..\include\spdlog\sinks\syslog_sink.h = ..\include\spdlog\sinks\syslog_sink.h - ..\include\spdlog\sinks\wincolor_sink.h = ..\include\spdlog\sinks\wincolor_sink.h - ..\include\spdlog\sinks\windebug_sink.h = ..\include\spdlog\sinks\windebug_sink.h - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Debug|Win32.ActiveCfg = Debug|Win32 - {9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Debug|Win32.Build.0 = Debug|Win32 - {9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Debug|x64.ActiveCfg = Debug|x64 - {9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Debug|x64.Build.0 = Debug|x64 - {9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Release|Win32.ActiveCfg = Release|Win32 - {9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Release|Win32.Build.0 = Release|Win32 - {9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Release|x64.ActiveCfg = Release|x64 - {9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {08E93803-E650-42D9-BBB4-3C16979F850E} = {7FC6AB76-AD88-4135-888C-0568E81475AF} - {82378DE1-8463-4F91-91A0-C2C40E2AEA2A} = {7FC6AB76-AD88-4135-888C-0568E81475AF} - {D9CA4494-80D1-48D1-A897-D3564F7B27FF} = {82378DE1-8463-4F91-91A0-C2C40E2AEA2A} - {27D16BB9-2B81-4F61-80EC-0C7A777248E4} = {7FC6AB76-AD88-4135-888C-0568E81475AF} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {1BF53532-C5DC-4236-B195-9E17CBE40A48} - EndGlobalSection -EndGlobal diff --git a/example/example.vcxproj b/example/example.vcxproj deleted file mode 100644 index c752a8e9..00000000 --- a/example/example.vcxproj +++ /dev/null @@ -1,167 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - - - - {9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2} - Win32Proj - . - - - - Application - true - v141 - Unicode - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - Application - false - v141 - true - Unicode - - - - - - - - - - - - - - - - - - - true - - - true - - - false - - - false - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - ..\include;%(AdditionalIncludeDirectories) - - - - - Console - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - ..\include;%(AdditionalIncludeDirectories) - - - - - - - Console - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - ..\include;%(AdditionalIncludeDirectories) - - - - - Console - true - true - true - %(AdditionalLibraryDirectories) - %(AdditionalDependencies) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - ..\include;%(AdditionalIncludeDirectories) - - - - - - - Console - true - true - true - %(AdditionalLibraryDirectories) - %(AdditionalDependencies) - - - - - - \ No newline at end of file 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/details/thread_pool.h b/include/spdlog/details/thread_pool.h index 42761d7a..bf1b61e8 100644 --- a/include/spdlog/details/thread_pool.h +++ b/include/spdlog/details/thread_pool.h @@ -3,7 +3,6 @@ #pragma once -#include "spdlog/details/fmt_helper.h" #include "spdlog/details/log_msg.h" #include "spdlog/details/mpmc_blocking_q.h" #include "spdlog/details/os.h" @@ -86,7 +85,7 @@ struct async_msg , source(m.source) , worker_ptr(std::move(worker)) { - fmt_helper::append_string_view(m.payload, raw); + raw.append(m.payload.data(), m.payload.data() + m.payload.size()); } async_msg(async_logger_ptr &&worker, async_msg_type the_type) 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 new file mode 100644 index 00000000..254e5085 --- /dev/null +++ b/include/spdlog/sinks/basic_file_sink-inl.h @@ -0,0 +1,43 @@ +// Copyright(c) 2015-present Gabi Melman & spdlog contributors. +// Distributed under the MIT License (http://opensource.org/licenses/MIT) + +#pragma once + +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/sinks/basic_file_sink.h" +#endif + +#include "spdlog/common.h" +#include "spdlog/details/os.h" + +namespace spdlog { +namespace sinks { + +template +SPDLOG_INLINE basic_file_sink::basic_file_sink(const filename_t &filename, bool truncate) +{ + file_helper_.open(filename, truncate); +} + +template +SPDLOG_INLINE const filename_t &basic_file_sink::filename() const +{ + return file_helper_.filename(); +} + +template +SPDLOG_INLINE void basic_file_sink::sink_it_(const details::log_msg &msg) +{ + fmt::memory_buffer formatted; + sink::formatter_->format(msg, formatted); + file_helper_.write(formatted); +} + +template +SPDLOG_INLINE void basic_file_sink::flush_() +{ + file_helper_.flush(); +} + +} // namespace sinks +} // namespace spdlog diff --git a/include/spdlog/sinks/basic_file_sink.h b/include/spdlog/sinks/basic_file_sink.h index 249a6f31..95a7a336 100644 --- a/include/spdlog/sinks/basic_file_sink.h +++ b/include/spdlog/sinks/basic_file_sink.h @@ -23,28 +23,12 @@ template class basic_file_sink final : public base_sink { public: - explicit basic_file_sink(const filename_t &filename, bool truncate = false) - { - file_helper_.open(filename, truncate); - } - - const filename_t &filename() const - { - return file_helper_.filename(); - } + explicit basic_file_sink(const filename_t &filename, bool truncate = false); + const filename_t &filename() const; protected: - void sink_it_(const details::log_msg &msg) override - { - fmt::memory_buffer formatted; - sink::formatter_->format(msg, formatted); - file_helper_.write(formatted); - } - - void flush_() override - { - file_helper_.flush(); - } + void sink_it_(const details::log_msg &msg) override; + void flush_() override; private: details::file_helper file_helper_; @@ -71,3 +55,7 @@ inline std::shared_ptr basic_logger_st(const std::string &logger_name, c } } // namespace spdlog + +#ifdef SPDLOG_HEADER_ONLY +#include "basic_file_sink-inl.h" +#endif \ No newline at end of file diff --git a/include/spdlog/sinks/daily_file_sink.h b/include/spdlog/sinks/daily_file_sink.h index a240294c..23ca6f0b 100644 --- a/include/spdlog/sinks/daily_file_sink.h +++ b/include/spdlog/sinks/daily_file_sink.h @@ -11,6 +11,7 @@ #include "spdlog/details/null_mutex.h" #include "spdlog/fmt/fmt.h" #include "spdlog/sinks/base_sink.h" +#include "spdlog/details/os.h" #include #include 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/stdout_sinks.h b/include/spdlog/sinks/stdout_sinks.h index 91274c11..91bed987 100644 --- a/include/spdlog/sinks/stdout_sinks.h +++ b/include/spdlog/sinks/stdout_sinks.h @@ -9,6 +9,7 @@ #include "spdlog/details/console_globals.h" #include "spdlog/details/null_mutex.h" +#include "spdlog/details/pattern_formatter.h" #include #include diff --git a/include/spdlog/sinks/wincolor_sink-inl.h b/include/spdlog/sinks/wincolor_sink-inl.h index 8600e0ad..912f2a6f 100644 --- a/include/spdlog/sinks/wincolor_sink-inl.h +++ b/include/spdlog/sinks/wincolor_sink-inl.h @@ -3,12 +3,19 @@ #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()) - , mutex_(ConsoleMutex::mutex()) + : out_handle_(TargetStream::handle()) + , mutex_(ConsoleMutex::mutex()) { colors_[level::trace] = WHITE; colors_[level::debug] = CYAN; @@ -49,7 +56,7 @@ void SPDLOG_INLINE wincolor_sink::log(const details: print_range_(formatted, msg.color_range_start, msg.color_range_end); ::SetConsoleTextAttribute(out_handle_, orig_attribs); // reset to orig colors - // after color range + // after color range print_range_(formatted, msg.color_range_end, formatted.size()); } else // print without colors if color range is invalid @@ -77,7 +84,7 @@ void SPDLOG_INLINE wincolor_sink::set_formatter(std: std::lock_guard lock(mutex_); formatter_ = std::move(sink_formatter); } - + // set color and return the orig console attributes (for resetting later) template WORD SPDLOG_INLINE wincolor_sink::set_console_attribs(WORD attribs) @@ -100,5 +107,5 @@ void SPDLOG_INLINE wincolor_sink::print_range_(const ::WriteConsoleA(out_handle_, formatted.data() + start, size, nullptr, nullptr); } -} +} // namespace sinks } // namespace spdlog \ No newline at end of file diff --git a/include/spdlog/sinks/wincolor_sink.h b/include/spdlog/sinks/wincolor_sink.h index 7645819c..29319fd9 100644 --- a/include/spdlog/sinks/wincolor_sink.h +++ b/include/spdlog/sinks/wincolor_sink.h @@ -35,27 +35,26 @@ public: const WORD WHITE = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; const WORD YELLOW = FOREGROUND_RED | FOREGROUND_GREEN; - wincolor_sink(); + wincolor_sink(); ~wincolor_sink() override; wincolor_sink(const wincolor_sink &other) = delete; wincolor_sink &operator=(const wincolor_sink &other) = delete; // change the color for the given level - void set_color(level::level_enum level, WORD color); - void log(const details::log_msg &msg) final override; - void flush() final override; - void set_pattern(const std::string &pattern) override final; + void set_color(level::level_enum level, WORD color); + void log(const details::log_msg &msg) final override; + void flush() final override; + void set_pattern(const std::string &pattern) override final; void set_formatter(std::unique_ptr sink_formatter) override final; - private: - using mutex_t = typename ConsoleMutex::mutex_t; + using mutex_t = typename ConsoleMutex::mutex_t; HANDLE out_handle_; mutex_t &mutex_; std::unordered_map colors_; - // set color and return the orig console attributes (for resetting later) + // set color and return the orig console attributes (for resetting later) WORD set_console_attribs(WORD attribs); // print a range of formatted message to console void print_range_(const fmt::memory_buffer &formatted, size_t start, size_t end); diff --git a/include/spdlog/spdlog-inl.h b/include/spdlog/spdlog-inl.h new file mode 100644 index 00000000..c8aa1c8e --- /dev/null +++ b/include/spdlog/spdlog-inl.h @@ -0,0 +1,100 @@ +// Copyright(c) 2015-present Gabi Melman & spdlog contributors. +// Distributed under the MIT License (http://opensource.org/licenses/MIT) + +#pragma once + +#ifndef SPDLOG_HEADER_ONLY +#include "spdlog/spdlog.h" +#endif + +#include "spdlog/common.h" +#include "spdlog/details/pattern_formatter.h" + +namespace spdlog { + +SPDLOG_INLINE void initialize_logger(std::shared_ptr logger) +{ + details::registry::instance().initialize_logger(std::move(logger)); +} + +SPDLOG_INLINE std::shared_ptr get(const std::string &name) +{ + return details::registry::instance().get(name); +} + +SPDLOG_INLINE void set_formatter(std::unique_ptr formatter) +{ + details::registry::instance().set_formatter(std::move(formatter)); +} + +SPDLOG_INLINE void set_pattern(std::string pattern, pattern_time_type time_type) +{ + set_formatter(std::unique_ptr(new pattern_formatter(std::move(pattern), time_type))); +} + +SPDLOG_INLINE void set_level(level::level_enum log_level) +{ + details::registry::instance().set_level(log_level); +} + +SPDLOG_INLINE void flush_on(level::level_enum log_level) +{ + details::registry::instance().flush_on(log_level); +} + +SPDLOG_INLINE void flush_every(std::chrono::seconds interval) +{ + details::registry::instance().flush_every(interval); +} + +SPDLOG_INLINE void set_error_handler(void (*handler)(const std::string &msg)) +{ + details::registry::instance().set_error_handler(handler); +} + +SPDLOG_INLINE void register_logger(std::shared_ptr logger) +{ + details::registry::instance().register_logger(std::move(logger)); +} + +SPDLOG_INLINE void apply_all(const std::function)> &fun) +{ + details::registry::instance().apply_all(fun); +} + +SPDLOG_INLINE void drop(const std::string &name) +{ + details::registry::instance().drop(name); +} + +SPDLOG_INLINE void drop_all() +{ + details::registry::instance().drop_all(); +} + +SPDLOG_INLINE void shutdown() +{ + details::registry::instance().shutdown(); +} + +SPDLOG_INLINE void set_automatic_registration(bool automatic_registation) +{ + details::registry::instance().set_automatic_registration(automatic_registation); +} + +SPDLOG_INLINE std::shared_ptr default_logger() +{ + return details::registry::instance().default_logger(); +} + +SPDLOG_INLINE spdlog::logger *default_logger_raw() +{ + return details::registry::instance().get_default_raw(); +} + +SPDLOG_INLINE void set_default_logger(std::shared_ptr default_logger) +{ + details::registry::instance().set_default_logger(std::move(default_logger)); +} + +} // namespace spdlog \ No newline at end of file diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index db67dba6..56a69e4c 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -11,7 +11,6 @@ #include "spdlog/common.h" #include "spdlog/details/registry.h" -#include "spdlog/details/pattern_formatter.h" #include "spdlog/logger.h" #include "spdlog/version.h" @@ -58,94 +57,52 @@ inline std::shared_ptr create(std::string logger_name, SinkArgs // auto console_sink = std::make_shared(); // auto console_logger = std::make_shared("console_logger", console_sink); // spdlog::initialize_logger(console_logger); -inline void initialize_logger(std::shared_ptr logger) -{ - details::registry::instance().initialize_logger(std::move(logger)); -} +void initialize_logger(std::shared_ptr logger); // Return an existing logger or nullptr if a logger with such name doesn't // exist. // example: spdlog::get("my_logger")->info("hello {}", "world"); -inline std::shared_ptr get(const std::string &name) -{ - return details::registry::instance().get(name); -} +std::shared_ptr get(const std::string &name); // Set global formatter. Each sink in each logger will get a clone of this object -inline void set_formatter(std::unique_ptr formatter) -{ - details::registry::instance().set_formatter(std::move(formatter)); -} +void set_formatter(std::unique_ptr formatter); // Set global format string. // example: spdlog::set_pattern("%Y-%m-%d %H:%M:%S.%e %l : %v"); -inline void set_pattern(std::string pattern, pattern_time_type time_type = pattern_time_type::local) -{ - set_formatter(std::unique_ptr(new pattern_formatter(std::move(pattern), time_type))); -} +void set_pattern(std::string pattern, pattern_time_type time_type = pattern_time_type::local); // Set global logging level -inline void set_level(level::level_enum log_level) -{ - details::registry::instance().set_level(log_level); -} +void set_level(level::level_enum log_level); // Set global flush level -inline void flush_on(level::level_enum log_level) -{ - details::registry::instance().flush_on(log_level); -} +void flush_on(level::level_enum log_level); // Start/Restart a periodic flusher thread // Warning: Use only if all your loggers are thread safe! -inline void flush_every(std::chrono::seconds interval) -{ - details::registry::instance().flush_every(interval); -} +void flush_every(std::chrono::seconds interval); // Set global error handler -inline void set_error_handler(void (*handler)(const std::string &msg)) -{ - details::registry::instance().set_error_handler(handler); -} +void set_error_handler(void (*handler)(const std::string &msg)); // Register the given logger with the given name -inline void register_logger(std::shared_ptr logger) -{ - details::registry::instance().register_logger(std::move(logger)); -} +void register_logger(std::shared_ptr logger); // Apply a user defined function on all registered loggers // Example: // spdlog::apply_all([&](std::shared_ptr l) {l->flush();}); -inline void apply_all(const std::function)> &fun) -{ - details::registry::instance().apply_all(fun); -} +void apply_all(const std::function)> &fun); // Drop the reference to the given logger -inline void drop(const std::string &name) -{ - details::registry::instance().drop(name); -} +void drop(const std::string &name); // Drop all references from the registry -inline void drop_all() -{ - details::registry::instance().drop_all(); -} +void drop_all(); // stop any running threads started by spdlog and clean registry loggers -inline void shutdown() -{ - details::registry::instance().shutdown(); -} +void shutdown(); // Automatic registration of loggers when using spdlog::create() or spdlog::create_async -inline void set_automatic_registration(bool automatic_registation) -{ - details::registry::instance().set_automatic_registration(automatic_registation); -} +void set_automatic_registration(bool automatic_registation); // API for using default logger (stdout_color_mt), // e.g: spdlog::info("Message {}", 1); @@ -162,20 +119,11 @@ inline void set_automatic_registration(bool automatic_registation) // set_default_logger() *should not* be used concurrently with the default API. // e.g do not call set_default_logger() from one thread while calling spdlog::info() from another. -inline std::shared_ptr default_logger() -{ - return details::registry::instance().default_logger(); -} +std::shared_ptr default_logger(); -inline spdlog::logger *default_logger_raw() -{ - return details::registry::instance().get_default_raw(); -} +spdlog::logger *default_logger_raw(); -inline void set_default_logger(std::shared_ptr default_logger) -{ - details::registry::instance().set_default_logger(std::move(default_logger)); -} +void set_default_logger(std::shared_ptr default_logger); template inline void log(source_loc source, level::level_enum lvl, const char *fmt, const Args &... args) @@ -382,4 +330,8 @@ inline void critical(const wchar_t *fmt, const Args &... args) #define SPDLOG_CRITICAL(...) (void)0 #endif +#ifdef SPDLOG_HEADER_ONLY +#include "spdlog-inl.h" +#endif + #endif // SPDLOG_H diff --git a/src/spdlog.cpp b/src/spdlog.cpp index d4e78ffc..d98458ca 100644 --- a/src/spdlog.cpp +++ b/src/spdlog.cpp @@ -8,65 +8,48 @@ #include #include -#include "spdlog/spdlog.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/rotating_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-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; @@ -74,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); @@ -86,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/CMakeLists.txt b/tests/CMakeLists.txt index 48f80e0e..2950f99e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -21,7 +21,7 @@ set(SPDLOG_UTESTS_SOURCES add_executable(${PROJECT_NAME} ${SPDLOG_UTESTS_SOURCES}) target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) -target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog) +target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::static) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs") diff --git a/tests/Makefile b/tests/Makefile deleted file mode 100644 index c9ce3c01..00000000 --- a/tests/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -CXX ?= g++ -CXXFLAGS = -Wall -pedantic -std=c++11 -pthread -Wconversion -O3 -I../include -fmax-errors=1 -LDPFALGS = -pthread -lsystemd - -CPP_FILES := $(wildcard *.cpp) -OBJ_FILES := $(addprefix ./,$(notdir $(CPP_FILES:.cpp=.o))) - - -tests: $(OBJ_FILES) - $(CXX) $(CXXFLAGS) $(LDPFALGS) -o $@ $^ - mkdir -p logs - -%.o: %.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -clean: - rm -f tests *.o logs/*.txt - -rebuild: clean tests - - - diff --git a/tests/includes.h b/tests/includes.h index 26517922..4e0eaf8a 100644 --- a/tests/includes.h +++ b/tests/includes.h @@ -20,3 +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" \ 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) { diff --git a/tests/tests.sln b/tests/tests.sln deleted file mode 100644 index 511c99c8..00000000 --- a/tests/tests.sln +++ /dev/null @@ -1,98 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27428.2037 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests", "tests.vcxproj", "{59A07559-5F38-4DD6-A7FA-DB4153690B42}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "spdlog", "spdlog", "{0C043010-E40A-43B9-A5EA-B931FC8B6EFB}" - ProjectSection(SolutionItems) = preProject - ..\include\spdlog\async.h = ..\include\spdlog\async.h - ..\include\spdlog\async_logger.h = ..\include\spdlog\async_logger.h - ..\include\spdlog\common.h = ..\include\spdlog\common.h - ..\include\spdlog\formatter.h = ..\include\spdlog\formatter.h - ..\include\spdlog\logger.h = ..\include\spdlog\logger.h - ..\include\spdlog\spdlog.h = ..\include\spdlog\spdlog.h - ..\include\spdlog\tweakme.h = ..\include\spdlog\tweakme.h - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "details", "details", "{C8A207B7-6930-4D28-85BB-EA79ADFD7DAC}" - ProjectSection(SolutionItems) = preProject - ..\include\spdlog\details\async_logger_impl.h = ..\include\spdlog\details\async_logger_impl.h - ..\include\spdlog\details\file_helper.h = ..\include\spdlog\details\file_helper.h - ..\include\spdlog\details\log_msg.h = ..\include\spdlog\details\log_msg.h - ..\include\spdlog\details\logger_impl.h = ..\include\spdlog\details\logger_impl.h - ..\include\spdlog\details\mpmc_bounded_q.h = ..\include\spdlog\details\mpmc_bounded_q.h - ..\include\spdlog\details\null_mutex.h = ..\include\spdlog\details\null_mutex.h - ..\include\spdlog\details\os.h = ..\include\spdlog\details\os.h - ..\include\spdlog\details\pattern_formatter.h = ..\include\spdlog\details\pattern_formatter.h - ..\include\spdlog\details\registry.h = ..\include\spdlog\details\registry.h - ..\include\spdlog\details\spdlog_impl.h = ..\include\spdlog\details\spdlog_impl.h - ..\include\spdlog\details\thread_pool.h = ..\include\spdlog\details\thread_pool.h - ..\include\spdlog\details\traits.h = ..\include\spdlog\details\traits.h - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fmt", "fmt", "{6512BA57-E9B9-4971-BC3A-83C784CC59A5}" - ProjectSection(SolutionItems) = preProject - ..\include\spdlog\fmt\fmt.h = ..\include\spdlog\fmt\fmt.h - ..\include\spdlog\fmt\ostr.h = ..\include\spdlog\fmt\ostr.h - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bundled", "bundled", "{F0D4A944-E0C7-4575-8254-06AC92B384E6}" - ProjectSection(SolutionItems) = preProject - ..\include\spdlog\fmt\bundled\format.cc = ..\include\spdlog\fmt\bundled\format.cc - ..\include\spdlog\fmt\bundled\format.h = ..\include\spdlog\fmt\bundled\format.h - ..\include\spdlog\fmt\bundled\LICENSE.rst = ..\include\spdlog\fmt\bundled\LICENSE.rst - ..\include\spdlog\fmt\bundled\ostream.cc = ..\include\spdlog\fmt\bundled\ostream.cc - ..\include\spdlog\fmt\bundled\ostream.h = ..\include\spdlog\fmt\bundled\ostream.h - ..\include\spdlog\fmt\bundled\posix.cc = ..\include\spdlog\fmt\bundled\posix.cc - ..\include\spdlog\fmt\bundled\posix.h = ..\include\spdlog\fmt\bundled\posix.h - ..\include\spdlog\fmt\bundled\time.h = ..\include\spdlog\fmt\bundled\time.h - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sinks", "sinks", "{093AE34A-B617-467E-8F31-3C5A85EF51EB}" - ProjectSection(SolutionItems) = preProject - ..\include\spdlog\sinks\android_sink.h = ..\include\spdlog\sinks\android_sink.h - ..\include\spdlog\sinks\ansicolor_sink.h = ..\include\spdlog\sinks\ansicolor_sink.h - ..\include\spdlog\sinks\base_sink.h = ..\include\spdlog\sinks\base_sink.h - ..\include\spdlog\sinks\dist_sink.h = ..\include\spdlog\sinks\dist_sink.h - ..\include\spdlog\sinks\msvc_sink.h = ..\include\spdlog\sinks\msvc_sink.h - ..\include\spdlog\sinks\null_sink.h = ..\include\spdlog\sinks\null_sink.h - ..\include\spdlog\sinks\ostream_sink.h = ..\include\spdlog\sinks\ostream_sink.h - ..\include\spdlog\sinks\sink.h = ..\include\spdlog\sinks\sink.h - ..\include\spdlog\sinks\stdout_color_sinks.h = ..\include\spdlog\sinks\stdout_color_sinks.h - ..\include\spdlog\sinks\stdout_sinks.h = ..\include\spdlog\sinks\stdout_sinks.h - ..\include\spdlog\sinks\syslog_sink.h = ..\include\spdlog\sinks\syslog_sink.h - ..\include\spdlog\sinks\wincolor_sink.h = ..\include\spdlog\sinks\wincolor_sink.h - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {59A07559-5F38-4DD6-A7FA-DB4153690B42}.Debug|Win32.ActiveCfg = Debug|Win32 - {59A07559-5F38-4DD6-A7FA-DB4153690B42}.Debug|Win32.Build.0 = Debug|Win32 - {59A07559-5F38-4DD6-A7FA-DB4153690B42}.Debug|x64.ActiveCfg = Debug|x64 - {59A07559-5F38-4DD6-A7FA-DB4153690B42}.Debug|x64.Build.0 = Debug|x64 - {59A07559-5F38-4DD6-A7FA-DB4153690B42}.Release|Win32.ActiveCfg = Release|Win32 - {59A07559-5F38-4DD6-A7FA-DB4153690B42}.Release|Win32.Build.0 = Release|Win32 - {59A07559-5F38-4DD6-A7FA-DB4153690B42}.Release|x64.ActiveCfg = Release|x64 - {59A07559-5F38-4DD6-A7FA-DB4153690B42}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {C8A207B7-6930-4D28-85BB-EA79ADFD7DAC} = {0C043010-E40A-43B9-A5EA-B931FC8B6EFB} - {6512BA57-E9B9-4971-BC3A-83C784CC59A5} = {0C043010-E40A-43B9-A5EA-B931FC8B6EFB} - {F0D4A944-E0C7-4575-8254-06AC92B384E6} = {6512BA57-E9B9-4971-BC3A-83C784CC59A5} - {093AE34A-B617-467E-8F31-3C5A85EF51EB} = {0C043010-E40A-43B9-A5EA-B931FC8B6EFB} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {1D363F0E-2DC2-4544-963A-9812679AFF6B} - EndGlobalSection -EndGlobal diff --git a/tests/tests.vcxproj b/tests/tests.vcxproj deleted file mode 100644 index a246fd21..00000000 --- a/tests/tests.vcxproj +++ /dev/null @@ -1,148 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {59A07559-5F38-4DD6-A7FA-DB4153690B42} - tests - 10.0.16299.0 - - - - Application - true - v141 - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - Level3 - Disabled - true - $(SolutionDir)\..\include;%(AdditionalIncludeDirectories) - - - true - Console - - - - - Level3 - Disabled - true - _MBCS;%(PreprocessorDefinitions) - $(SolutionDir)..\include;%(AdditionalIncludeDirectories) - - - true - Console - - - - - Level3 - MaxSpeed - true - true - true - $(SolutionDir)\..\include;%(AdditionalIncludeDirectories) - - - true - true - true - Console - - - - - Level3 - MaxSpeed - true - true - true - _MBCS;%(PreprocessorDefinitions) - $(SolutionDir)..\include;%(AdditionalIncludeDirectories) - - - true - true - true - Console - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/tests.vcxproj.filters b/tests/tests.vcxproj.filters deleted file mode 100644 index c70cc496..00000000 --- a/tests/tests.vcxproj.filters +++ /dev/null @@ -1,60 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/tests/tests.vcxproj.user b/tests/tests.vcxproj.user deleted file mode 100644 index be250787..00000000 --- a/tests/tests.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file