Skip to content

Commit 55ac4d2

Browse files
committed
refactor: forward logging compatibility to vix log
1 parent 3a09211 commit 55ac4d2

9 files changed

Lines changed: 228 additions & 2179 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 58 additions & 545 deletions
Large diffs are not rendered by default.

‎cmake/vix_utilsConfig.cmake.in‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@
22

33
include(CMakeFindDependencyMacro)
44

5-
if (@VIX_UTILS_PACKAGE_WITH_THREADS@)
6-
find_dependency(Threads REQUIRED)
7-
endif()
8-
9-
if (NOT @VIX_UTILS_LOGGING_DEPS_BUNDLED@)
10-
find_dependency(spdlog CONFIG REQUIRED)
11-
find_dependency(fmt CONFIG REQUIRED)
12-
endif()
5+
find_dependency(vix_log CONFIG REQUIRED)
6+
find_dependency(vix_env CONFIG REQUIRED)
137

148
include("${CMAKE_CURRENT_LIST_DIR}/vix_utilsTargets.cmake")
159

‎include/vix/utils/ConsoleMutex.hpp‎

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
#ifndef VIX_CONSOLE_MUTEX_HPP
1717
#define VIX_CONSOLE_MUTEX_HPP
1818

19-
#include <mutex>
20-
#include <condition_variable>
19+
#include <vix/log/ConsoleSync.hpp>
2120

2221
namespace vix::utils
2322
{
@@ -29,11 +28,7 @@ namespace vix::utils
2928
*
3029
* @return Reference to the global console mutex.
3130
*/
32-
inline std::mutex &console_mutex()
33-
{
34-
static std::mutex m;
35-
return m;
36-
}
31+
inline std::mutex &console_mutex() { return vix::log::console_mutex(); }
3732

3833
/**
3934
* @brief Mutex protecting banner-related state.
@@ -43,11 +38,7 @@ namespace vix::utils
4338
*
4439
* @return Reference to the banner mutex.
4540
*/
46-
inline std::mutex &banner_mutex()
47-
{
48-
static std::mutex m;
49-
return m;
50-
}
41+
inline std::mutex &banner_mutex() { return vix::log::banner_mutex(); }
5142

5243
/**
5344
* @brief Condition variable used for banner synchronization.
@@ -57,11 +48,7 @@ namespace vix::utils
5748
*
5849
* @return Reference to the banner condition variable.
5950
*/
60-
inline std::condition_variable &console_cv()
61-
{
62-
static std::condition_variable cv;
63-
return cv;
64-
}
51+
inline std::condition_variable &console_cv() { return vix::log::console_cv(); }
6552

6653
/**
6754
* @brief Flag indicating whether the console banner is done.
@@ -70,38 +57,22 @@ namespace vix::utils
7057
*
7158
* @return Reference to the banner completion flag.
7259
*/
73-
inline bool &console_banner_done()
74-
{
75-
static bool done = true;
76-
return done;
77-
}
60+
inline bool &console_banner_done() { return vix::log::console_banner_done(); }
7861

7962
/**
8063
* @brief Block until the console banner has completed.
8164
*
8265
* This function waits on the banner condition variable
8366
* until console_banner_done() becomes true.
8467
*/
85-
inline void console_wait_banner()
86-
{
87-
std::unique_lock<std::mutex> lk(banner_mutex());
88-
console_cv().wait(lk, []
89-
{ return console_banner_done(); });
90-
}
68+
inline void console_wait_banner() { vix::log::console_wait_banner(); }
9169

9270
/**
9371
* @brief Mark the console banner as completed.
9472
*
9573
* Wakes all threads waiting in console_wait_banner().
9674
*/
97-
inline void console_mark_banner_done()
98-
{
99-
{
100-
std::lock_guard<std::mutex> lk(banner_mutex());
101-
console_banner_done() = true;
102-
}
103-
console_cv().notify_all();
104-
}
75+
inline void console_mark_banner_done() { vix::log::console_mark_banner_done(); }
10576

10677
/**
10778
* @brief Reset the banner completion state.
@@ -110,11 +81,7 @@ namespace vix::utils
11081
* console_wait_banner() will block until the banner
11182
* is marked done again.
11283
*/
113-
inline void console_reset_banner()
114-
{
115-
std::lock_guard<std::mutex> lk(banner_mutex());
116-
console_banner_done() = false;
117-
}
84+
inline void console_reset_banner() { vix::log::console_reset_banner(); }
11885

11986
} // namespace vix::utils
12087

0 commit comments

Comments
 (0)