From f84097543e59a3564eae4ac19b7118102728c8a9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 2 Mar 2023 15:20:59 +0100 Subject: [PATCH] allow passing context to mutex guard --- src/fsfw/ipc/MutexGuard.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/fsfw/ipc/MutexGuard.h b/src/fsfw/ipc/MutexGuard.h index f6d2f25f..b82b2d7f 100644 --- a/src/fsfw/ipc/MutexGuard.h +++ b/src/fsfw/ipc/MutexGuard.h @@ -7,14 +7,17 @@ class MutexGuard { public: MutexGuard(MutexIF* mutex, MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::BLOCKING, - uint32_t timeoutMs = 0) + uint32_t timeoutMs = 0, const char* context = nullptr) : internalMutex(mutex) { + if (context == nullptr) { + context = "unknown"; + } if (mutex == nullptr) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "MutexGuard: Passed mutex is invalid!" << std::endl; + sif::error << "MutexGuard::" << context << ": Passed mutex is invalid!" << std::endl; #else - sif::printError("MutexGuard: Passed mutex is invalid!\n"); + sif::printError("MutexGuard::%s: Passed mutex is invalid!\n", context); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_VERBOSE_LEVEL >= 1 */ return;