diff --git a/.ci_templates/.clang_format.yml b/.ci_templates/.clang_format.yml index dc263197d73bc5bf68967dfd390ae2933bde2a31..b62073920184d98edef9e94f3b1312a8da89bcc2 100644 --- a/.ci_templates/.clang_format.yml +++ b/.ci_templates/.clang_format.yml @@ -11,7 +11,7 @@ # create temporary branch - if [ `git rev-parse --verify ci_clangformat 2>/dev/null` ]; then - - git branch --delete ci_clangformat + - git branch -D ci_clangformat - fi - export CI_NEW_BRANCH_CLANG=ci_clangformat - echo creating new temporary branch... $CI_NEW_BRANCH_CLANG diff --git a/.ci_templates/.license_headers.yml b/.ci_templates/.license_headers.yml index cc3b675ccd6bf027e21971d951052563cd64d77a..f2b1db32f2a2f126eb7053ac55468df95192b255 100644 --- a/.ci_templates/.license_headers.yml +++ b/.ci_templates/.license_headers.yml @@ -12,7 +12,7 @@ # create temporary branch - if [ `git rev-parse --verify ci_license_header 2>/dev/null` ]; then - - git branch --delete ci_license_header + - git branch -D ci_license_header - fi - export CI_NEW_BRANCH_LICENSE=ci_license_header - echo creating new temporary branch... $CI_NEW_BRANCH_LICENSE diff --git a/.ci_templates/.yaml_schema_cpp.yml b/.ci_templates/.yaml_schema_cpp.yml index fb7056750f841bfdd95de84630bd4f1da6127089..1e26f3d7963d9a90429e11224e4f8869d57fed14 100644 --- a/.ci_templates/.yaml_schema_cpp.yml +++ b/.ci_templates/.yaml_schema_cpp.yml @@ -38,7 +38,7 @@ # create temporary branch - if [ `git rev-parse --verify ci_yamlschemacpp 2>/dev/null` ]; then - - git branch --delete ci_yamlschemacpp + - git branch -D ci_yamlschemacpp - fi - export CI_NEW_BRANCH_YAML=ci_yamlschemacpp - echo creating new temporary branch... $CI_NEW_BRANCH_YAML diff --git a/include/core/utils/logging.h b/include/core/utils/logging.h index df58dfd1fb8e57857e86fba961cdb7ff017d06ba..1fac8415226635b9780c47cfc1a81ade87b4c474 100644 --- a/include/core/utils/logging.h +++ b/include/core/utils/logging.h @@ -34,8 +34,10 @@ // spdlog include #include "spdlog/spdlog.h" +#include "spdlog/async.h" // enable the use of ostream operator<< -#include "spdlog/fmt/bundled/ostream.h" +#include "spdlog/fmt/ostr.h" +#include "spdlog/sinks/stdout_color_sinks.h" // Wolf includes #include "core/utils/singleton.h" @@ -125,7 +127,7 @@ inline Logger::Logger(const std::string& name) : // Enable asynchronous logging // Queue size must be a power of 2 - spdlog::set_async_mode(4096); + spdlog::init_thread_pool(4096, 1); if (log_name_ == __INTERNAL_WOLF_MAIN_LOGGER_NAME_) // Logging pattern is : @@ -133,13 +135,13 @@ inline Logger::Logger(const std::string& name) : //set_pattern("[%t][%H:%M:%S.%F][%l] %v"); // [log type][MM/DD/YY - hour:minutes:seconds.nanoseconds] #log-content // set_pattern("[%l][%x - %H:%M:%S.%F] %v"); - set_pattern("[%l][%H:%M:%S] %v"); + set_pattern("%^[%l][%H:%M:%S] %v%$"); else // Logging pattern is : // [logger name][thread num][hour:minutes:seconds.nanoseconds][log type] #log-content //set_pattern("[" + log_name_ + "]" +"[%t][%H:%M:%S.%F][%l] %v"); // [log type][MM/DD/YY - hour:minutes:seconds.nanoseconds][logger name] #log-content - set_pattern("[%l][%x - %H:%M:%S.%F][" + log_name_ + "] %v"); + set_pattern("%^[%l][%x - %H:%M:%S.%F][" + log_name_ + "] %v%$"); } inline Logger::Logger(std::string&& name) : @@ -154,7 +156,7 @@ inline Logger::Logger(std::string&& name) : // Enable asynchronous logging // Queue size must be a power of 2 - spdlog::set_async_mode(4096); + spdlog::init_thread_pool(4096, 1); if (log_name_ == __INTERNAL_WOLF_MAIN_LOGGER_NAME_) // Logging pattern is : @@ -162,13 +164,13 @@ inline Logger::Logger(std::string&& name) : //set_pattern("[%t][%H:%M:%S.%F][%l] %v"); // [log type][MM/DD/YY - hour:minutes:seconds.nanoseconds] #log-content // set_pattern("[%l][%x - %H:%M:%S.%F] %v"); - set_pattern("[%l][%H:%M:%S] %v"); + set_pattern("%^[%l][%H:%M:%S] %v%$"); else // Logging pattern is : // [logger name][thread num][hour:minutes:seconds.nanoseconds][log type] #log-content //set_pattern("[" + log_name_ + "]" +"[%t][%H:%M:%S.%F][%l] %v"); // [log type][MM/DD/YY - hour:minutes:seconds.nanoseconds][logger name] #log-content - set_pattern("[%l][%x - %H:%M:%S.%F][" + log_name_ + "] %v"); + set_pattern("%^[%l][%x - %H:%M:%S.%F][" + log_name_ + "] %v%$"); } inline Logger::~Logger() @@ -209,8 +211,7 @@ void Logger::trace(Args&&... args) const inline bool Logger::set_async_queue(const std::size_t q_size) { bool p2 = q_size%2 == 0; - - if (p2) spdlog::set_async_mode(q_size); + if (p2) spdlog::init_thread_pool(q_size, 1); return q_size; } diff --git a/test/gtest_logging.cpp b/test/gtest_logging.cpp index 32da5344dd0b29becbbda22baea8dcec41311655..63927355f3a53a312c9b6ef2d305f8a6005bb2c8 100644 --- a/test/gtest_logging.cpp +++ b/test/gtest_logging.cpp @@ -33,26 +33,36 @@ TEST(logging, info) { WOLF_INFO("test info ", 5, " ", 0.123); + WOLF_INFO_COND(true, "This message should appear!"); + WOLF_INFO_COND(false, "This message should NOT appear!"); } TEST(logging, warn) { WOLF_WARN("test warn ", 5, " ", 0.123); + WOLF_WARN_COND(true, "This message should appear!"); + WOLF_WARN_COND(false, "This message should NOT appear!"); } TEST(logging, error) { WOLF_ERROR("test error ", 5, " ", 0.123); + WOLF_ERROR_COND(true, "This message should appear!"); + WOLF_ERROR_COND(false, "This message should NOT appear!"); } TEST(logging, trace) { WOLF_TRACE("test trace ", 5, " ", 0.123); + WOLF_TRACE_COND(true, "This message should appear!"); + WOLF_TRACE_COND(false, "This message should NOT appear!"); } TEST(logging, debug) { WOLF_DEBUG("test debug ", 5, " ", 0.123); + WOLF_DEBUG_COND(true, "This message should appear!"); + WOLF_DEBUG_COND(false, "This message should NOT appear!"); } int main(int argc, char **argv)