From 393ba1b5d1f3946b4e9650926274c2700b024e15 Mon Sep 17 00:00:00 2001
From: Mateus Sanches Moura <msanches@iri.upc.edu>
Date: Tue, 11 Jun 2024 19:53:18 +0200
Subject: [PATCH] Maintain compatibility with v0.x

---
 include/core/utils/logging.h | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/include/core/utils/logging.h b/include/core/utils/logging.h
index 2028d6b41..965b218ed 100644
--- a/include/core/utils/logging.h
+++ b/include/core/utils/logging.h
@@ -34,10 +34,14 @@
 
 // spdlog include
 #include "spdlog/spdlog.h"
+#if SPDLOG_VER_MAJOR >= 1
 #include "spdlog/async.h"
 // enable the use of ostream operator<<
 #include "spdlog/fmt/ostr.h"
 #include "spdlog/sinks/stdout_color_sinks.h"
+#else
+#include "spdlog/fmt/bundled/ostream.h"
+#endif
 
 // Wolf includes
 #include "core/utils/singleton.h"
@@ -127,7 +131,11 @@ inline Logger::Logger(const std::string& name) :
 
   // Enable asynchronous logging
   // Queue size must be a power of 2
+#if SPDLOG_VER_MAJOR >= 1
   spdlog::init_thread_pool(4096, 1);
+#else
+  spdlog::set_async_mode(4096);
+#endif
 
   if (log_name_ == __INTERNAL_WOLF_MAIN_LOGGER_NAME_)
     // Logging pattern is :
@@ -156,7 +164,11 @@ inline Logger::Logger(std::string&& name) :
 
   // Enable asynchronous logging
   // Queue size must be a power of 2
+#if SPDLOG_VER_MAJOR >= 1
   spdlog::init_thread_pool(4096, 1);
+#else
+  spdlog::set_async_mode(4096);
+#endif
 
   if (log_name_ == __INTERNAL_WOLF_MAIN_LOGGER_NAME_)
     // Logging pattern is :
@@ -211,8 +223,11 @@ 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 SPDLOG_VER_MAJOR >= 1
   if (p2) spdlog::init_thread_pool(q_size, 1);
+#else
+  if (p2) spdlog::set_async_mode(q_size);
+#endif
 
   return q_size;
 }
-- 
GitLab