logger
1.0.0
Hilfsbibliothek zur Quellcodeverfolgung und zum Debuggen.
Kann wie eine Schnittstelle (nur Header) oder eine gemeinsam genutzte Bibliothek verwendet werden.
std::cout
– StandardBeide Anwendungsbeispiele (nur Header oder gemeinsam genutzte Bibliothek) finden Sie in Tests/LoggerMainTest.
std::cout
als Protokollierungsausgabe verwendet wird: std::mutex nlab::logger::gCoutMutex; // used for output synchronization
Wenn nicht, schalten Sie die Cout-Protokollierung über das nächste Definieren aus: LOG_OUTPUT_COUT_DISABLED
, z. B. für CMake:
add_definitions(-DLOG_OUTPUT_COUT_DISABLED`)
LOGGER_BUILD_HEADER_LIB=ON
über die Befehlszeile fest, z. B.: cmake -DCMAKE_BUILD_TYPE=Release -DLOGGER_BUILD_HEADER_LIB=ON ..
oder in der obersten CMake-Datei, z. B.:
set(LOGGER_BUILD_HEADER_LIB ON CACHE BOOL "Build the header only library")
add_subdirectory(logger)
Gibt aus Tests/LoggerMainTest erfasste Beispiele aus
Für Debug-Build:
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
cd tests
make
./LoggerMainTest
06-26 17:23:21.897 [--->] LoggerMainTest.cpp:16 main() ThreadId: 140718535841600
06-26 17:23:21.897 [--->] LoggerMainTest.cpp:60 main_th() ThreadId: 140718515595008
06-26 17:23:21.897 [--->] LoggerMainTest.cpp:60 main_th() ThreadId: 140718507202304
06-26 17:23:21.897 [--->] LoggerMainTest.cpp:55 test2() ThreadId: 140718507202304
06-26 17:23:21.897 [--->] LoggerMainTest.cpp:55 test2() ThreadId: 140718515595008
06-26 17:23:21.897 [<---] LoggerMainTest.cpp:55 test2() ThreadId: 140718515595008
06-26 17:23:21.898 [<---] LoggerMainTest.cpp:55 test2() ThreadId: 140718507202304
06-26 17:23:21.998 [--->] LoggerMainTest.cpp:55 test2() ThreadId: 140718515595008
06-26 17:23:21.998 [<---] LoggerMainTest.cpp:55 test2() ThreadId: 140718515595008
06-26 17:23:21.998 [--->] LoggerMainTest.cpp:55 test2() ThreadId: 140718507202304
06-26 17:23:21.998 [<---] LoggerMainTest.cpp:55 test2() ThreadId: 140718507202304
06-26 17:23:22.098 [--->] LoggerMainTest.cpp:55 test2() ThreadId: 140718515595008
06-26 17:23:22.098 [<---] LoggerMainTest.cpp:55 test2() ThreadId: 140718515595008
06-26 17:23:22.098 [--->] LoggerMainTest.cpp:55 test2() ThreadId: 140718507202304
06-26 17:23:22.098 [<---] LoggerMainTest.cpp:55 test2() ThreadId: 140718507202304
06-26 17:23:22.198 [<---] LoggerMainTest.cpp:60 main_th() ThreadId: 140718515595008
06-26 17:23:22.198 [<---] LoggerMainTest.cpp:60 main_th() ThreadId: 140718507202304
06-26 17:23:22.198 [info] LoggerMainTest.cpp:24 main() Test Info 1
06-26 17:23:22.198 [warn] LoggerMainTest.cpp:25 main() Test Warning 2
06-26 17:23:22.198 [error] LoggerMainTest.cpp:26 main() Test Error 3
06-26 17:23:22.198 [debug] LoggerMainTest.cpp:27 main() Test Debug 4
06-26 17:23:22.198 [info] LoggerMainTest.cpp:30 main() Test 888 str c
06-26 17:23:22.199 [error] LoggerMainTest.cpp:33 main() ptr = nullptr
06-26 17:23:22.199 [--->] LoggerMainTest.cpp:50 test1() ThreadId: 140718535841600
06-26 17:23:22.199 [<---] LoggerMainTest.cpp:50 test1() ThreadId: 140718535841600
06-26 17:23:22.199 [--->] LoggerMainTest.cpp:50 test1() ThreadId: 140718535841600
06-26 17:23:22.199 [<---] LoggerMainTest.cpp:50 test1() ThreadId: 140718535841600
06-26 17:23:22.199 [--->] LoggerMainTest.cpp:50 test1() ThreadId: 140718535841600
06-26 17:23:22.199 [<---] LoggerMainTest.cpp:50 test1() ThreadId: 140718535841600
06-26 17:23:23.199 [<---] LoggerMainTest.cpp:16 main() ThreadId: 140718535841600
Für Release-Build:
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cd tests
make
./LoggerMainTest
06-26 17:37:00.411 [info] LoggerMainTest.cpp:24 main() Test Info 1
06-26 17:37:00.411 [warn] LoggerMainTest.cpp:25 main() Test Warning 2
06-26 17:37:00.411 [error] LoggerMainTest.cpp:26 main() Test Error 3
06-26 17:37:00.411 [info] LoggerMainTest.cpp:30 main() Test 888 str c
06-26 17:37:00.411 [error] LoggerMainTest.cpp:33 main() ptr = nullptr