diff --git a/.gitignore b/.gitignore
index d0dd3961..e1c36ed7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,48 +1,48 @@
-# Compiled Object files
-*.slo
-*.lo
-*.o
-*.obj
-
-# Compiled Dynamic libraries
-*.so
-*.dylib
-*.dll
-
-# Compiled Static libraries
-*.lai
-*.la
-*.a
-*.lib
-
-# Executables
-*.exe
-*.out
-*.app
-
-# Codelite
-.codelite
-
-# .orig files
-*.orig
-
-# example files
-example/*
-!example/example.cpp
-!example/bench.cpp
-!example/utils.h
-!example/Makefile*
-!example/example.sln
-!example/example.vcxproj
-!example/CMakeLists.txt
-
-# generated files
-generated
-
-# Cmake
-CMakeCache.txt
-CMakeFiles
-CMakeScripts
-Makefile
-cmake_install.cmake
-install_manifest.txt
+# Compiled Object files
+*.slo
+*.lo
+*.o
+*.obj
+
+# Compiled Dynamic libraries
+*.so
+*.dylib
+*.dll
+
+# Compiled Static libraries
+*.lai
+*.la
+*.a
+*.lib
+
+# Executables
+*.exe
+*.out
+*.app
+
+# Codelite
+.codelite
+
+# .orig files
+*.orig
+
+# example files
+example/*
+!example/example.cpp
+!example/bench.cpp
+!example/utils.h
+!example/Makefile*
+!example/example.sln
+!example/example.vcxproj
+!example/CMakeLists.txt
+
+# generated files
+generated
+
+# Cmake
+CMakeCache.txt
+CMakeFiles
+CMakeScripts
+Makefile
+cmake_install.cmake
+install_manifest.txt
diff --git a/INSTALL b/INSTALL
index 7ef525f6..664509d2 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,13 +1,13 @@
-spdlog is header only library.
-Just copy the files to your build tree and use a C++11 compiler
-
-Tested on:
-gcc 4.8.1 and above
-clang 3.5
-Visual Studio 2013
-
-gcc 4.8 flags: --std==c++11 -pthread -O3 -flto -Wl,--no-as-needed
-gcc 4.9 flags: --std=c++11 -pthread -O3 -flto
-
-
-see the makefile in the example folder
+spdlog is header only library.
+Just copy the files to your build tree and use a C++11 compiler
+
+Tested on:
+gcc 4.8.1 and above
+clang 3.5
+Visual Studio 2013
+
+gcc 4.8 flags: --std==c++11 -pthread -O3 -flto -Wl,--no-as-needed
+gcc 4.9 flags: --std=c++11 -pthread -O3 -flto
+
+
+see the makefile in the example folder
diff --git a/LICENSE b/LICENSE
index 806124de..4b43e064 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,22 +1,22 @@
-The MIT License (MIT)
-
-Copyright (c) 2016 Gabi Melman.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
+The MIT License (MIT)
+
+Copyright (c) 2016 Gabi Melman.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
diff --git a/bench/Makefile.mingw b/bench/Makefile.mingw
index ac5a5af7..b4357be4 100644
--- a/bench/Makefile.mingw
+++ b/bench/Makefile.mingw
@@ -1,57 +1,57 @@
-CXX ?= g++
-CXXFLAGS = -D_WIN32_WINNT=0x600 -march=native -Wall -Wextra -pedantic -std=c++11 -pthread -Wl,--no-as-needed -I../include
-CXX_RELEASE_FLAGS = -O3 -flto
-
-
-binaries=spdlog-bench spdlog-bench-mt spdlog-async boost-bench boost-bench-mt glog-bench glog-bench-mt g2log-async easylogging-bench easylogging-bench-mt
-
-all: $(binaries)
-
-spdlog-bench: spdlog-bench.cpp
- $(CXX) spdlog-bench.cpp -o spdlog-bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
-
-spdlog-bench-mt: spdlog-bench-mt.cpp
- $(CXX) spdlog-bench-mt.cpp -o spdlog-bench-mt $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
-
-spdlog-async: spdlog-async.cpp
- $(CXX) spdlog-async.cpp -o spdlog-async $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
-
-
-BOOST_FLAGS = -DBOOST_LOG_DYN_LINK -I/home/gabi/devel/boost_1_56_0/ -L/home/gabi/devel/boost_1_56_0/stage/lib -lboost_log -lboost_log_setup -lboost_filesystem -lboost_system -lboost_thread -lboost_regex -lboost_date_time -lboost_chrono
-
-boost-bench: boost-bench.cpp
- $(CXX) boost-bench.cpp -o boost-bench $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS)
-
-boost-bench-mt: boost-bench-mt.cpp
- $(CXX) boost-bench-mt.cpp -o boost-bench-mt $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS)
-
-
-GLOG_FLAGS = -lglog
-glog-bench: glog-bench.cpp
- $(CXX) glog-bench.cpp -o glog-bench $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS)
-
-glog-bench-mt: glog-bench-mt.cpp
- $(CXX) glog-bench-mt.cpp -o glog-bench-mt $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS)
-
-
-G2LOG_FLAGS = -I/home/gabi/devel/g2log/g2log/src -L/home/gabi/devel/g2log/g2log -llib_g2logger
-g2log-async: g2log-async.cpp
- $(CXX) g2log-async.cpp -o g2log-async $(CXXFLAGS) $(G2LOG_FLAGS) $(CXX_RELEASE_FLAGS)
-
-
-EASYL_FLAGS = -I../../easylogging/src/
-easylogging-bench: easylogging-bench.cpp
- $(CXX) easylogging-bench.cpp -o easylogging-bench $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)
-easylogging-bench-mt: easylogging-bench-mt.cpp
- $(CXX) easylogging-bench-mt.cpp -o easylogging-bench-mt $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)
-
-.PHONY: clean
-
-clean:
- rm -f *.o logs/* $(binaries)
-
-
-rebuild: clean all
-
-
-
+CXX ?= g++
+CXXFLAGS = -D_WIN32_WINNT=0x600 -march=native -Wall -Wextra -pedantic -std=c++11 -pthread -Wl,--no-as-needed -I../include
+CXX_RELEASE_FLAGS = -O3 -flto
+
+
+binaries=spdlog-bench spdlog-bench-mt spdlog-async boost-bench boost-bench-mt glog-bench glog-bench-mt g2log-async easylogging-bench easylogging-bench-mt
+
+all: $(binaries)
+
+spdlog-bench: spdlog-bench.cpp
+ $(CXX) spdlog-bench.cpp -o spdlog-bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
+
+spdlog-bench-mt: spdlog-bench-mt.cpp
+ $(CXX) spdlog-bench-mt.cpp -o spdlog-bench-mt $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
+
+spdlog-async: spdlog-async.cpp
+ $(CXX) spdlog-async.cpp -o spdlog-async $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
+
+
+BOOST_FLAGS = -DBOOST_LOG_DYN_LINK -I/home/gabi/devel/boost_1_56_0/ -L/home/gabi/devel/boost_1_56_0/stage/lib -lboost_log -lboost_log_setup -lboost_filesystem -lboost_system -lboost_thread -lboost_regex -lboost_date_time -lboost_chrono
+
+boost-bench: boost-bench.cpp
+ $(CXX) boost-bench.cpp -o boost-bench $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS)
+
+boost-bench-mt: boost-bench-mt.cpp
+ $(CXX) boost-bench-mt.cpp -o boost-bench-mt $(CXXFLAGS) $(BOOST_FLAGS) $(CXX_RELEASE_FLAGS)
+
+
+GLOG_FLAGS = -lglog
+glog-bench: glog-bench.cpp
+ $(CXX) glog-bench.cpp -o glog-bench $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS)
+
+glog-bench-mt: glog-bench-mt.cpp
+ $(CXX) glog-bench-mt.cpp -o glog-bench-mt $(CXXFLAGS) $(GLOG_FLAGS) $(CXX_RELEASE_FLAGS)
+
+
+G2LOG_FLAGS = -I/home/gabi/devel/g2log/g2log/src -L/home/gabi/devel/g2log/g2log -llib_g2logger
+g2log-async: g2log-async.cpp
+ $(CXX) g2log-async.cpp -o g2log-async $(CXXFLAGS) $(G2LOG_FLAGS) $(CXX_RELEASE_FLAGS)
+
+
+EASYL_FLAGS = -I../../easylogging/src/
+easylogging-bench: easylogging-bench.cpp
+ $(CXX) easylogging-bench.cpp -o easylogging-bench $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)
+easylogging-bench-mt: easylogging-bench-mt.cpp
+ $(CXX) easylogging-bench-mt.cpp -o easylogging-bench-mt $(CXXFLAGS) $(EASYL_FLAGS) $(CXX_RELEASE_FLAGS)
+
+.PHONY: clean
+
+clean:
+ rm -f *.o logs/* $(binaries)
+
+
+rebuild: clean all
+
+
+
diff --git a/bench/easyl.conf b/bench/easyl.conf
index 02f14989..3bfb5440 100644
--- a/bench/easyl.conf
+++ b/bench/easyl.conf
@@ -1,10 +1,10 @@
-* GLOBAL:
- FORMAT = "[%datetime]: %msg"
- FILENAME = ./logs/easylogging.log
- ENABLED = true
- TO_FILE = true
- TO_STANDARD_OUTPUT = false
- MILLISECONDS_WIDTH = 3
- PERFORMANCE_TRACKING = false
- MAX_LOG_FILE_SIZE = 10485760
- Log_Flush_Threshold = 10485760
+* GLOBAL:
+ FORMAT = "[%datetime]: %msg"
+ FILENAME = ./logs/easylogging.log
+ ENABLED = true
+ TO_FILE = true
+ TO_STANDARD_OUTPUT = false
+ MILLISECONDS_WIDTH = 3
+ PERFORMANCE_TRACKING = false
+ MAX_LOG_FILE_SIZE = 10485760
+ Log_Flush_Threshold = 10485760
diff --git a/bench/logs/.gitignore b/bench/logs/.gitignore
index 5e7d2734..40637012 100644
--- a/bench/logs/.gitignore
+++ b/bench/logs/.gitignore
@@ -1,4 +1,4 @@
-# Ignore everything in this directory
-*
-# Except this file
-!.gitignore
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
diff --git a/bench/run_all.sh b/bench/run_all.sh
deleted file mode 100755
index fcecc379..00000000
--- a/bench/run_all.sh
+++ /dev/null
@@ -1,76 +0,0 @@
-#~/bin/bash
-#execute each bench 3 times and print the timing
-
-exec 2>&1
-
-#execute and time given exe 3 times
-bench_exe ()
-{
- echo "**************** $1 ****************"
- for i in {1..3}; do
- time ./$1 $2;
- rm -f logs/*
- sleep 3
- done;
-}
-
-#execute given async tests 3 times (timing is already builtin)
-bench_async ()
-{
- echo "**************** $1 ****************"
- for i in {1..3}; do
- ./$1 $2;
- echo
- rm -f logs/*
- sleep 3
- done;
-}
-
-
-echo "----------------------------------------------------------"
-echo "Single threaded benchmarks.. (1 thread, 1,000,000 lines)"
-echo "----------------------------------------------------------"
-for exe in boost-bench glog-bench easylogging-bench zf_log-bench spdlog-bench;
-do
- bench_exe $exe 1
-done;
-
-echo "----------------------------------------------------------"
-echo "Multi threaded benchmarks.. (10 threads, 1,000,000 lines)"
-echo "----------------------------------------------------------"
-for exe in boost-bench-mt glog-bench-mt easylogging-bench-mt zf_log-bench-mt spdlog-bench-mt;
-do
- bench_exe $exe 10
-done;
-
-echo "----------------------------------------------------------"
-echo "Multi threaded benchmarks.. (100 threads, 1,000,000 lines)"
-echo "----------------------------------------------------------"
-for exe in boost-bench-mt glog-bench-mt easylogging-bench-mt zf_log-bench-mt spdlog-bench-mt;
-do
- bench_exe $exe 100
-done;
-
-echo "---------------------------------------------------------------"
-echo "Async, single threaded benchmark.. (1 thread, 1,000,000 lines)"
-echo "---------------------------------------------------------------"
-for exe in spdlog-async g2log-async
-do
- bench_async $exe 1
-done;
-
-echo "---------------------------------------------------------------"
-echo "Async, multi threaded benchmark.. (10 threads, 1,000,000 lines)"
-echo "---------------------------------------------------------------"
-for exe in spdlog-async g2log-async
-do
- bench_async $exe 10
-done;
-
-echo "---------------------------------------------------------------"
-echo "Async, multi threaded benchmark.. (100 threads, 1,000,000 lines)"
-echo "---------------------------------------------------------------"
-for exe in spdlog-async g2log-async
-do
- bench_async $exe 100
-done;
diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in
index b59e23e8..ba0b36f2 100644
--- a/cmake/Config.cmake.in
+++ b/cmake/Config.cmake.in
@@ -1,24 +1,24 @@
-# *************************************************************************/
-# * Copyright (c) 2015 Ruslan Baratov. */
-# * */
-# * Permission is hereby granted, free of charge, to any person obtaining */
-# * a copy of this software and associated documentation files (the */
-# * "Software"), to deal in the Software without restriction, including */
-# * without limitation the rights to use, copy, modify, merge, publish, */
-# * distribute, sublicense, and/or sell copies of the Software, and to */
-# * permit persons to whom the Software is furnished to do so, subject to */
-# * the following conditions: */
-# * */
-# * The above copyright notice and this permission notice shall be */
-# * included in all copies or substantial portions of the Software. */
-# * */
-# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-# * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-# * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-# * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-# * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-# *************************************************************************/
-
-include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
+# *************************************************************************/
+# * Copyright (c) 2015 Ruslan Baratov. */
+# * */
+# * Permission is hereby granted, free of charge, to any person obtaining */
+# * a copy of this software and associated documentation files (the */
+# * "Software"), to deal in the Software without restriction, including */
+# * without limitation the rights to use, copy, modify, merge, publish, */
+# * distribute, sublicense, and/or sell copies of the Software, and to */
+# * permit persons to whom the Software is furnished to do so, subject to */
+# * the following conditions: */
+# * */
+# * The above copyright notice and this permission notice shall be */
+# * included in all copies or substantial portions of the Software. */
+# * */
+# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+# * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+# * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+# * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+# * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+# *************************************************************************/
+
+include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
diff --git a/cmake/spdlog.pc.in b/cmake/spdlog.pc.in
index 2c94a0ad..262248a7 100644
--- a/cmake/spdlog.pc.in
+++ b/cmake/spdlog.pc.in
@@ -1,6 +1,6 @@
-prefix=@CMAKE_INSTALL_PREFIX@
-includedir=${prefix}/include
-
-Name: @PROJECT_NAME@
-Description: Super fast C++ logging library.
-Version: @PROJECT_VERSION@
+prefix=@CMAKE_INSTALL_PREFIX@
+includedir=${prefix}/include
+
+Name: @PROJECT_NAME@
+Description: Super fast C++ logging library.
+Version: @PROJECT_VERSION@
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index d63b7c97..1944acaa 100644
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -1,46 +1,46 @@
-# *************************************************************************/
-# * Copyright (c) 2015 Ruslan Baratov. */
-# * */
-# * Permission is hereby granted, free of charge, to any person obtaining */
-# * a copy of this software and associated documentation files (the */
-# * "Software"), to deal in the Software without restriction, including */
-# * without limitation the rights to use, copy, modify, merge, publish, */
-# * distribute, sublicense, and/or sell copies of the Software, and to */
-# * permit persons to whom the Software is furnished to do so, subject to */
-# * the following conditions: */
-# * */
-# * The above copyright notice and this permission notice shall be */
-# * included in all copies or substantial portions of the Software. */
-# * */
-# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-# * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-# * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-# * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-# * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-# *************************************************************************/
-
-cmake_minimum_required(VERSION 3.0)
-project(SpdlogExamples)
-
-if(TARGET spdlog)
- # Part of the main project
- add_library(spdlog::spdlog ALIAS spdlog)
-else()
- # Stand-alone build
- find_package(spdlog CONFIG REQUIRED)
-endif()
-
-find_package(Threads)
-
-add_executable(example example.cpp)
-target_link_libraries(example spdlog::spdlog ${CMAKE_THREAD_LIBS_INIT})
-
-add_executable(benchmark bench.cpp)
-target_link_libraries(benchmark spdlog::spdlog ${CMAKE_THREAD_LIBS_INIT})
-
-enable_testing()
-file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
-add_test(NAME RunExample COMMAND example)
-add_test(NAME RunBenchmark COMMAND benchmark)
+# *************************************************************************/
+# * Copyright (c) 2015 Ruslan Baratov. */
+# * */
+# * Permission is hereby granted, free of charge, to any person obtaining */
+# * a copy of this software and associated documentation files (the */
+# * "Software"), to deal in the Software without restriction, including */
+# * without limitation the rights to use, copy, modify, merge, publish, */
+# * distribute, sublicense, and/or sell copies of the Software, and to */
+# * permit persons to whom the Software is furnished to do so, subject to */
+# * the following conditions: */
+# * */
+# * The above copyright notice and this permission notice shall be */
+# * included in all copies or substantial portions of the Software. */
+# * */
+# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+# * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+# * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+# * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+# * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+# *************************************************************************/
+
+cmake_minimum_required(VERSION 3.0)
+project(SpdlogExamples)
+
+if(TARGET spdlog)
+ # Part of the main project
+ add_library(spdlog::spdlog ALIAS spdlog)
+else()
+ # Stand-alone build
+ find_package(spdlog CONFIG REQUIRED)
+endif()
+
+find_package(Threads)
+
+add_executable(example example.cpp)
+target_link_libraries(example spdlog::spdlog ${CMAKE_THREAD_LIBS_INIT})
+
+add_executable(benchmark bench.cpp)
+target_link_libraries(benchmark spdlog::spdlog ${CMAKE_THREAD_LIBS_INIT})
+
+enable_testing()
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
+add_test(NAME RunExample COMMAND example)
+add_test(NAME RunBenchmark COMMAND benchmark)
diff --git a/example/Makefile b/example/Makefile
index 8b17c7f2..6d169e41 100644
--- a/example/Makefile
+++ b/example/Makefile
@@ -1,29 +1,29 @@
-CXX ?= g++
-CXXFLAGS =
-CXX_FLAGS = -Wall -Wshadow -Wextra -pedantic -std=c++11 -pthread -I../include
-CXX_RELEASE_FLAGS = -O3 -march=native
-CXX_DEBUG_FLAGS= -g
-
-
-all: example bench
-debug: example-debug bench-debug
-
-example: example.cpp
- $(CXX) example.cpp -o example $(CXX_FLAGS) $(CXX_RELEASE_FLAGS) $(CXXFLAGS)
-
-bench: bench.cpp
- $(CXX) bench.cpp -o bench $(CXX_FLAGS) $(CXX_RELEASE_FLAGS) $(CXXFLAGS)
-
-
-example-debug: example.cpp
- $(CXX) example.cpp -o example-debug $(CXX_FLAGS) $(CXX_DEBUG_FLAGS) $(CXXFLAGS)
-
-bench-debug: bench.cpp
- $(CXX) bench.cpp -o bench-debug $(CXX_FLAGS) $(CXX_DEBUG_FLAGS) $(CXXFLAGS)
-
-clean:
- rm -f *.o logs/*.txt example example-debug bench bench-debug
-
-
-rebuild: clean all
-rebuild-debug: clean debug
+CXX ?= g++
+CXXFLAGS =
+CXX_FLAGS = -Wall -Wshadow -Wextra -pedantic -std=c++11 -pthread -I../include
+CXX_RELEASE_FLAGS = -O3 -march=native
+CXX_DEBUG_FLAGS= -g
+
+
+all: example bench
+debug: example-debug bench-debug
+
+example: example.cpp
+ $(CXX) example.cpp -o example $(CXX_FLAGS) $(CXX_RELEASE_FLAGS) $(CXXFLAGS)
+
+bench: bench.cpp
+ $(CXX) bench.cpp -o bench $(CXX_FLAGS) $(CXX_RELEASE_FLAGS) $(CXXFLAGS)
+
+
+example-debug: example.cpp
+ $(CXX) example.cpp -o example-debug $(CXX_FLAGS) $(CXX_DEBUG_FLAGS) $(CXXFLAGS)
+
+bench-debug: bench.cpp
+ $(CXX) bench.cpp -o bench-debug $(CXX_FLAGS) $(CXX_DEBUG_FLAGS) $(CXXFLAGS)
+
+clean:
+ rm -f *.o logs/*.txt example example-debug bench bench-debug
+
+
+rebuild: clean all
+rebuild-debug: clean debug
diff --git a/example/Makefile.clang b/example/Makefile.clang
index 7efc4194..0ed004d0 100644
--- a/example/Makefile.clang
+++ b/example/Makefile.clang
@@ -1,32 +1,32 @@
-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 bench
-debug: example-debug bench-debug
-
-example: example.cpp
- $(CXX) example.cpp -o example-clang $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
-
-bench: bench.cpp
- $(CXX) bench.cpp -o bench-clang $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
-
-
-example-debug: example.cpp
- $(CXX) example.cpp -o example-clang-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
-
-bench-debug: bench.cpp
- $(CXX) bench.cpp -o bench-clang-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
-
-
-
-clean:
- rm -f *.o logs/*.txt example-clang example-clang-debug bench-clang bench-clang-debug
-
-
-rebuild: clean all
-rebuild-debug: clean debug
-
-
+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 bench
+debug: example-debug bench-debug
+
+example: example.cpp
+ $(CXX) example.cpp -o example-clang $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
+
+bench: bench.cpp
+ $(CXX) bench.cpp -o bench-clang $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
+
+
+example-debug: example.cpp
+ $(CXX) example.cpp -o example-clang-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
+
+bench-debug: bench.cpp
+ $(CXX) bench.cpp -o bench-clang-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
+
+
+
+clean:
+ rm -f *.o logs/*.txt example-clang example-clang-debug bench-clang bench-clang-debug
+
+
+rebuild: clean all
+rebuild-debug: clean debug
+
+
diff --git a/example/Makefile.mingw b/example/Makefile.mingw
index 9057a9e4..b9ffd711 100644
--- a/example/Makefile.mingw
+++ b/example/Makefile.mingw
@@ -1,32 +1,32 @@
-CXX ?= g++
-CXXFLAGS = -D_WIN32_WINNT=0x600 -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -Wl,--no-as-needed -I../include
-CXX_RELEASE_FLAGS = -O3
-CXX_DEBUG_FLAGS= -g
-
-
-all: example bench
-debug: example-debug bench-debug
-
-example: example.cpp
- $(CXX) example.cpp -o example $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
-
-bench: bench.cpp
- $(CXX) bench.cpp -o bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
-
-
-example-debug: example.cpp
- $(CXX) example.cpp -o example-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
-
-bench-debug: bench.cpp
- $(CXX) bench.cpp -o bench-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
-
-
-
-clean:
- rm -f *.o logs/*.txt example example-debug bench bench-debug
-
-
-rebuild: clean all
-rebuild-debug: clean debug
-
-
+CXX ?= g++
+CXXFLAGS = -D_WIN32_WINNT=0x600 -march=native -Wall -Wextra -Wshadow -pedantic -std=c++11 -pthread -Wl,--no-as-needed -I../include
+CXX_RELEASE_FLAGS = -O3
+CXX_DEBUG_FLAGS= -g
+
+
+all: example bench
+debug: example-debug bench-debug
+
+example: example.cpp
+ $(CXX) example.cpp -o example $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
+
+bench: bench.cpp
+ $(CXX) bench.cpp -o bench $(CXXFLAGS) $(CXX_RELEASE_FLAGS)
+
+
+example-debug: example.cpp
+ $(CXX) example.cpp -o example-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
+
+bench-debug: bench.cpp
+ $(CXX) bench.cpp -o bench-debug $(CXXFLAGS) $(CXX_DEBUG_FLAGS)
+
+
+
+clean:
+ rm -f *.o logs/*.txt example example-debug bench bench-debug
+
+
+rebuild: clean all
+rebuild-debug: clean debug
+
+
diff --git a/example/example.cpp b/example/example.cpp
index d0838433..9947e647 100644
--- a/example/example.cpp
+++ b/example/example.cpp
@@ -22,11 +22,11 @@ int main(int, char*[])
// Multithreaded color console
auto console = spd::stdout_logger_mt("console", true);
console->info("Welcome to spdlog!");
- console->info("An info message example {}..", 1);
+ console->error("An info message example {}..", 1);
// Formatting examples
- console->info("Easy padding in numbers like {:08d}", 12);
- console->info("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
+ console->warn("Easy padding in numbers like {:08d}", 12);
+ console->critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
console->info("Support for floats {:03.2f}", 1.23456);
console->info("Positional args are {1} {0}..", "too", "supported");
@@ -106,4 +106,3 @@ void syslog_example()
#endif
}
-
diff --git a/example/example.sln b/example/example.sln
index 20a6a1f4..3b21f058 100644
--- a/example/example.sln
+++ b/example/example.sln
@@ -1,22 +1,22 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.40629.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example.vcxproj", "{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- 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}.Release|Win32.ActiveCfg = Release|Win32
- {9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.40629.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example.vcxproj", "{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ 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}.Release|Win32.ActiveCfg = Release|Win32
+ {9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/example/example.vcxproj b/example/example.vcxproj
index 3356baa3..37e72395 100644
--- a/example/example.vcxproj
+++ b/example/example.vcxproj
@@ -11,8 +11,43 @@
+
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{9E5AB93A-0CCE-4BAC-9FCB-0FC9CB5EB8D2}
Win32Proj
diff --git a/example/logs/.gitignore b/example/logs/.gitignore
deleted file mode 100644
index 960fe795..00000000
--- a/example/logs/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*.txt
-
diff --git a/include/spdlog/async_logger.h b/include/spdlog/async_logger.h
index 786eb02e..769413b2 100644
--- a/include/spdlog/async_logger.h
+++ b/include/spdlog/async_logger.h
@@ -63,7 +63,7 @@ public:
void flush() override;
protected:
- void _log_msg(details::log_msg& msg) override;
+ void _sink_it(details::log_msg& msg) override;
void _set_formatter(spdlog::formatter_ptr msg_formatter) override;
void _set_pattern(const std::string& pattern) override;
diff --git a/include/spdlog/common.h b/include/spdlog/common.h
index 992b3008..004c0af4 100644
--- a/include/spdlog/common.h
+++ b/include/spdlog/common.h
@@ -56,26 +56,32 @@ using level_t = details::null_atomic_int;
using level_t = std::atomic_int;
#endif
+
+#define SPDLOG_LEVEL_TRACE 0
+#define SPDLOG_LEVEL_DEBUG 1
+#define SPDLOG_LEVEL_INFO 2
+#define SPDLOG_LEVEL_WARN 3
+#define SPDLOG_LEVEL_ERR 4
+#define SPDLOG_LEVEL_CRIT 5
+#define SPDLOG_LEVEL_OFF 6
+
//Log level enum
namespace level
{
typedef enum
{
- trace = 0,
- debug = 1,
- info = 2,
- notice = 3,
- warn = 4,
- err = 5,
- critical = 6,
- alert = 7,
- emerg = 8,
- off = 9
+ trace = SPDLOG_LEVEL_TRACE,
+ debug = SPDLOG_LEVEL_DEBUG,
+ info = SPDLOG_LEVEL_INFO,
+ warn = SPDLOG_LEVEL_WARN,
+ err = SPDLOG_LEVEL_ERR,
+ critical = SPDLOG_LEVEL_CRIT,
+ off = SPDLOG_LEVEL_OFF
} level_enum;
-static const char* level_names[] { "trace", "debug", "info", "notice", "warning", "error", "critical", "alert", "emerg", "off"};
+static const char* level_names[] { "trace", "debug", "info", "warning", "error", "critical", "off"};
-static const char* short_level_names[] { "T", "D", "I", "N", "W", "E", "C", "A", "M", "O"};
+static const char* short_level_names[] { "T", "D", "I", "W", "E", "C", "O"};
inline const char* to_str(spdlog::level::level_enum l)
{
@@ -124,5 +130,7 @@ using filename_t = std::wstring;
using filename_t = std::string;
#endif
+#define SDLOG_STR_HELPER(x) #x
+#define SPDLOG_STR(x) SDLOG_STR_HELPER(x)
} //spdlog
diff --git a/include/spdlog/details/async_log_helper.h b/include/spdlog/details/async_log_helper.h
index f6f00282..d257c994 100644
--- a/include/spdlog/details/async_log_helper.h
+++ b/include/spdlog/details/async_log_helper.h
@@ -86,21 +86,22 @@ async_msg(async_msg&& other) SPDLOG_NOEXCEPT:
// construct from log_msg
async_msg(const details::log_msg& m) :
- logger_name(m.logger_name),
level(m.level),
time(m.time),
thread_id(m.thread_id),
txt(m.raw.data(), m.raw.size()),
msg_type(async_msg_type::log)
- {}
-
+ {
+#ifndef SPDLOG_NO_NAME
+ logger_name = *m.logger_name;
+#endif
+ }
// copy into log_msg
void fill_log_msg(log_msg &msg)
{
- msg.clear();
- msg.logger_name = logger_name;
+ msg.logger_name = &logger_name;
msg.level = level;
msg.time = time;
msg.thread_id = thread_id;
@@ -278,7 +279,7 @@ inline bool spdlog::details::async_log_helper::process_next_msg(log_clock::time_
{
async_msg incoming_async_msg;
- log_msg incoming_log_msg;
+
if (_q.dequeue(incoming_async_msg))
{
@@ -295,6 +296,7 @@ inline bool spdlog::details::async_log_helper::process_next_msg(log_clock::time_
break;
default:
+ log_msg incoming_log_msg;
incoming_async_msg.fill_log_msg(incoming_log_msg);
_formatter->format(incoming_log_msg);
for (auto &s : _sinks)
diff --git a/include/spdlog/details/async_logger_impl.h b/include/spdlog/details/async_logger_impl.h
index 8fa698dd..e0af1985 100644
--- a/include/spdlog/details/async_logger_impl.h
+++ b/include/spdlog/details/async_logger_impl.h
@@ -71,7 +71,7 @@ inline void spdlog::async_logger::_set_pattern(const std::string& pattern)
}
-inline void spdlog::async_logger::_log_msg(details::log_msg& msg)
+inline void spdlog::async_logger::_sink_it(details::log_msg& msg)
{
_async_log_helper->log(msg);
}
diff --git a/include/spdlog/details/line_logger_fwd.h b/include/spdlog/details/line_logger_fwd.h
deleted file mode 100644
index eabc6eff..00000000
--- a/include/spdlog/details/line_logger_fwd.h
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// Copyright(c) 2015 Gabi Melman.
-// Distributed under the MIT License (http://opensource.org/licenses/MIT)
-//
-#pragma once
-
-#include
-#include
-
-#include
-
-// Line logger class - aggregates operator<< calls to fast ostream
-// and logs upon destruction
-
-namespace spdlog
-{
-
-// Forward declaration
-class logger;
-
-namespace details
-{
-class line_logger
-{
-public:
- line_logger(logger* callback_logger, level::level_enum msg_level, bool enabled);
-
- // No copy intended. Only move
- line_logger(const line_logger& other) = delete;
- line_logger& operator=(const line_logger&) = delete;
- line_logger& operator=(line_logger&&) = delete;
-
-
- line_logger(line_logger&& other);
-
- //Log the log message using the callback logger
- ~line_logger();
-
- //
- // Support for format string with variadic args
- //
-
-
- void write(const char* what);
-
- template
- void write(const char* fmt, const Args&... args);
-
- //
- // Support for operator<<
- //
- DEPRECATED line_logger& operator<<(const char* what);
- DEPRECATED line_logger& operator<<(const std::string& what);
- DEPRECATED line_logger& operator<<(int what);
- DEPRECATED line_logger& operator<<(unsigned int what);
- DEPRECATED line_logger& operator<<(long what);
- DEPRECATED line_logger& operator<<(unsigned long what);
- DEPRECATED line_logger& operator<<(long long what);
- DEPRECATED line_logger& operator<<(unsigned long long what);
- DEPRECATED line_logger& operator<<(double what);
- DEPRECATED line_logger& operator<<(long double what);
- DEPRECATED line_logger& operator<<(float what);
- DEPRECATED line_logger& operator<<(char what);
- //Support user types which implements operator<<
- template
- DEPRECATED line_logger& operator<<(const T& what);
-
- void disable();
- bool is_enabled() const;
-
-private:
- logger* _callback_logger;
- log_msg _log_msg;
- bool _enabled;
-};
-} //Namespace details
-} // Namespace spdlog
-
diff --git a/include/spdlog/details/line_logger_impl.h b/include/spdlog/details/line_logger_impl.h
deleted file mode 100644
index d61225af..00000000
--- a/include/spdlog/details/line_logger_impl.h
+++ /dev/null
@@ -1,185 +0,0 @@
-//
-// Copyright(c) 2015 Gabi Melman.
-// Distributed under the MIT License (http://opensource.org/licenses/MIT)
-//
-#pragma once
-#include
-
-#include
-#include
-#include
-
-#include
-#include
-
-// Line logger class - aggregates operator<< calls to fast ostream
-// and logs upon destruction
-
-inline spdlog::details::line_logger::line_logger(logger* callback_logger, level::level_enum msg_level, bool enabled):
- _callback_logger(callback_logger),
- _log_msg(msg_level),
- _enabled(enabled)
-{}
-
-inline spdlog::details::line_logger::line_logger(line_logger&& other) :
- _callback_logger(other._callback_logger),
- _log_msg(std::move(other._log_msg)),
- _enabled(other._enabled)
-{
- other.disable();
-}
-
-//Log the log message using the callback logger
-inline spdlog::details::line_logger::~line_logger()
-{
- if (_enabled)
- {
-#ifndef SPDLOG_NO_NAME
- _log_msg.logger_name = _callback_logger->name();
-#endif
-#ifndef SPDLOG_NO_DATETIME
- _log_msg.time = os::now();
-#endif
-
-#ifndef SPDLOG_NO_THREAD_ID
- _log_msg.thread_id = os::thread_id();
-#endif
- _callback_logger->_log_msg(_log_msg);
- }
-}
-
-//
-// Support for format string with variadic args
-//
-
-
-inline void spdlog::details::line_logger::write(const char* what)
-{
- if (_enabled)
- _log_msg.raw << what;
-}
-
-template
-inline void spdlog::details::line_logger::write(const char* fmt, const Args&... args)
-{
- if (!_enabled)
- return;
- try
- {
- _log_msg.raw.write(fmt, args...);
- }
- catch (const fmt::FormatError& e)
- {
- throw spdlog_ex(fmt::format("formatting error while processing format string '{}': {}", fmt, e.what()));
- }
-}
-
-
-//
-// Support for operator<<
-//
-inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(const char* what)
-{
- if (_enabled)
- _log_msg.raw << what;
- return *this;
-}
-
-inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(const std::string& what)
-{
- if (_enabled)
- _log_msg.raw << what;
- return *this;
-}
-
-inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(int what)
-{
- if (_enabled)
- _log_msg.raw << what;
- return *this;
-}
-
-inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(unsigned int what)
-{
- if (_enabled)
- _log_msg.raw << what;
- return *this;
-}
-
-
-inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(long what)
-{
- if (_enabled)
- _log_msg.raw << what;
- return *this;
-}
-
-inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(unsigned long what)
-{
- if (_enabled)
- _log_msg.raw << what;
- return *this;
-}
-
-inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(long long what)
-{
- if (_enabled)
- _log_msg.raw << what;
- return *this;
-}
-
-inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(unsigned long long what)
-{
- if (_enabled)
- _log_msg.raw << what;
- return *this;
-}
-
-inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(double what)
-{
- if (_enabled)
- _log_msg.raw << what;
- return *this;
-}
-
-inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(long double what)
-{
- if (_enabled)
- _log_msg.raw << what;
- return *this;
-}
-
-inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(float what)
-{
- if (_enabled)
- _log_msg.raw << what;
- return *this;
-}
-
-inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(char what)
-{
- if (_enabled)
- _log_msg.raw << what;
- return *this;
-}
-
-//Support user types which implements operator<<
-template
-inline spdlog::details::line_logger& spdlog::details::line_logger::operator<<(const T& what)
-{
- if (_enabled)
- _log_msg.raw.write("{}", what);
- return *this;
-}
-
-
-inline void spdlog::details::line_logger::disable()
-{
- _enabled = false;
-}
-
-inline bool spdlog::details::line_logger::is_enabled() const
-{
- return _enabled;
-}
-
diff --git a/include/spdlog/details/log_msg.h b/include/spdlog/details/log_msg.h
index 0d50b684..52bd956a 100644
--- a/include/spdlog/details/log_msg.h
+++ b/include/spdlog/details/log_msg.h
@@ -7,6 +7,7 @@
#include
#include
+#include
#include
#include
@@ -18,59 +19,23 @@ namespace details
struct log_msg
{
log_msg() = default;
- log_msg(level::level_enum l):
- logger_name(),
- level(l),
- raw(),
- formatted() {}
-
-
- log_msg(const log_msg& other) :
- logger_name(other.logger_name),
- level(other.level),
- time(other.time),
- thread_id(other.thread_id)
+ log_msg(const std::string *loggers_name, level::level_enum lvl) : logger_name(loggers_name), level(lvl)
{
- if (other.raw.size())
- raw << fmt::BasicStringRef(other.raw.data(), other.raw.size());
- if (other.formatted.size())
- formatted << fmt::BasicStringRef(other.formatted.data(), other.formatted.size());
+#ifndef SPDLOG_NO_DATETIME
+ time = os::now();
+#endif
+
+#ifndef SPDLOG_NO_THREAD_ID
+ thread_id = os::thread_id();
+#endif
}
- log_msg(log_msg&& other) :
- logger_name(std::move(other.logger_name)),
- level(other.level),
- time(std::move(other.time)),
- thread_id(other.thread_id),
- raw(std::move(other.raw)),
- formatted(std::move(other.formatted))
- {
- other.clear();
- }
+ log_msg(const log_msg& other) = delete;
+ log_msg& operator=(log_msg&& other) = delete;
+ log_msg(log_msg&& other) = delete;
- log_msg& operator=(log_msg&& other)
- {
- if (this == &other)
- return *this;
- logger_name = std::move(other.logger_name);
- level = other.level;
- time = std::move(other.time);
- thread_id = other.thread_id;
- raw = std::move(other.raw);
- formatted = std::move(other.formatted);
- other.clear();
- return *this;
- }
-
- void clear()
- {
- level = level::off;
- raw.clear();
- formatted.clear();
- }
-
- std::string logger_name;
+ const std::string *logger_name;
level::level_enum level;
log_clock::time_point time;
size_t thread_id;
diff --git a/include/spdlog/details/logger_impl.h b/include/spdlog/details/logger_impl.h
index 3eef7fec..4874e939 100644
--- a/include/spdlog/details/logger_impl.h
+++ b/include/spdlog/details/logger_impl.h
@@ -31,8 +31,7 @@ inline spdlog::logger::logger(const std::string& logger_name, sinks_init_list si
// ctor with single sink
inline spdlog::logger::logger(const std::string& logger_name, spdlog::sink_ptr single_sink) :
- logger(logger_name,
-{
+ logger(logger_name, {
single_sink
}) {}
@@ -50,210 +49,131 @@ inline void spdlog::logger::set_pattern(const std::string& pattern)
_set_pattern(pattern);
}
-//
-// log only if given level>=logger's log level
-//
-
template
-inline spdlog::details::line_logger spdlog::logger::_log_if_enabled(level::level_enum lvl, const char* fmt, const Args&... args)
+inline void spdlog::logger::log(level::level_enum lvl, const char* fmt, const Args&... args)
{
- bool msg_enabled = should_log(lvl);
- details::line_logger l(this, lvl, msg_enabled);
- l.write(fmt, args...);
- return l;
+ if (!should_log(lvl)) return;
+
+ details::log_msg log_msg(&_name, lvl);
+ try
+ {
+ log_msg.raw.write(fmt, args...);
+ }
+ catch (fmt::FormatError &ex)
+ {
+ throw spdlog::spdlog_ex(std::string("format error in \"") + fmt + "\": " + ex.what());
+ }
+
+ _formatter->format(log_msg);
+ _sink_it(log_msg);
+
}
-inline spdlog::details::line_logger spdlog::logger::_log_if_enabled(level::level_enum lvl)
+template
+inline void spdlog::logger::log(level::level_enum lvl, const char* msg)
{
- return details::line_logger(this, lvl, should_log(lvl));
+ if (!should_log(lvl)) return;
+
+ details::log_msg log_msg(&_name, lvl);
+ log_msg.raw << msg;
+ _formatter->format(log_msg);
+ _sink_it(log_msg);
+
}
template
-inline spdlog::details::line_logger spdlog::logger::_log_if_enabled(level::level_enum lvl, const T& msg)
+inline void spdlog::logger::log(level::level_enum lvl, const T& msg)
{
- bool msg_enabled = should_log(lvl);
- details::line_logger l(this, lvl, msg_enabled);
- l.write("{}", msg);
- return l;
+ if (!should_log(lvl)) return;
+
+ details::log_msg log_msg(&_name, lvl);
+ log_msg.raw << msg;
+ _formatter->format(log_msg);
+ _sink_it(log_msg);
+
}
-//
-// logger.info(cppformat_string, arg1, arg2, arg3, ...) call style
-//
+
template
-inline spdlog::details::line_logger spdlog::logger::trace(const char* fmt, const Args&... args)
+inline void spdlog::logger::trace(const char* fmt, const Args&... args)
{
- return _log_if_enabled(level::trace, fmt, args...);
+ log(level::trace, fmt, args...);
}
template
-inline spdlog::details::line_logger spdlog::logger::debug(const char* fmt, const Args&... args)
+inline void spdlog::logger::debug(const char* fmt, const Args&... args)
{
- return _log_if_enabled(level::debug, fmt, args...);
+ log(level::debug, fmt, args...);
}
template
-inline spdlog::details::line_logger spdlog::logger::info(const char* fmt, const Args&... args)
+inline void spdlog::logger::info(const char* fmt, const Args&... args)
{
- return _log_if_enabled(level::info, fmt, args...);
+ log(level::info, fmt, args...);
+}
+
+
+template
+inline void spdlog::logger::warn(const char* fmt, const Args&... args)
+{
+ log(level::warn, fmt, args...);
}
template
-inline spdlog::details::line_logger spdlog::logger::notice(const char* fmt, const Args&... args)
+inline void spdlog::logger::error(const char* fmt, const Args&... args)
{
- return _log_if_enabled(level::notice, fmt, args...);
+ log(level::err, fmt, args...);
}
template
-inline spdlog::details::line_logger spdlog::logger::warn(const char* fmt, const Args&... args)
+inline void spdlog::logger::critical(const char* fmt, const Args&... args)
{
- return _log_if_enabled(level::warn, fmt, args...);
-}
-
-template
-inline spdlog::details::line_logger spdlog::logger::error(const char* fmt, const Args&... args)
-{
- return _log_if_enabled(level::err, fmt, args...);
-}
-
-template
-inline spdlog::details::line_logger spdlog::logger::critical(const char* fmt, const Args&... args)
-{
- return _log_if_enabled(level::critical, fmt, args...);
-}
-
-template
-inline spdlog::details::line_logger spdlog::logger::alert(const char* fmt, const Args&... args)
-{
- return _log_if_enabled(level::alert, fmt, args...);
-}
-
-template
-inline spdlog::details::line_logger spdlog::logger::emerg(const char* fmt, const Args&... args)
-{
- return _log_if_enabled(level::emerg, fmt, args...);
-}
-
-//
-// logger.info(msg) << ".." call style
-//
-template
-inline spdlog::details::line_logger spdlog::logger::trace(const T& msg)
-{
- return _log_if_enabled(level::trace, msg);
-}
-
-template
-inline spdlog::details::line_logger spdlog::logger::debug(const T& msg)
-{
- return _log_if_enabled(level::debug, msg);
+ log(level::critical, fmt, args...);
}
template
-inline spdlog::details::line_logger spdlog::logger::info(const T& msg)
+inline void spdlog::logger::trace(const T& msg)
{
- return _log_if_enabled(level::info, msg);
+ log(level::trace, msg);
}
template
-inline spdlog::details::line_logger spdlog::logger::notice(const T& msg)
+inline void spdlog::logger::debug(const T& msg)
{
- return _log_if_enabled(level::notice, msg);
+ log(level::debug, msg);
+}
+
+
+template
+inline void spdlog::logger::info(const T& msg)
+{
+ log(level::info, msg);
+}
+
+
+template
+inline void spdlog::logger::warn(const T& msg)
+{
+ log(level::warn, msg);
}
template
-inline spdlog::details::line_logger spdlog::logger::warn(const T& msg)
+inline void spdlog::logger::error(const T& msg)
{
- return _log_if_enabled(level::warn, msg);
+ log(level::err, msg);
}
template
-inline spdlog::details::line_logger spdlog::logger::error(const T& msg)
+inline void spdlog::logger::critical(const T& msg)
{
- return _log_if_enabled(level::err, msg);
-}
-
-template
-inline spdlog::details::line_logger spdlog::logger::critical(const T& msg)
-{
- return _log_if_enabled(level::critical, msg);
-}
-
-template
-inline spdlog::details::line_logger spdlog::logger::alert(const T& msg)
-{
- return _log_if_enabled(level::alert, msg);
-}
-
-template
-inline spdlog::details::line_logger spdlog::logger::emerg(const T& msg)
-{
- return _log_if_enabled(level::emerg, msg);
+ log(level::critical, msg);
}
-//
-// logger.info() << ".." call style
-//
-inline spdlog::details::line_logger spdlog::logger::trace()
-{
- return _log_if_enabled(level::trace);
-}
-
-inline spdlog::details::line_logger spdlog::logger::debug()
-{
- return _log_if_enabled(level::debug);
-}
-
-inline spdlog::details::line_logger spdlog::logger::info()
-{
- return _log_if_enabled(level::info);
-}
-
-inline spdlog::details::line_logger spdlog::logger::notice()
-{
- return _log_if_enabled(level::notice);
-}
-
-inline spdlog::details::line_logger spdlog::logger::warn()
-{
- return _log_if_enabled(level::warn);
-}
-
-inline spdlog::details::line_logger spdlog::logger::error()
-{
- return _log_if_enabled(level::err);
-}
-
-inline spdlog::details::line_logger spdlog::logger::critical()
-{
- return _log_if_enabled(level::critical);
-}
-
-inline spdlog::details::line_logger spdlog::logger::alert()
-{
- return _log_if_enabled(level::alert);
-}
-
-inline spdlog::details::line_logger spdlog::logger::emerg()
-{
- return _log_if_enabled(level::emerg);
-}
-
-
-// always log, no matter what is the actual logger's log level
-template
-inline spdlog::details::line_logger spdlog::logger::force_log(level::level_enum lvl, const char* fmt, const Args&... args)
-{
- details::line_logger l(this, lvl, true);
- l.write(fmt, args...);
- return l;
-}
-
//
// name and level
//
@@ -285,9 +205,8 @@ inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) cons
//
// protected virtual called at end of each user log call (if enabled) by the line_logger
//
-inline void spdlog::logger::_log_msg(details::log_msg& msg)
+inline void spdlog::logger::_sink_it(details::log_msg& msg)
{
- _formatter->format(msg);
for (auto &sink : _sinks)
sink->log(msg);
diff --git a/include/spdlog/details/pattern_formatter_impl.h b/include/spdlog/details/pattern_formatter_impl.h
index 313bfc85..f960e726 100644
--- a/include/spdlog/details/pattern_formatter_impl.h
+++ b/include/spdlog/details/pattern_formatter_impl.h
@@ -39,7 +39,7 @@ class name_formatter :public flag_formatter
{
void format(details::log_msg& msg, const std::tm&) override
{
- msg.formatted << msg.logger_name;
+ msg.formatted << *msg.logger_name;
}
};
}
@@ -435,7 +435,7 @@ class full_formatter :public flag_formatter
#endif
#ifndef SPDLOG_NO_NAME
- msg.formatted << '[' << msg.logger_name << "] ";
+ msg.formatted << '[' << *msg.logger_name << "] ";
#endif
msg.formatted << '[' << level::to_str(msg.level) << "] ";
@@ -613,7 +613,11 @@ inline void spdlog::pattern_formatter::format(details::log_msg& msg)
{
try
{
+#ifndef SPDLOG_NO_DATETIME
auto tm_time = details::os::localtime(log_clock::to_time_t(msg.time));
+#else
+ std::tm tm_time;
+#endif
for (auto &f : _formatters)
{
f->format(msg, tm_time);
diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h
index ca94e554..63c6598b 100644
--- a/include/spdlog/logger.h
+++ b/include/spdlog/logger.h
@@ -14,12 +14,12 @@
#include
#include
-#include
#include
#include
#include
+
namespace spdlog
{
@@ -35,75 +35,42 @@ public:
logger(const logger&) = delete;
logger& operator=(const logger&) = delete;
+
+ template void log(level::level_enum lvl, const char* fmt, const Args&... args);
+ template void log(level::level_enum lvl, const char* msg);
+ template void trace(const char* fmt, const Args&... args);
+ template void debug(const char* fmt, const Args&... args);
+ template void info(const char* fmt, const Args&... args);
+ template void warn(const char* fmt, const Args&... args);
+ template void error(const char* fmt, const Args&... args);
+ template void critical(const char* fmt, const Args&... args);
+
+ template void log(level::level_enum lvl, const T&);
+ template void trace(const T&);
+ template void debug(const T&);
+ template void info(const T&);
+ template void warn(const T&);
+ template void error(const T&);
+ template void critical(const T&);
+
+
+ bool should_log(level::level_enum) const;
void set_level(level::level_enum);
level::level_enum level() const;
-
const std::string& name() const;
- bool should_log(level::level_enum) const;
-
- // automatically call flush() after a message of level log_level or higher is emitted
- void flush_on(level::level_enum log_level);
-
- // logger.info(cppformat_string, arg1, arg2, arg3, ...) call style
- template details::line_logger trace(const char* fmt, const Args&... args);
- template details::line_logger debug(const char* fmt, const Args&... args);
- template details::line_logger info(const char* fmt, const Args&... args);
- template details::line_logger notice(const char* fmt, const Args&... args);
- template details::line_logger warn(const char* fmt, const Args&... args);
- template details::line_logger error(const char* fmt, const Args&... args);
- template details::line_logger critical(const char* fmt, const Args&... args);
- template details::line_logger alert(const char* fmt, const Args&... args);
- template details::line_logger emerg(const char* fmt, const Args&... args);
-
-
- // logger.info(msg) << ".." call style
- template details::line_logger trace(const T&);
- template details::line_logger debug(const T&);
- template details::line_logger info(const T&);
- template details::line_logger notice(const T&);
- template details::line_logger warn(const T&);
- template details::line_logger error(const T&);
- template details::line_logger critical(const T&);
- template details::line_logger alert(const T&);
- template details::line_logger emerg(const T&);
-
-
- // logger.info() << ".." call style
- details::line_logger trace();
- details::line_logger debug();
- details::line_logger info();
- details::line_logger notice();
- details::line_logger warn();
- details::line_logger error();
- details::line_logger critical();
- details::line_logger alert();
- details::line_logger emerg();
-
-
-
- // Create log message with the given level, no matter what is the actual logger's level
- template
- details::line_logger force_log(level::level_enum lvl, const char* fmt, const Args&... args);
-
- // Set the format of the log messages from this logger
void set_pattern(const std::string&);
void set_formatter(formatter_ptr);
+ // automatically call flush() if message level >= log_level
+ void flush_on(level::level_enum log_level);
virtual void flush();
protected:
- virtual void _log_msg(details::log_msg&);
+ virtual void _sink_it(details::log_msg&);
virtual void _set_pattern(const std::string&);
virtual void _set_formatter(formatter_ptr);
- details::line_logger _log_if_enabled(level::level_enum lvl);
- template
- details::line_logger _log_if_enabled(level::level_enum lvl, const char* fmt, const Args&... args);
- template
- inline details::line_logger _log_if_enabled(level::level_enum lvl, const T& msg);
-
- friend details::line_logger;
- std::string _name;
+ const std::string _name;
std::vector _sinks;
formatter_ptr _formatter;
spdlog::level_t _level;
@@ -112,5 +79,5 @@ protected:
}
#include
-#include
+
diff --git a/include/spdlog/sinks/ansicolor_sink.h b/include/spdlog/sinks/ansicolor_sink.h
index 664b2599..a3b4292d 100644
--- a/include/spdlog/sinks/ansicolor_sink.h
+++ b/include/spdlog/sinks/ansicolor_sink.h
@@ -72,15 +72,12 @@ protected:
inline ansicolor_sink::ansicolor_sink(sink_ptr wrapped_sink) : sink_(wrapped_sink)
{
- colors_[level::trace] = cyan;
- colors_[level::debug] = cyan;
- colors_[level::info] = white;
- colors_[level::notice] = bold + white;
- colors_[level::warn] = bold + yellow;
- colors_[level::err] = red;
- colors_[level::critical] = bold + red;
- colors_[level::alert] = bold + white + on_red;
- colors_[level::emerg] = bold + yellow + on_red;
+ colors_[level::trace] = cyan;
+ colors_[level::debug] = cyan;
+ colors_[level::info] = bold;
+ colors_[level::warn] = yellow + bold;
+ colors_[level::err] = red + bold;
+ colors_[level::critical] = bold + on_red;
colors_[level::off] = reset;
}
@@ -91,6 +88,10 @@ inline void ansicolor_sink::log(const details::log_msg& msg)
const std::string& s = msg.formatted.str();
const std::string& suffix = reset;
details::log_msg m;
+ m.level = msg.level;
+ m.logger_name = msg.logger_name;
+ m.time = msg.time;
+ m.thread_id = msg.thread_id;
m.formatted << prefix << s << suffix;
sink_->log(m);
}
diff --git a/include/spdlog/sinks/syslog_sink.h b/include/spdlog/sinks/syslog_sink.h
index 5d7ccf87..6eea7431 100644
--- a/include/spdlog/sinks/syslog_sink.h
+++ b/include/spdlog/sinks/syslog_sink.h
@@ -35,12 +35,9 @@ public:
_priorities[static_cast(level::trace)] = LOG_DEBUG;
_priorities[static_cast(level::debug)] = LOG_DEBUG;
_priorities[static_cast(level::info)] = LOG_INFO;
- _priorities[static_cast(level::notice)] = LOG_NOTICE;
_priorities[static_cast(level::warn)] = LOG_WARNING;
_priorities[static_cast(level::err)] = LOG_ERR;
_priorities[static_cast(level::critical)] = LOG_CRIT;
- _priorities[static_cast(level::alert)] = LOG_ALERT;
- _priorities[static_cast(level::emerg)] = LOG_EMERG;
_priorities[static_cast(level::off)] = LOG_INFO;
//set ident to be program name if empty
@@ -65,7 +62,7 @@ public:
private:
- std::array _priorities;
+ std::array _priorities;
//must store the ident because the man says openlog might use the pointer as is and not a string copy
const std::string _ident;
diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h
index dc2f4181..4cb63a4c 100644
--- a/include/spdlog/spdlog.h
+++ b/include/spdlog/spdlog.h
@@ -134,14 +134,15 @@ void drop_all();
// SPDLOG_DEBUG(my_logger, "Some debug message {} {}", 1, 3.2);
///////////////////////////////////////////////////////////////////////////////
+
#ifdef SPDLOG_TRACE_ON
-#define SPDLOG_TRACE(logger, ...) logger->trace(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
+#define SPDLOG_TRACE(logger, ...) logger->trace(__FILE__ ## " line " ## SPDLOG_STR(__LINE__) ## ": " ## __VA_ARGS__);
#else
#define SPDLOG_TRACE(logger, ...)
#endif
#ifdef SPDLOG_DEBUG_ON
-#define SPDLOG_DEBUG(logger, ...) logger->debug(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
+#define SPDLOG_DEBUG(logger, ...) logger->debug(__VA_ARGS__)
#else
#define SPDLOG_DEBUG(logger, ...)
#endif
diff --git a/include/spdlog/tweakme.h b/include/spdlog/tweakme.h
index 2d6f606c..4f697c73 100644
--- a/include/spdlog/tweakme.h
+++ b/include/spdlog/tweakme.h
@@ -5,21 +5,28 @@
#pragma once
+///////////////////////////////////////////////////////////////////////////////
//
// Edit this file to squeeze every last drop of performance out of spdlog.
//
+///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Under Linux, the much faster CLOCK_REALTIME_COARSE clock can be used.
// This clock is less accurate - can be off by dozens of millis - depending on the kernel HZ.
-// Uncomment to use it instead of the regular (but slower) clock.
+// Uncomment to use it instead of the regular clock.
+//
// #define SPDLOG_CLOCK_COARSE
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-// Uncomment if date/time logging is not needed.
+// Uncomment if date/time logging is not needed and never appear in the log pattern.
// This will prevent spdlog from quering the clock on each log call.
+//
+// WARNING: If the log pattern contains any date/time while this flag is on, the result is undefined.
+// You must set new pattern(spdlog::set_pattern(..") without any date/time in it
+//
// #define SPDLOG_NO_DATETIME
///////////////////////////////////////////////////////////////////////////////
@@ -27,6 +34,9 @@
///////////////////////////////////////////////////////////////////////////////
// Uncomment if thread id logging is not needed (i.e. no %t in the log pattern).
// This will prevent spdlog from quering the thread id on each log call.
+//
+// WARNING: If the log pattern contains thread id (i.e, %t) while this flag is on, the result is undefined.
+//
// #define SPDLOG_NO_THREAD_ID
///////////////////////////////////////////////////////////////////////////////
@@ -34,12 +44,14 @@
///////////////////////////////////////////////////////////////////////////////
// Uncomment if logger name logging is not needed.
// This will prevent spdlog from copying the logger name on each log call.
+//
// #define SPDLOG_NO_NAME
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to enable the SPDLOG_DEBUG/SPDLOG_TRACE macros.
+//
// #define SPDLOG_DEBUG_ON
// #define SPDLOG_TRACE_ON
///////////////////////////////////////////////////////////////////////////////
@@ -49,18 +61,21 @@
// Uncomment to avoid locking in the registry operations (spdlog::get(), spdlog::drop() spdlog::register()).
// Use only if your code never modifes concurrently the registry.
// Note that upon creating a logger the registry is modified by spdlog..
+//
// #define SPDLOG_NO_REGISTRY_MUTEX
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to avoid spdlog's usage of atomic log levels
-// Use only if your code never modifies a logger's log levels concurrently.
+// Use only if your code never modifies a logger's log levels concurrently by different threads.
+//
// #define SPDLOG_NO_ATOMIC_LEVELS
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to enable usage of wchar_t for file names on Windows.
+//
// #define SPDLOG_WCHAR_FILENAMES
///////////////////////////////////////////////////////////////////////////////
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 4e314466..ce275ccb 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,19 +1,19 @@
-#
-# Tests
-#
-
-enable_testing()
-
-find_package(Threads)
-
-# Build Catch unit tests
-add_library(catch INTERFACE)
-target_include_directories(catch INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
-
-file(GLOB catch_tests LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
-
-add_executable(catch_tests ${catch_tests})
-target_link_libraries(catch_tests spdlog ${CMAKE_THREAD_LIBS_INIT})
-add_test(NAME catch_tests COMMAND catch_tests)
-file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
-
+#
+# Tests
+#
+
+enable_testing()
+
+find_package(Threads)
+
+# Build Catch unit tests
+add_library(catch INTERFACE)
+target_include_directories(catch INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
+
+file(GLOB catch_tests LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
+
+add_executable(catch_tests ${catch_tests})
+target_link_libraries(catch_tests spdlog ${CMAKE_THREAD_LIBS_INIT})
+add_test(NAME catch_tests COMMAND catch_tests)
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
+
diff --git a/tests/catch.hpp b/tests/catch.hpp
index 5b616a2b..925c6bff 100644
--- a/tests/catch.hpp
+++ b/tests/catch.hpp
@@ -1,9427 +1,9427 @@
-/*
- * CATCH v1.1 build 1 (master branch)
- * Generated: 2015-03-27 18:00:16.346230
- * ----------------------------------------------------------
- * This file has been merged from multiple headers. Please don't edit it directly
- * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
- *
- * Distributed under the Boost Software License, Version 1.0. (See accompanying
- * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- */
-#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
-#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
-
-#define TWOBLUECUBES_CATCH_HPP_INCLUDED
-
-// #included from: internal/catch_suppress_warnings.h
-
-#define TWOBLUECUBES_CATCH_SUPPRESS_WARNINGS_H_INCLUDED
-
-#ifdef __clang__
-# ifdef __ICC // icpc defines the __clang__ macro
-# pragma warning(push)
-# pragma warning(disable: 161 1682)
-# else // __ICC
-# pragma clang diagnostic ignored "-Wglobal-constructors"
-# pragma clang diagnostic ignored "-Wvariadic-macros"
-# pragma clang diagnostic ignored "-Wc99-extensions"
-# pragma clang diagnostic ignored "-Wunused-variable"
-# pragma clang diagnostic push
-# pragma clang diagnostic ignored "-Wpadded"
-# pragma clang diagnostic ignored "-Wc++98-compat"
-# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
-# endif
-#elif defined __GNUC__
-# pragma GCC diagnostic ignored "-Wvariadic-macros"
-# pragma GCC diagnostic ignored "-Wunused-variable"
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wpadded"
-#endif
-
-#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER)
-# define CATCH_IMPL
-#endif
-
-#ifdef CATCH_IMPL
-# ifndef CLARA_CONFIG_MAIN
-# define CLARA_CONFIG_MAIN_NOT_DEFINED
-# define CLARA_CONFIG_MAIN
-# endif
-#endif
-
-// #included from: internal/catch_notimplemented_exception.h
-#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
-
-// #included from: catch_common.h
-#define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
-
-#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
-#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
-#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
-
-#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
-#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
-
-#include
-#include
-#include
-
-// #included from: catch_compiler_capabilities.h
-#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
-
-// Much of the following code is based on Boost (1.53)
-
-#ifdef __clang__
-
-# if __has_feature(cxx_nullptr)
-# define CATCH_CONFIG_CPP11_NULLPTR
-# endif
-
-# if __has_feature(cxx_noexcept)
-# define CATCH_CONFIG_CPP11_NOEXCEPT
-# endif
-
-#endif // __clang__
-
-////////////////////////////////////////////////////////////////////////////////
-// Borland
-#ifdef __BORLANDC__
-
-#if (__BORLANDC__ > 0x582 )
-//#define CATCH_CONFIG_SFINAE // Not confirmed
-#endif
-
-#endif // __BORLANDC__
-
-////////////////////////////////////////////////////////////////////////////////
-// EDG
-#ifdef __EDG_VERSION__
-
-#if (__EDG_VERSION__ > 238 )
-//#define CATCH_CONFIG_SFINAE // Not confirmed
-#endif
-
-#endif // __EDG_VERSION__
-
-////////////////////////////////////////////////////////////////////////////////
-// Digital Mars
-#ifdef __DMC__
-
-#if (__DMC__ > 0x840 )
-//#define CATCH_CONFIG_SFINAE // Not confirmed
-#endif
-
-#endif // __DMC__
-
-////////////////////////////////////////////////////////////////////////////////
-// GCC
-#ifdef __GNUC__
-
-#if __GNUC__ < 3
-
-#if (__GNUC_MINOR__ >= 96 )
-//#define CATCH_CONFIG_SFINAE
-#endif
-
-#elif __GNUC__ >= 3
-
-// #define CATCH_CONFIG_SFINAE // Taking this out completely for now
-
-#endif // __GNUC__ < 3
-
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) )
-
-#define CATCH_CONFIG_CPP11_NULLPTR
-#endif
-
-#endif // __GNUC__
-
-////////////////////////////////////////////////////////////////////////////////
-// Visual C++
-#ifdef _MSC_VER
-
-#if (_MSC_VER >= 1600)
-#define CATCH_CONFIG_CPP11_NULLPTR
-#endif
-
-#if (_MSC_VER >= 1310 ) // (VC++ 7.0+)
-//#define CATCH_CONFIG_SFINAE // Not confirmed
-#endif
-
-#endif // _MSC_VER
-
-// Use variadic macros if the compiler supports them
-#if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \
- ( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \
- ( defined __GNUC__ && __GNUC__ >= 3 ) || \
- ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L )
-
-#ifndef CATCH_CONFIG_NO_VARIADIC_MACROS
-#define CATCH_CONFIG_VARIADIC_MACROS
-#endif
-
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// C++ language feature support
-
-// detect language version:
-#if (__cplusplus == 201103L)
-# define CATCH_CPP11
-# define CATCH_CPP11_OR_GREATER
-#elif (__cplusplus >= 201103L)
-# define CATCH_CPP11_OR_GREATER
-#endif
-
-// noexcept support:
-#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT)
-# define CATCH_NOEXCEPT noexcept
-# define CATCH_NOEXCEPT_IS(x) noexcept(x)
-#else
-# define CATCH_NOEXCEPT throw()
-# define CATCH_NOEXCEPT_IS(x)
-#endif
-
-namespace Catch {
-
- class NonCopyable {
-#ifdef CATCH_CPP11_OR_GREATER
- NonCopyable( NonCopyable const& ) = delete;
- NonCopyable( NonCopyable && ) = delete;
- NonCopyable& operator = ( NonCopyable const& ) = delete;
- NonCopyable& operator = ( NonCopyable && ) = delete;
-#else
- NonCopyable( NonCopyable const& info );
- NonCopyable& operator = ( NonCopyable const& );
-#endif
-
- protected:
- NonCopyable() {}
- virtual ~NonCopyable();
- };
-
- class SafeBool {
- public:
- typedef void (SafeBool::*type)() const;
-
- static type makeSafe( bool value ) {
- return value ? &SafeBool::trueValue : 0;
- }
- private:
- void trueValue() const {}
- };
-
- template
- inline void deleteAll( ContainerT& container ) {
- typename ContainerT::const_iterator it = container.begin();
- typename ContainerT::const_iterator itEnd = container.end();
- for(; it != itEnd; ++it )
- delete *it;
- }
- template
- inline void deleteAllValues( AssociativeContainerT& container ) {
- typename AssociativeContainerT::const_iterator it = container.begin();
- typename AssociativeContainerT::const_iterator itEnd = container.end();
- for(; it != itEnd; ++it )
- delete it->second;
- }
-
- bool startsWith( std::string const& s, std::string const& prefix );
- bool endsWith( std::string const& s, std::string const& suffix );
- bool contains( std::string const& s, std::string const& infix );
- void toLowerInPlace( std::string& s );
- std::string toLower( std::string const& s );
- std::string trim( std::string const& str );
- bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis );
-
- struct pluralise {
- pluralise( std::size_t count, std::string const& label );
-
- friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser );
-
- std::size_t m_count;
- std::string m_label;
- };
-
- struct SourceLineInfo {
-
- SourceLineInfo();
- SourceLineInfo( char const* _file, std::size_t _line );
- SourceLineInfo( SourceLineInfo const& other );
-# ifdef CATCH_CPP11_OR_GREATER
- SourceLineInfo( SourceLineInfo && ) = default;
- SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
- SourceLineInfo& operator = ( SourceLineInfo && ) = default;
-# endif
- bool empty() const;
- bool operator == ( SourceLineInfo const& other ) const;
- bool operator < ( SourceLineInfo const& other ) const;
-
- std::string file;
- std::size_t line;
- };
-
- std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info );
-
- // This is just here to avoid compiler warnings with macro constants and boolean literals
- inline bool isTrue( bool value ){ return value; }
- inline bool alwaysTrue() { return true; }
- inline bool alwaysFalse() { return false; }
-
- void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo );
-
- // Use this in variadic streaming macros to allow
- // >> +StreamEndStop
- // as well as
- // >> stuff +StreamEndStop
- struct StreamEndStop {
- std::string operator+() {
- return std::string();
- }
- };
- template
- T const& operator + ( T const& value, StreamEndStop ) {
- return value;
- }
-}
-
-#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) )
-#define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO );
-
-#include
-
-namespace Catch {
-
- class NotImplementedException : public std::exception
- {
- public:
- NotImplementedException( SourceLineInfo const& lineInfo );
- NotImplementedException( NotImplementedException const& ) {}
-
- virtual ~NotImplementedException() CATCH_NOEXCEPT {}
-
- virtual const char* what() const CATCH_NOEXCEPT;
-
- private:
- std::string m_what;
- SourceLineInfo m_lineInfo;
- };
-
-} // end namespace Catch
-
-///////////////////////////////////////////////////////////////////////////////
-#define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO )
-
-// #included from: internal/catch_context.h
-#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
-
-// #included from: catch_interfaces_generators.h
-#define TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED
-
-#include
-
-namespace Catch {
-
- struct IGeneratorInfo {
- virtual ~IGeneratorInfo();
- virtual bool moveNext() = 0;
- virtual std::size_t getCurrentIndex() const = 0;
- };
-
- struct IGeneratorsForTest {
- virtual ~IGeneratorsForTest();
-
- virtual IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) = 0;
- virtual bool moveNext() = 0;
- };
-
- IGeneratorsForTest* createGeneratorsForTest();
-
-} // end namespace Catch
-
-// #included from: catch_ptr.hpp
-#define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpadded"
-#endif
-
-namespace Catch {
-
- // An intrusive reference counting smart pointer.
- // T must implement addRef() and release() methods
- // typically implementing the IShared interface
- template
- class Ptr {
- public:
- Ptr() : m_p( NULL ){}
- Ptr( T* p ) : m_p( p ){
- if( m_p )
- m_p->addRef();
- }
- Ptr( Ptr const& other ) : m_p( other.m_p ){
- if( m_p )
- m_p->addRef();
- }
- ~Ptr(){
- if( m_p )
- m_p->release();
- }
- void reset() {
- if( m_p )
- m_p->release();
- m_p = NULL;
- }
- Ptr& operator = ( T* p ){
- Ptr temp( p );
- swap( temp );
- return *this;
- }
- Ptr& operator = ( Ptr const& other ){
- Ptr temp( other );
- swap( temp );
- return *this;
- }
- void swap( Ptr& other ) { std::swap( m_p, other.m_p ); }
- T* get() { return m_p; }
- const T* get() const{ return m_p; }
- T& operator*() const { return *m_p; }
- T* operator->() const { return m_p; }
- bool operator !() const { return m_p == NULL; }
- operator SafeBool::type() const { return SafeBool::makeSafe( m_p != NULL ); }
-
- private:
- T* m_p;
- };
-
- struct IShared : NonCopyable {
- virtual ~IShared();
- virtual void addRef() const = 0;
- virtual void release() const = 0;
- };
-
- template
- struct SharedImpl : T {
-
- SharedImpl() : m_rc( 0 ){}
-
- virtual void addRef() const {
- ++m_rc;
- }
- virtual void release() const {
- if( --m_rc == 0 )
- delete this;
- }
-
- mutable unsigned int m_rc;
- };
-
-} // end namespace Catch
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
-#include
-#include
-#include
-
-namespace Catch {
-
- class TestCase;
- class Stream;
- struct IResultCapture;
- struct IRunner;
- struct IGeneratorsForTest;
- struct IConfig;
-
- struct IContext
- {
- virtual ~IContext();
-
- virtual IResultCapture* getResultCapture() = 0;
- virtual IRunner* getRunner() = 0;
- virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0;
- virtual bool advanceGeneratorsForCurrentTest() = 0;
- virtual Ptr getConfig() const = 0;
- };
-
- struct IMutableContext : IContext
- {
- virtual ~IMutableContext();
- virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
- virtual void setRunner( IRunner* runner ) = 0;
- virtual void setConfig( Ptr const& config ) = 0;
- };
-
- IContext& getCurrentContext();
- IMutableContext& getCurrentMutableContext();
- void cleanUpContext();
- Stream createStream( std::string const& streamName );
-
-}
-
-// #included from: internal/catch_test_registry.hpp
-#define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
-
-// #included from: catch_interfaces_testcase.h
-#define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
-
-#include
-
-namespace Catch {
-
- class TestSpec;
-
- struct ITestCase : IShared {
- virtual void invoke () const = 0;
- protected:
- virtual ~ITestCase();
- };
-
- class TestCase;
- struct IConfig;
-
- struct ITestCaseRegistry {
- virtual ~ITestCaseRegistry();
- virtual std::vector const& getAllTests() const = 0;
- virtual void getFilteredTests( TestSpec const& testSpec, IConfig const& config, std::vector& matchingTestCases, bool negated = false ) const = 0;
-
- };
-}
-
-namespace Catch {
-
-template
-class MethodTestCase : public SharedImpl {
-
-public:
- MethodTestCase( void (C::*method)() ) : m_method( method ) {}
-
- virtual void invoke() const {
- C obj;
- (obj.*m_method)();
- }
-
-private:
- virtual ~MethodTestCase() {}
-
- void (C::*m_method)();
-};
-
-typedef void(*TestFunction)();
-
-struct NameAndDesc {
- NameAndDesc( const char* _name = "", const char* _description= "" )
- : name( _name ), description( _description )
- {}
-
- const char* name;
- const char* description;
-};
-
-struct AutoReg {
-
- AutoReg( TestFunction function,
- SourceLineInfo const& lineInfo,
- NameAndDesc const& nameAndDesc );
-
- template
- AutoReg( void (C::*method)(),
- char const* className,
- NameAndDesc const& nameAndDesc,
- SourceLineInfo const& lineInfo ) {
- registerTestCase( new MethodTestCase( method ),
- className,
- nameAndDesc,
- lineInfo );
- }
-
- void registerTestCase( ITestCase* testCase,
- char const* className,
- NameAndDesc const& nameAndDesc,
- SourceLineInfo const& lineInfo );
-
- ~AutoReg();
-
-private:
- AutoReg( AutoReg const& );
- void operator= ( AutoReg const& );
-};
-
-} // end namespace Catch
-
-#ifdef CATCH_CONFIG_VARIADIC_MACROS
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_TESTCASE( ... ) \
- static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )(); \
- namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\
- static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )()
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
- namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); }
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... )\
- namespace{ \
- struct INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) : ClassName{ \
- void test(); \
- }; \
- Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \
- } \
- void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test()
-
-#else
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
- static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )(); \
- namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
- static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )()
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
- namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); }
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
- namespace{ \
- struct INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) : ClassName{ \
- void test(); \
- }; \
- Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \
- } \
- void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test()
-
-#endif
-
-// #included from: internal/catch_capture.hpp
-#define TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED
-
-// #included from: catch_result_builder.h
-#define TWOBLUECUBES_CATCH_RESULT_BUILDER_H_INCLUDED
-
-// #included from: catch_result_type.h
-#define TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED
-
-namespace Catch {
-
- // ResultWas::OfType enum
- struct ResultWas { enum OfType {
- Unknown = -1,
- Ok = 0,
- Info = 1,
- Warning = 2,
-
- FailureBit = 0x10,
-
- ExpressionFailed = FailureBit | 1,
- ExplicitFailure = FailureBit | 2,
-
- Exception = 0x100 | FailureBit,
-
- ThrewException = Exception | 1,
- DidntThrowException = Exception | 2,
-
- FatalErrorCondition = 0x200 | FailureBit
-
- }; };
-
- inline bool isOk( ResultWas::OfType resultType ) {
- return ( resultType & ResultWas::FailureBit ) == 0;
- }
- inline bool isJustInfo( int flags ) {
- return flags == ResultWas::Info;
- }
-
- // ResultDisposition::Flags enum
- struct ResultDisposition { enum Flags {
- Normal = 0x00,
-
- ContinueOnFailure = 0x01, // Failures fail test, but execution continues
- FalseTest = 0x02, // Prefix expression with !
- SuppressFail = 0x04 // Failures are reported but do not fail the test
- }; };
-
- inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) {
- return static_cast( static_cast( lhs ) | static_cast( rhs ) );
- }
-
- inline bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; }
- inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; }
- inline bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; }
-
-} // end namespace Catch
-
-// #included from: catch_assertionresult.h
-#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED
-
-#include
-
-namespace Catch {
-
- struct AssertionInfo
- {
- AssertionInfo() {}
- AssertionInfo( std::string const& _macroName,
- SourceLineInfo const& _lineInfo,
- std::string const& _capturedExpression,
- ResultDisposition::Flags _resultDisposition );
-
- std::string macroName;
- SourceLineInfo lineInfo;
- std::string capturedExpression;
- ResultDisposition::Flags resultDisposition;
- };
-
- struct AssertionResultData
- {
- AssertionResultData() : resultType( ResultWas::Unknown ) {}
-
- std::string reconstructedExpression;
- std::string message;
- ResultWas::OfType resultType;
- };
-
- class AssertionResult {
- public:
- AssertionResult();
- AssertionResult( AssertionInfo const& info, AssertionResultData const& data );
- ~AssertionResult();
-# ifdef CATCH_CPP11_OR_GREATER
- AssertionResult( AssertionResult const& ) = default;
- AssertionResult( AssertionResult && ) = default;
- AssertionResult& operator = ( AssertionResult const& ) = default;
- AssertionResult& operator = ( AssertionResult && ) = default;
-# endif
-
- bool isOk() const;
- bool succeeded() const;
- ResultWas::OfType getResultType() const;
- bool hasExpression() const;
- bool hasMessage() const;
- std::string getExpression() const;
- std::string getExpressionInMacro() const;
- bool hasExpandedExpression() const;
- std::string getExpandedExpression() const;
- std::string getMessage() const;
- SourceLineInfo getSourceInfo() const;
- std::string getTestMacroName() const;
-
- protected:
- AssertionInfo m_info;
- AssertionResultData m_resultData;
- };
-
-} // end namespace Catch
-
-namespace Catch {
-
- struct TestFailureException{};
-
- template class ExpressionLhs;
-
- struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
-
- struct CopyableStream {
- CopyableStream() {}
- CopyableStream( CopyableStream const& other ) {
- oss << other.oss.str();
- }
- CopyableStream& operator=( CopyableStream const& other ) {
- oss.str("");
- oss << other.oss.str();
- return *this;
- }
- std::ostringstream oss;
- };
-
- class ResultBuilder {
- public:
- ResultBuilder( char const* macroName,
- SourceLineInfo const& lineInfo,
- char const* capturedExpression,
- ResultDisposition::Flags resultDisposition );
-
- template
- ExpressionLhs operator->* ( T const& operand );
- ExpressionLhs operator->* ( bool value );
-
- template
- ResultBuilder& operator << ( T const& value ) {
- m_stream.oss << value;
- return *this;
- }
-
- template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& );
- template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& );
-
- ResultBuilder& setResultType( ResultWas::OfType result );
- ResultBuilder& setResultType( bool result );
- ResultBuilder& setLhs( std::string const& lhs );
- ResultBuilder& setRhs( std::string const& rhs );
- ResultBuilder& setOp( std::string const& op );
-
- void endExpression();
-
- std::string reconstructExpression() const;
- AssertionResult build() const;
-
- void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal );
- void captureResult( ResultWas::OfType resultType );
- void captureExpression();
- void react();
- bool shouldDebugBreak() const;
- bool allowThrows() const;
-
- private:
- AssertionInfo m_assertionInfo;
- AssertionResultData m_data;
- struct ExprComponents {
- ExprComponents() : testFalse( false ) {}
- bool testFalse;
- std::string lhs, rhs, op;
- } m_exprComponents;
- CopyableStream m_stream;
-
- bool m_shouldDebugBreak;
- bool m_shouldThrow;
- };
-
-} // namespace Catch
-
-// Include after due to circular dependency:
-// #included from: catch_expression_lhs.hpp
-#define TWOBLUECUBES_CATCH_EXPRESSION_LHS_HPP_INCLUDED
-
-// #included from: catch_evaluate.hpp
-#define TWOBLUECUBES_CATCH_EVALUATE_HPP_INCLUDED
-
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4389) // '==' : signed/unsigned mismatch
-#endif
-
-#include
-
-namespace Catch {
-namespace Internal {
-
- enum Operator {
- IsEqualTo,
- IsNotEqualTo,
- IsLessThan,
- IsGreaterThan,
- IsLessThanOrEqualTo,
- IsGreaterThanOrEqualTo
- };
-
- template struct OperatorTraits { static const char* getName(){ return "*error*"; } };
- template<> struct OperatorTraits { static const char* getName(){ return "=="; } };
- template<> struct OperatorTraits { static const char* getName(){ return "!="; } };
- template<> struct OperatorTraits { static const char* getName(){ return "<"; } };
- template<> struct OperatorTraits { static const char* getName(){ return ">"; } };
- template<> struct OperatorTraits { static const char* getName(){ return "<="; } };
- template<> struct OperatorTraits{ static const char* getName(){ return ">="; } };
-
- template
- inline T& opCast(T const& t) { return const_cast(t); }
-
-// nullptr_t support based on pull request #154 from Konstantin Baumann
-#ifdef CATCH_CONFIG_CPP11_NULLPTR
- inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; }
-#endif // CATCH_CONFIG_CPP11_NULLPTR
-
- // So the compare overloads can be operator agnostic we convey the operator as a template
- // enum, which is used to specialise an Evaluator for doing the comparison.
- template
- class Evaluator{};
-
- template
- struct Evaluator {
- static bool evaluate( T1 const& lhs, T2 const& rhs) {
- return opCast( lhs ) == opCast( rhs );
- }
- };
- template
- struct Evaluator {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return opCast( lhs ) != opCast( rhs );
- }
- };
- template
- struct Evaluator {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return opCast( lhs ) < opCast( rhs );
- }
- };
- template
- struct Evaluator {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return opCast( lhs ) > opCast( rhs );
- }
- };
- template
- struct Evaluator {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return opCast( lhs ) >= opCast( rhs );
- }
- };
- template
- struct Evaluator {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return opCast( lhs ) <= opCast( rhs );
- }
- };
-
- template
- bool applyEvaluator( T1 const& lhs, T2 const& rhs ) {
- return Evaluator::evaluate( lhs, rhs );
- }
-
- // This level of indirection allows us to specialise for integer types
- // to avoid signed/ unsigned warnings
-
- // "base" overload
- template
- bool compare( T1 const& lhs, T2 const& rhs ) {
- return Evaluator::evaluate( lhs, rhs );
- }
-
- // unsigned X to int
- template bool compare( unsigned int lhs, int rhs ) {
- return applyEvaluator( lhs, static_cast( rhs ) );
- }
- template bool compare( unsigned long lhs, int rhs ) {
- return applyEvaluator( lhs, static_cast( rhs ) );
- }
- template bool compare( unsigned char lhs, int rhs ) {
- return applyEvaluator( lhs, static_cast( rhs ) );
- }
-
- // unsigned X to long
- template bool compare( unsigned int lhs, long rhs ) {
- return applyEvaluator( lhs, static_cast( rhs ) );
- }
- template bool compare( unsigned long lhs, long rhs ) {
- return applyEvaluator( lhs, static_cast( rhs ) );
- }
- template bool compare( unsigned char lhs, long rhs ) {
- return applyEvaluator( lhs, static_cast( rhs ) );
- }
-
- // int to unsigned X
- template bool compare( int lhs, unsigned int rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
- template bool compare( int lhs, unsigned long rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
- template bool compare( int lhs, unsigned char rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
-
- // long to unsigned X
- template bool compare( long lhs, unsigned int rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
- template bool compare( long lhs, unsigned long rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
- template bool compare( long lhs, unsigned char rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
-
- // pointer to long (when comparing against NULL)
- template bool compare( long lhs, T* rhs ) {
- return Evaluator::evaluate( reinterpret_cast( lhs ), rhs );
- }
- template bool compare( T* lhs, long rhs ) {
- return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) );
- }
-
- // pointer to int (when comparing against NULL)
- template bool compare( int lhs, T* rhs ) {
- return Evaluator::evaluate( reinterpret_cast( lhs ), rhs );
- }
- template bool compare( T* lhs, int rhs ) {
- return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) );
- }
-
-#ifdef CATCH_CONFIG_CPP11_NULLPTR
- // pointer to nullptr_t (when comparing against nullptr)
- template bool compare( std::nullptr_t, T* rhs ) {
- return Evaluator::evaluate( NULL, rhs );
- }
- template bool compare( T* lhs, std::nullptr_t ) {
- return Evaluator::evaluate( lhs, NULL );
- }
-#endif // CATCH_CONFIG_CPP11_NULLPTR
-
-} // end of namespace Internal
-} // end of namespace Catch
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
-// #included from: catch_tostring.h
-#define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED
-
-// #included from: catch_sfinae.hpp
-#define TWOBLUECUBES_CATCH_SFINAE_HPP_INCLUDED
-
-// Try to detect if the current compiler supports SFINAE
-
-namespace Catch {
-
- struct TrueType {
- static const bool value = true;
- typedef void Enable;
- char sizer[1];
- };
- struct FalseType {
- static const bool value = false;
- typedef void Disable;
- char sizer[2];
- };
-
-#ifdef CATCH_CONFIG_SFINAE
-
- template struct NotABooleanExpression;
-
- template struct If : NotABooleanExpression {};
- template<> struct If : TrueType {};
- template<> struct If : FalseType {};
-
- template struct SizedIf;
- template<> struct SizedIf : TrueType {};
- template<> struct SizedIf : FalseType {};
-
-#endif // CATCH_CONFIG_SFINAE
-
-} // end namespace Catch
-
-#include
-#include
-#include
-#include
-#include
-
-#ifdef __OBJC__
-// #included from: catch_objc_arc.hpp
-#define TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED
-
-#import
-
-#ifdef __has_feature
-#define CATCH_ARC_ENABLED __has_feature(objc_arc)
-#else
-#define CATCH_ARC_ENABLED 0
-#endif
-
-void arcSafeRelease( NSObject* obj );
-id performOptionalSelector( id obj, SEL sel );
-
-#if !CATCH_ARC_ENABLED
-inline void arcSafeRelease( NSObject* obj ) {
- [obj release];
-}
-inline id performOptionalSelector( id obj, SEL sel ) {
- if( [obj respondsToSelector: sel] )
- return [obj performSelector: sel];
- return nil;
-}
-#define CATCH_UNSAFE_UNRETAINED
-#define CATCH_ARC_STRONG
-#else
-inline void arcSafeRelease( NSObject* ){}
-inline id performOptionalSelector( id obj, SEL sel ) {
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
-#endif
- if( [obj respondsToSelector: sel] )
- return [obj performSelector: sel];
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
- return nil;
-}
-#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained
-#define CATCH_ARC_STRONG __strong
-#endif
-
-#endif
-
-#ifdef CATCH_CPP11_OR_GREATER
-#include
-#include
-#endif
-
-namespace Catch {
-
-// Why we're here.
-template
-std::string toString( T const& value );
-
-// Built in overloads
-
-std::string toString( std::string const& value );
-std::string toString( std::wstring const& value );
-std::string toString( const char* const value );
-std::string toString( char* const value );
-std::string toString( const wchar_t* const value );
-std::string toString( wchar_t* const value );
-std::string toString( int value );
-std::string toString( unsigned long value );
-std::string toString( unsigned int value );
-std::string toString( const double value );
-std::string toString( const float value );
-std::string toString( bool value );
-std::string toString( char value );
-std::string toString( signed char value );
-std::string toString( unsigned char value );
-
-#ifdef CATCH_CONFIG_CPP11_NULLPTR
-std::string toString( std::nullptr_t );
-#endif
-
-#ifdef __OBJC__
- std::string toString( NSString const * const& nsstring );
- std::string toString( NSString * CATCH_ARC_STRONG const& nsstring );
- std::string toString( NSObject* const& nsObject );
-#endif
-
-namespace Detail {
-
- extern std::string unprintableString;
-
-// SFINAE is currently disabled by default for all compilers.
-// If the non SFINAE version of IsStreamInsertable is ambiguous for you
-// and your compiler supports SFINAE, try #defining CATCH_CONFIG_SFINAE
-#ifdef CATCH_CONFIG_SFINAE
-
- template
- class IsStreamInsertableHelper {
- template struct TrueIfSizeable : TrueType {};
-
- template
- static TrueIfSizeable dummy(T2*);
- static FalseType dummy(...);
-
- public:
- typedef SizedIf type;
- };
-
- template
- struct IsStreamInsertable : IsStreamInsertableHelper::type {};
-
-#else
-
- struct BorgType {
- template BorgType( T const& );
- };
-
- TrueType& testStreamable( std::ostream& );
- FalseType testStreamable( FalseType );
-
- FalseType operator<<( std::ostream const&, BorgType const& );
-
- template
- struct IsStreamInsertable {
- static std::ostream &s;
- static T const&t;
- enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) };
- };
-
-#endif
-
-#if defined(CATCH_CPP11_OR_GREATER)
- template::value
- >
- struct EnumStringMaker
- {
- static std::string convert( T const& ) { return unprintableString; }
- };
-
- template
- struct EnumStringMaker
- {
- static std::string convert( T const& v )
- {
- return ::Catch::toString(
- static_cast::type>(v)
- );
- }
- };
-#endif
- template
- struct StringMakerBase {
-#if defined(CATCH_CPP11_OR_GREATER)
- template
- static std::string convert( T const& v )
- {
- return EnumStringMaker::convert( v );
- }
-#else
- template
- static std::string convert( T const& ) { return unprintableString; }
-#endif
- };
-
- template<>
- struct StringMakerBase {
- template
- static std::string convert( T const& _value ) {
- std::ostringstream oss;
- oss << _value;
- return oss.str();
- }
- };
-
- std::string rawMemoryToString( const void *object, std::size_t size );
-
- template
- inline std::string rawMemoryToString( const T& object ) {
- return rawMemoryToString( &object, sizeof(object) );
- }
-
-} // end namespace Detail
-
-template
-struct StringMaker :
- Detail::StringMakerBase