From af740b139bfa977fb6baf2226300a3ce10de1a68 Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Sat, 13 Sep 2025 10:07:32 +0300 Subject: [PATCH 1/4] refactor(core): move TaskExecutor to detail Move TaskExecutor implementation into logit/detail namespace and update logger headers to include the internal executor while removing it from the public umbrella header. --- include/logit_cpp/LogIt.hpp | 1 - include/logit_cpp/logit/Logger.hpp | 3 ++- include/logit_cpp/logit/{ => detail}/TaskExecutor.hpp | 10 +++++----- include/logit_cpp/logit/loggers/ConsoleLogger.hpp | 5 +++-- include/logit_cpp/logit/loggers/FileLogger.hpp | 5 +++-- include/logit_cpp/logit/loggers/UniqueFileLogger.hpp | 5 +++-- 6 files changed, 16 insertions(+), 13 deletions(-) rename include/logit_cpp/logit/{ => detail}/TaskExecutor.hpp (95%) diff --git a/include/logit_cpp/LogIt.hpp b/include/logit_cpp/LogIt.hpp index 1834b74..ee32239 100644 --- a/include/logit_cpp/LogIt.hpp +++ b/include/logit_cpp/LogIt.hpp @@ -8,7 +8,6 @@ #include "LogItConfig.hpp" #include "logit/enums.hpp" #include "logit/utils.hpp" -#include "logit/TaskExecutor.hpp" #include "logit/Logger.hpp" #include "logit/LogStream.hpp" #include "logit/LogMacros.hpp" diff --git a/include/logit_cpp/logit/Logger.hpp b/include/logit_cpp/logit/Logger.hpp index 27818cd..b6dc415 100644 --- a/include/logit_cpp/logit/Logger.hpp +++ b/include/logit_cpp/logit/Logger.hpp @@ -7,6 +7,7 @@ #include "loggers/ILogger.hpp" #include "formatter.hpp" +#include "logit/detail/TaskExecutor.hpp" #include #include #include @@ -239,7 +240,7 @@ namespace logit { if (m_shutdown) return; m_shutdown = true; wait(); - TaskExecutor::get_instance().shutdown(); + detail::TaskExecutor::get_instance().shutdown(); } private: diff --git a/include/logit_cpp/logit/TaskExecutor.hpp b/include/logit_cpp/logit/detail/TaskExecutor.hpp similarity index 95% rename from include/logit_cpp/logit/TaskExecutor.hpp rename to include/logit_cpp/logit/detail/TaskExecutor.hpp index 311b5b1..678288d 100644 --- a/include/logit_cpp/logit/TaskExecutor.hpp +++ b/include/logit_cpp/logit/detail/TaskExecutor.hpp @@ -1,6 +1,6 @@ #pragma once -#ifndef _LOGIT_TASK_EXECUTOR_HPP_INCLUDED -#define _LOGIT_TASK_EXECUTOR_HPP_INCLUDED +#ifndef _LOGIT_DETAIL_TASK_EXECUTOR_HPP_INCLUDED +#define _LOGIT_DETAIL_TASK_EXECUTOR_HPP_INCLUDED /// \file TaskExecutor.hpp /// \brief Defines the TaskExecutor class, which manages task execution in a separate thread. @@ -13,7 +13,7 @@ #include #include -namespace logit { +namespace logit { namespace detail { #if defined(__EMSCRIPTEN__) @@ -136,6 +136,6 @@ namespace logit { #endif // defined(__EMSCRIPTEN__) -}; // namespace logit +}} // namespace logit::detail -#endif // _LOGIT_TASK_EXECUTOR_HPP_INCLUDED +#endif // _LOGIT_DETAIL_TASK_EXECUTOR_HPP_INCLUDED diff --git a/include/logit_cpp/logit/loggers/ConsoleLogger.hpp b/include/logit_cpp/logit/loggers/ConsoleLogger.hpp index 4df484c..c77ee58 100644 --- a/include/logit_cpp/logit/loggers/ConsoleLogger.hpp +++ b/include/logit_cpp/logit/loggers/ConsoleLogger.hpp @@ -6,6 +6,7 @@ /// \brief Console logger implementation that outputs logs to the console with color support. #include "ILogger.hpp" +#include "logit/detail/TaskExecutor.hpp" #include #if defined(_WIN32) #include @@ -105,7 +106,7 @@ namespace logit { return; } lock.unlock(); - TaskExecutor::get_instance().add_task([this, message](){ + detail::TaskExecutor::get_instance().add_task([this, message](){ std::lock_guard lock(m_mutex); # if defined(_WIN32) // For Windows, parse the message for ANSI color codes and apply them @@ -181,7 +182,7 @@ namespace logit { std::unique_lock lock(m_mutex); if (!m_config.async) return; lock.unlock(); - TaskExecutor::get_instance().wait(); + detail::TaskExecutor::get_instance().wait(); #endif } diff --git a/include/logit_cpp/logit/loggers/FileLogger.hpp b/include/logit_cpp/logit/loggers/FileLogger.hpp index 0706c74..561ccff 100644 --- a/include/logit_cpp/logit/loggers/FileLogger.hpp +++ b/include/logit_cpp/logit/loggers/FileLogger.hpp @@ -6,6 +6,7 @@ /// \brief File logger implementation that outputs logs to files with rotation and deletion of old logs. #include "ILogger.hpp" +#include "logit/detail/TaskExecutor.hpp" #include #include #include @@ -117,7 +118,7 @@ namespace logit { return; } auto timestamp_ms = record.timestamp_ms; - TaskExecutor::get_instance().add_task([this, message, timestamp_ms]() { + detail::TaskExecutor::get_instance().add_task([this, message, timestamp_ms]() { std::lock_guard lock(m_mutex); try { write_log(message, timestamp_ms); @@ -181,7 +182,7 @@ namespace logit { /// \brief Waits for all asynchronous tasks to complete. void wait() override { if (!m_config.async) return; - TaskExecutor::get_instance().wait(); + detail::TaskExecutor::get_instance().wait(); } private: diff --git a/include/logit_cpp/logit/loggers/UniqueFileLogger.hpp b/include/logit_cpp/logit/loggers/UniqueFileLogger.hpp index 08beb48..c423843 100644 --- a/include/logit_cpp/logit/loggers/UniqueFileLogger.hpp +++ b/include/logit_cpp/logit/loggers/UniqueFileLogger.hpp @@ -6,6 +6,7 @@ /// \brief Logger that writes each log message to a unique file with auto-deletion of old logs. #include "ILogger.hpp" +#include "logit/detail/TaskExecutor.hpp" #include #include #include @@ -163,7 +164,7 @@ namespace logit { info_lock.unlock(); auto timestamp_ms = record.timestamp_ms; - TaskExecutor::get_instance().add_task([this, message, timestamp_ms, thread_id]() { + detail::TaskExecutor::get_instance().add_task([this, message, timestamp_ms, thread_id]() { std::lock_guard lock(m_mutex); std::string file_path; try { @@ -253,7 +254,7 @@ namespace logit { /// \brief Waits for all asynchronous tasks to complete. void wait() override { if (!m_config.async) return; - TaskExecutor::get_instance().wait(); + detail::TaskExecutor::get_instance().wait(); } private: From f7cef8c6a8f7c35a6fc0cded22e7d75dfa31a44d Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Sat, 13 Sep 2025 10:08:22 +0300 Subject: [PATCH 2/4] refactor: update Logger.hpp --- include/logit_cpp/logit/Logger.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/logit_cpp/logit/Logger.hpp b/include/logit_cpp/logit/Logger.hpp index b6dc415..a097f0d 100644 --- a/include/logit_cpp/logit/Logger.hpp +++ b/include/logit_cpp/logit/Logger.hpp @@ -7,7 +7,7 @@ #include "loggers/ILogger.hpp" #include "formatter.hpp" -#include "logit/detail/TaskExecutor.hpp" +#include "detail/TaskExecutor.hpp" #include #include #include From 7273c25b965a3e12e200465288bd58e84a420d34 Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Sat, 13 Sep 2025 10:09:34 +0300 Subject: [PATCH 3/4] refactor: update TaskExecutor.hpp --- include/logit_cpp/logit/detail/TaskExecutor.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/logit_cpp/logit/detail/TaskExecutor.hpp b/include/logit_cpp/logit/detail/TaskExecutor.hpp index 678288d..3455c33 100644 --- a/include/logit_cpp/logit/detail/TaskExecutor.hpp +++ b/include/logit_cpp/logit/detail/TaskExecutor.hpp @@ -13,7 +13,7 @@ #include #include -namespace logit { namespace detail { +namespace logit::detail { #if defined(__EMSCRIPTEN__) @@ -136,6 +136,6 @@ namespace logit { namespace detail { #endif // defined(__EMSCRIPTEN__) -}} // namespace logit::detail +} // namespace logit::detail #endif // _LOGIT_DETAIL_TASK_EXECUTOR_HPP_INCLUDED From e532381d794508f2ee16c902e9a1ae89c139eb9d Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Sat, 13 Sep 2025 10:16:11 +0300 Subject: [PATCH 4/4] refactor: update TaskExecutor.hpp --- include/logit_cpp/logit/detail/TaskExecutor.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/logit_cpp/logit/detail/TaskExecutor.hpp b/include/logit_cpp/logit/detail/TaskExecutor.hpp index 3455c33..678288d 100644 --- a/include/logit_cpp/logit/detail/TaskExecutor.hpp +++ b/include/logit_cpp/logit/detail/TaskExecutor.hpp @@ -13,7 +13,7 @@ #include #include -namespace logit::detail { +namespace logit { namespace detail { #if defined(__EMSCRIPTEN__) @@ -136,6 +136,6 @@ namespace logit::detail { #endif // defined(__EMSCRIPTEN__) -} // namespace logit::detail +}} // namespace logit::detail #endif // _LOGIT_DETAIL_TASK_EXECUTOR_HPP_INCLUDED