From c892ed2df85a18b326873ca19096ee922c6b2f89 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Wed, 3 May 2017 09:31:41 +0100 Subject: [PATCH] Add logging lib spdlog. --- .gitmodules | 3 +++ lib/spdlog | 1 + src/CMakeLists.txt | 2 ++ src/main.cpp | 12 ++++++++---- 4 files changed, 14 insertions(+), 4 deletions(-) create mode 160000 lib/spdlog diff --git a/.gitmodules b/.gitmodules index 0daa23b..948076f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "lib/houdini/houdini"] path = lib/houdini/houdini url = https://github.com/vmg/houdini.git +[submodule "lib/spdlog"] + path = lib/spdlog + url = https://github.com/gabime/spdlog.git diff --git a/lib/spdlog b/lib/spdlog new file mode 160000 index 0000000..4a25802 --- /dev/null +++ b/lib/spdlog @@ -0,0 +1 @@ +Subproject commit 4a2580231259f464674d8bd998e5fb378694c98d diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8c3d4c2..2aec511 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -45,6 +45,7 @@ target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/better-enums PRIVATE ${SourceHighlight_INCLUDE_DIR} PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/utf8_v2_3_4/source + PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/spdlog/include ) target_link_libraries(${PROJECT_NAME} PRIVATE ${Boost_LIBRARIES} @@ -52,6 +53,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE ${SourceHighlight_LIBRARIES} PRIVATE mstch PRIVATE houdini + PRIVATE pthread ) target_compile_definitions(${PROJECT_NAME} PRIVATE BOOST_SPIRIT_USE_PHOENIX_V3=1 diff --git a/src/main.cpp b/src/main.cpp index 06f6fdc..f0e9193 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,7 +26,7 @@ #include "pathname/pathname.hpp" #include "duckhandy/compatibility.h" #include "settings_bag.hpp" -#include +#include #include #include #include @@ -78,9 +78,13 @@ int main() { using tawashi::PastieResponse; using tawashi::Response; -#if !defined(NDEBUG) - std::cerr << "Loading config: \"" << config_file_path() << "\"\n"; -#endif + //Prepare the logger + spdlog::set_pattern("[%Y-%m-%d %T %z] - %v"); + spdlog::set_level(spdlog::level::debug); + auto statuslog = spdlog::stderr_logger_st("statuslog"); + + statuslog->debug("Loading config: \"{}\"\n", config_file_path()); + std::ifstream conf(config_file_path()); conf >> std::noskipws; auto ini = SafeStackObject(std::istream_iterator(conf), std::istream_iterator());