diff --git a/apps/Main.cpp b/apps/Main.cpp index 0ab7d43739b7c3e07591ede377cd2e4eb73461a4..b2df11bdca19aa97430dbbe07699fd0428d010b1 100644 --- a/apps/Main.cpp +++ b/apps/Main.cpp @@ -5,7 +5,7 @@ #include "BinaryPrivateSemaphore.hpp" // for BPS #include "CountingPrivateSemaphore.hpp" // for CPS -#include "Debug.hpp" // for WDBG +#include "Debug.hpp" // for DBG #include "Fiber.hpp" // for Fiber #include "PrivateSemaphore.hpp" // for PS #include "Runtime.hpp" // for Runtime @@ -46,13 +46,13 @@ static void fib(void* voidParams) { runtime->schedule(*f1); runtime->schedule(*f2); - WDBG("fib: Calling wait for n=" << n); + DBG("fib: Calling wait for n=" << n); newSem.wait(); *result = a + b; } - WDBG("fib: Calling signalAndExit for n=" << n); + DBG("fib: Calling signalAndExit for n=" << n); sem->signalAndExit(); } diff --git a/emper/Debug.cpp b/emper/Debug.cpp index c8cfd09b886694c185977da978be62999127aa97..08f13c59a10d272e48c77723054584ef8c4a3d92 100644 --- a/emper/Debug.cpp +++ b/emper/Debug.cpp @@ -52,7 +52,7 @@ void emper_log(const std::string& prefix, const std::string& message) { logMessage << " "; } - logMessage << message; + logMessage << message << std::endl; std::unique_lock<std::mutex> lock(emper_log_mutex); std::cerr << logMessage.str(); diff --git a/emper/Debug.hpp b/emper/Debug.hpp index 768a07e0c1fcc95f5ded73d6bb408c3de115b983..06cdd502354272808581173c21379edeb8646d36 100644 --- a/emper/Debug.hpp +++ b/emper/Debug.hpp @@ -18,38 +18,36 @@ // The lamda should be fairly cheap/free because it will be inlined. // The use of a lambda here is the ISO C++ equivalent to GCC statement expressions. // NOLINTNEXTLINE(bugprone-macro-parentheses) -#define LOG_STR_LAMBDA(x, new_line) [&]() -> std::string {std::stringstream sst; sst << x; if constexpr (new_line) { sst << std::endl; }; return sst.str(); } +#define EMPER_BUILD_STR(x) [&]() -> std::string {std::stringstream sst; sst << x; return sst.str(); } // NOLINTNEXTLINE(bugprone-macro-parentheses) -#define LOG(level, x, log_func, new_line) do {if constexpr (level > EMPER_LOG_LEVEL) { break; } log_func(LOG_STR_LAMBDA(x, new_line)()); } while (false) +#define LOG(level, x, log_func) do {if constexpr (level > EMPER_LOG_LEVEL) { break; } log_func(EMPER_BUILD_STR(x)()); } while (false) // NOLINTNEXTLINE(bugprone-macro-parentheses) -#define DBG(x) LOG(Debug, x, emper_log_no_prefix, true); -// NOLINTNEXTLINE(bugprone-macro-parentheses) -#define WDBG(x) LOG(Debug, x, emper_log_no_prefix, false); +#define DBG(x) LOG(Debug, x, emper_log_no_prefix); // To avoid "error: there are no arguments to ‘logD’ that depend on a // template parameter, so a declaration of ‘logD’ must be available" // we use "this->logD()" instead of simply "logD()" below. // NOLINTNEXTLINE(bugprone-macro-parentheses) -#define LOGD(x) LOG(Debug, x, this->logD, true); +#define LOGD(x) LOG(Debug, x, this->logD); // NOLINTNEXTLINE(bugprone-macro-parentheses) -#define LOGDD(x) LOG(FineDebug, x, this->logDD, true); +#define LOGDD(x) LOG(FineDebug, x, this->logDD); // NOLINTNEXTLINE(bugprone-macro-parentheses) -#define LOGI(x) LOG(Info, "Info: " << x, emper_log_no_prefix, true); +#define LOGI(x) LOG(Info, "Info: " << x, emper_log_no_prefix); // NOLINTNEXTLINE(bugprone-macro-parentheses) -#define LOGGER_LOGI(x) LOG(Info, "Info: " << x, this->logI, true); +#define LOGGER_LOGI(x) LOG(Info, "Info: " << x, this->logI); // NOLINTNEXTLINE(bugprone-macro-parentheses) -#define LOGW(x) LOG(Warning, "Warning: " << x, emper_log_no_prefix, true); +#define LOGW(x) LOG(Warning, "Warning: " << x, emper_log_no_prefix); // NOLINTNEXTLINE(bugprone-macro-parentheses) -#define LOGGER_LOGW(x) LOG(Warning, "Warning: " << x, this->logW, true); +#define LOGGER_LOGW(x) LOG(Warning, "Warning: " << x, this->logW); // NOLINTNEXTLINE(bugprone-macro-parentheses) -#define LOGE(x) LOG(Error, "Error: " << x, emper_log_no_prefix, true); +#define LOGE(x) LOG(Error, "Error: " << x, emper_log_no_prefix); // NOLINTNEXTLINE(bugprone-macro-parentheses) -#define LOGGER_LOGE(x) LOG(Error, "Error: " << x, emper_log_no_prefix, true); +#define LOGGER_LOGE(x) LOG(Error, "Error: " << x, emper_log_no_prefix); // NOLINTNEXTLINE(bugprone-macro-parentheses) #define ABORT(x) { LOGE(x); abort(); } diff --git a/tests/RuntimeDestroyTest.cpp b/tests/RuntimeDestroyTest.cpp index 6b1d6308e378d8df6fa21769fa75a4cac4e209a0..1617b6e9896856bd431008bab35533929cb25762 100644 --- a/tests/RuntimeDestroyTest.cpp +++ b/tests/RuntimeDestroyTest.cpp @@ -5,7 +5,7 @@ #include "BinaryPrivateSemaphore.hpp" // for BPS #include "CountingPrivateSemaphore.hpp" // for CPS -#include "Debug.hpp" // for WDBG +#include "Debug.hpp" // for DBG #include "Fiber.hpp" // for Fiber #include "PrivateSemaphore.hpp" // for PS #include "Runtime.hpp" // for Runtime @@ -53,13 +53,13 @@ static void fib(void* voidParams) { runtime->schedule(*f1); runtime->schedule(*f2); - WDBG("fib: Calling wait for n=" << n); + DBG("fib: Calling wait for n=" << n); newSem.wait(); *result = a + b; } - WDBG("fib: Calling signalAndExit for n=" << n); + DBG("fib: Calling signalAndExit for n=" << n); sem->signalAndExit(); } diff --git a/tests/SimpleActorTest.cpp b/tests/SimpleActorTest.cpp index e02da94c78f390196218a41fa724d65704a4a492..c5b284ad67f4858146e1e317b393cef0f3961f99 100644 --- a/tests/SimpleActorTest.cpp +++ b/tests/SimpleActorTest.cpp @@ -7,7 +7,7 @@ #include "Actor.hpp" // for Actor #include "CountingPrivateSemaphore.hpp" // for CPS -#include "Debug.hpp" // for WDBG +#include "Debug.hpp" // for DBG #include "Dispatcher.hpp" // for Dispatcher #include "Fiber.hpp" // for Fiber #include "Runtime.hpp" // for Runtime @@ -47,8 +47,8 @@ static void mainFiber(void* runtime_ptr) { for (unsigned int fiberNum = 0; fiberNum < FIBER_COUNT; ++fiberNum) { spawn( [&sumActor, fiberNum] { - WDBG(Dispatcher::getCurrentFiber() - << " (" << fiberNum << ") starts to count to " << FIBERS_COUNT_TO); + DBG(Dispatcher::getCurrentFiber() + << " (" << fiberNum << ") starts to count to " << FIBERS_COUNT_TO); for (uint64_t i = 1; i <= FIBERS_COUNT_TO; ++i) { sumActor.tell(i); } diff --git a/tests/SimplestFibTest.cpp b/tests/SimplestFibTest.cpp index bd0700a3700f7e62c80749b75df31530b3958009..b0ef2db70b25f53d8e049d2913a92db5a6a7a1de 100644 --- a/tests/SimplestFibTest.cpp +++ b/tests/SimplestFibTest.cpp @@ -5,7 +5,7 @@ #include "BinaryPrivateSemaphore.hpp" // for BPS #include "CountingPrivateSemaphore.hpp" // for CPS -#include "Debug.hpp" // for WDBG +#include "Debug.hpp" // for DBG #include "Fiber.hpp" // for Fiber #include "PrivateSemaphore.hpp" // for PS #include "Runtime.hpp" // for Runtime @@ -52,13 +52,13 @@ static void fib(void* voidParams) { runtime->schedule(*f1); runtime->schedule(*f2); - WDBG("fib: Calling wait for n=" << n); + DBG("fib: Calling wait for n=" << n); newSem.wait(); *result = a + b; } - WDBG("fib: Calling signalAndExit for n=" << n); + DBG("fib: Calling signalAndExit for n=" << n); sem->signalAndExit(); }