diff --git a/CMakeLists.txt b/CMakeLists.txt index 1be4e27..7c65b6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) include(cmake/color.cmake) -set(BLT_VERSION 5.2.9) +set(BLT_VERSION 5.2.10) set(BLT_TARGET BLT) diff --git a/include/blt/logging/logging.h b/include/blt/logging/logging.h index b1b75d5..f91d666 100644 --- a/include/blt/logging/logging.h +++ b/include/blt/logging/logging.h @@ -160,7 +160,7 @@ namespace blt::logging size_t m_arg_pos = 0; }; - void print(const std::string& str); + void print(std::string str); void newline(); @@ -212,12 +212,13 @@ namespace blt::logging user_str.pop_back(); if (level == log_level_t::NONE) { - println(user_str); + print(user_str); + newline(); return; } auto log_fmt_str = config.generate(user_str, get_thread_name(), level, file, line); if (log_fmt_str) - print(*log_fmt_str); + print(std::move(*log_fmt_str)); } namespace detail diff --git a/include/blt/logging/logging_config.h b/include/blt/logging/logging_config.h index 199a7e6..b9b09f8 100644 --- a/include/blt/logging/logging_config.h +++ b/include/blt/logging/logging_config.h @@ -206,6 +206,11 @@ namespace blt::logging std::optional generate(const std::string& user_str, const std::string& thread_name, log_level_t level, const char* file, i32 line) const; + [[nodiscard]] const std::vector>& get_injectors() const + { + return m_injectors; + } + private: std::vector> m_injectors; // wrappers for streams exist in blt/fs/stream_wrappers.h diff --git a/libraries/parallel-hashmap b/libraries/parallel-hashmap index 93201da..7ef2e73 160000 --- a/libraries/parallel-hashmap +++ b/libraries/parallel-hashmap @@ -1 +1 @@ -Subproject commit 93201da2ba5a6aba0a6e57ada64973555629b3e3 +Subproject commit 7ef2e733416953b222851f9a360d7fc72d068ee5 diff --git a/src/blt/logging/logging.cpp b/src/blt/logging/logging.cpp index 7ff8311..a668d0f 100644 --- a/src/blt/logging/logging.cpp +++ b/src/blt/logging/logging.cpp @@ -216,9 +216,24 @@ namespace blt::logging return get_thread_context().logger; } - void print(const std::string& str) + void print(std::string str) { - std::cout << str; + const auto& config = get_global_config(); + bool should_print = true; + if (!config.get_injectors().empty()) + { + for (const auto& injector : config.get_injectors()) + { + auto [new_logging_output, should_continue, should_log] = injector->inject(str); + if (!should_continue) + break; + if (!should_log) + should_print = false; + str = std::move(new_logging_output); + } + } + if (should_print) + std::cout << str; } void newline()