diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp index 5d0a3068..ea0377ce 100644 --- a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp @@ -34,7 +34,7 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, auto* hkOwner = ObjectManager::instance()->get(poolOwner); if (hkOwner == nullptr) { FSFW_LOGWT( - "ctor: The supplied pool owner {:#08x} did not implement the correct interface " + "ctor: The supplied pool owner {:#010x} did not implement the correct interface " "HasLocalDataPoolIF\n", poolOwner); return; @@ -94,6 +94,6 @@ void LocalPoolObjectBase::reportReadCommitError(const char* variableType, Return errMsg = "Unknown error code"; } - FSFW_LOGW("{}: {} call | {} | Owner: {:#08x} | LPID: \n", variablePrintout, type, errMsg, + FSFW_LOGW("{}: {} call | {} | Owner: {:#010x} | LPID: \n", variablePrintout, type, errMsg, objectId, lpId); } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 437e94e8..a3c63697 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1459,10 +1459,10 @@ void DeviceHandlerBase::printWarningOrError(sif::LogLevel errorType, const char* } if (errorType == sif::LogLevel::WARNING) { - FSFW_LOGWT("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), + FSFW_LOGWT("{} | Object ID {:#010x} | {}", functionName, SystemObject::getObjectId(), errorPrint); } else if (errorType == sif::LogLevel::ERROR) { - FSFW_LOGET("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(), + FSFW_LOGET("{} | Object ID {:#010x} | {}", functionName, SystemObject::getObjectId(), errorPrint); } } diff --git a/src/fsfw/fdir/FailureIsolationBase.cpp b/src/fsfw/fdir/FailureIsolationBase.cpp index 39fbe022..5ba8c51b 100644 --- a/src/fsfw/fdir/FailureIsolationBase.cpp +++ b/src/fsfw/fdir/FailureIsolationBase.cpp @@ -35,7 +35,7 @@ ReturnValue_t FailureIsolationBase::initialize() { owner = ObjectManager::instance()->get(ownerId); if (owner == nullptr) { FSFW_LOGE( - "FailureIsolationBase::intialize: Owner object {:#08x} invalid. " + "FailureIsolationBase::intialize: Owner object {:#010x} invalid. " "Does it implement HasHealthIF?\n", ownerId); return ObjectManagerIF::CHILD_INIT_FAILED; @@ -44,8 +44,9 @@ ReturnValue_t FailureIsolationBase::initialize() { if (faultTreeParent != objects::NO_OBJECT) { auto* parentIF = ObjectManager::instance()->get(faultTreeParent); if (parentIF == nullptr) { - FSFW_LOGW("intialize: Parent object {:#08x} invalid. Does it implement ConfirmsFailuresIF?\n", - faultTreeParent); + FSFW_LOGW( + "intialize: Parent object {:#010x} invalid. Does it implement ConfirmsFailuresIF?\n", + faultTreeParent); return ObjectManagerIF::CHILD_INIT_FAILED; } eventQueue->setDefaultDestination(parentIF->getEventReceptionQueue()); diff --git a/src/fsfw/health/HealthHelper.cpp b/src/fsfw/health/HealthHelper.cpp index 97ab6205..3dec65f8 100644 --- a/src/fsfw/health/HealthHelper.cpp +++ b/src/fsfw/health/HealthHelper.cpp @@ -69,7 +69,7 @@ void HealthHelper::informParent(HasHealthIF::HealthState health, HealthMessage::setHealthMessage(&information, HealthMessage::HEALTH_INFO, health, oldHealth); if (MessageQueueSenderIF::sendMessage(parentQueue, &information, owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGWT("informParent: Object ID {:#08x} | Sending health reply failed\n", objectId); + FSFW_LOGWT("informParent: Object ID {:#010x} | Sending health reply failed\n", objectId); } } @@ -86,7 +86,7 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) { } if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply, owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGWT("handleSetHealthCommand: Object ID {:#08x} | Sending health reply failed\n", + FSFW_LOGWT("handleSetHealthCommand: Object ID {:#010x} | Sending health reply failed\n", objectId); } } diff --git a/src/fsfw/objectmanager/ObjectManager.cpp b/src/fsfw/objectmanager/ObjectManager.cpp index 9e3d8c69..df1325a7 100644 --- a/src/fsfw/objectmanager/ObjectManager.cpp +++ b/src/fsfw/objectmanager/ObjectManager.cpp @@ -38,7 +38,7 @@ ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) { #endif return ObjectManager::RETURN_OK; } else { - FSFW_LOGET("ObjectManager::insert: Object ID {:#08x} is already in use\nTerminating program\n", + FSFW_LOGET("ObjectManager::insert: Object ID {:#010x} is already in use\nTerminating program\n", static_cast(id)); // This is very severe and difficult to handle in other places. std::exit(INSERTION_FAILED); @@ -54,7 +54,7 @@ ReturnValue_t ObjectManager::remove(object_id_t id) { #endif return RETURN_OK; } else { - FSFW_LOGW("removeObject: Requested object {:#08x} not found\n", id); + FSFW_LOGW("removeObject: Requested object {:#010x} not found\n", id); return NOT_FOUND; } } @@ -78,7 +78,7 @@ void ObjectManager::initialize() { result = it.second->initialize(); if (result != RETURN_OK) { object_id_t var = it.first; - FSFW_LOGWT("initialize: Object {:#08x} failed to initialize with code {:#04x}\n", var, + FSFW_LOGWT("initialize: Object {:#010x} failed to initialize with code {:#06x}\n", var, result); errorCount++; } @@ -91,7 +91,7 @@ void ObjectManager::initialize() { for (auto const& it : objectList) { result = it.second->checkObjectConnections(); if (result != RETURN_OK) { - FSFW_LOGE("initialize: Object {:#08x} connection check failed with code {:#04x}\n", it.first, + FSFW_LOGE("initialize: Object {:#010x} connection check failed with code {:#06x}\n", it.first, result); errorCount++; } @@ -106,7 +106,7 @@ void ObjectManager::printList() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info("ObjectManager: Object List contains:\n"); for (auto const& it : objectList) { - sif::info("{:#08x} | {:#08x}\n", it.first, fmt::ptr(it.second)); + sif::info("{:#010x} | {:#010x}\n", it.first, fmt::ptr(it.second)); } #endif } diff --git a/src/fsfw/osal/host/FixedTimeslotTask.cpp b/src/fsfw/osal/host/FixedTimeslotTask.cpp index 76b00368..41a16839 100644 --- a/src/fsfw/osal/host/FixedTimeslotTask.cpp +++ b/src/fsfw/osal/host/FixedTimeslotTask.cpp @@ -116,7 +116,7 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, uint32_t slotT return HasReturnvaluesIF::RETURN_OK; } - FSFW_LOGE("addSlot: Component {:#08x} not found, not adding it to PST\n", componentId); + FSFW_LOGE("addSlot: Component {:#010x} not found, not adding it to PST\n", componentId); return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index a3eaadcd..6192723d 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -56,7 +56,7 @@ ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue auto* possibleTarget = ObjectManager::instance()->get(*objectId); if (possibleTarget == nullptr) { FSFW_LOGE( - "checkInterfaceAndAcquire: Can't retrieve message queue | Object ID {:#08x}\n" + "checkInterfaceAndAcquire: Can't retrieve message queue | Object ID {:#010x}\n" "Does it implement ReceivesParameterMessagesIF?\n", *objectId); return CommandingServiceBase::INVALID_OBJECT; diff --git a/src/fsfw/pus/Service2DeviceAccess.cpp b/src/fsfw/pus/Service2DeviceAccess.cpp index b38bf75b..5a6f8fca 100644 --- a/src/fsfw/pus/Service2DeviceAccess.cpp +++ b/src/fsfw/pus/Service2DeviceAccess.cpp @@ -132,7 +132,7 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs size_t size = 0; ReturnValue_t result = IPCStore->getData(storeAddress, &data, &size); if (result != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGW("sendWiretappingTm: Data Lost in handleUnrequestedReply with failure ID {:#04x}\n", + FSFW_LOGW("sendWiretappingTm: Data Lost in handleUnrequestedReply with failure ID {:#06x}\n", result); return; } diff --git a/src/fsfw/serviceinterface/fmtWrapper.h b/src/fsfw/serviceinterface/fmtWrapper.h index d06d7d04..f39caa5e 100644 --- a/src/fsfw/serviceinterface/fmtWrapper.h +++ b/src/fsfw/serviceinterface/fmtWrapper.h @@ -44,7 +44,7 @@ template size_t logTraced(LogLevel level, const char* file, unsigned int line, bool timed, fmt::format_string fmt, T&&... args) noexcept { if (PRINT_MUTEX == nullptr) { - fmt::print("Please call sif::initialize at program startup\n"); + fmt::print("ERRROR | {} | Please call sif::initialize at program startup\n", __FILENAME__); return 0; } try { @@ -74,7 +74,7 @@ size_t logTraced(LogLevel level, const char* file, unsigned int line, bool timed PRINT_MUTEX->unlockMutex(); return bufPos; } catch (const fmt::v8::format_error& e) { - fmt::print("Printing failed with error: {}\n", e.what()); + fmt::print("ERROR | {} | Printing failed with error: {}\n", __FILENAME__, e.what()); PRINT_MUTEX->unlockMutex(); return 0; } @@ -83,7 +83,7 @@ size_t logTraced(LogLevel level, const char* file, unsigned int line, bool timed template size_t log(LogLevel level, bool timed, fmt::format_string fmt, T&&... args) noexcept { if (PRINT_MUTEX == nullptr) { - fmt::print("Please call sif::initialize at program startup\n"); + fmt::print("ERROR | {} | Please call sif::initialize at program startup\n", __FILENAME__); return 0; } try { @@ -118,17 +118,30 @@ size_t log(LogLevel level, bool timed, fmt::format_string fmt, T&&... args } template -void debug(const char* file, unsigned int line, fmt::format_string fmt, - T&&... args) noexcept { +void debug(fmt::format_string fmt, T&&... args) noexcept { + log(LogLevel::DEBUG, false, fmt, args...); +} + +template +void debug_t(fmt::format_string fmt, T&&... args) noexcept { + log(LogLevel::DEBUG, true, fmt, args...); +} + +/** + * Debug logger with source file information + */ +template +void debug_s(const char* file, unsigned int line, fmt::format_string fmt, + T&&... args) noexcept { logTraced(LogLevel::DEBUG, file, line, false, fmt, args...); } /** - * Debug logger with timestamp and file/line number prefix + * Debug logger with source file information and timestamp */ template -void debug_t(const char* file, unsigned int line, fmt::format_string fmt, - T&&... args) noexcept { +void debug_st(const char* file, unsigned int line, fmt::format_string fmt, + T&&... args) noexcept { logTraced(LogLevel::DEBUG, file, line, true, fmt, args...); } @@ -209,17 +222,27 @@ void error_st(const char* file, unsigned int line, fmt::format_string fmt, } // namespace sif // Helper macros to simplify calling the logger functions -// The macros prefixed with F can be used to print formatted output // The macros postfixed with T are the log variant with timing information #define FSFW_LOGI(...) sif::info(__VA_ARGS__) #define FSFW_LOGIT(...) sif::info_t(__VA_ARGS__) -#define FSFW_LOGD(...) sif::debug(__FILENAME__, __LINE__, __VA_ARGS__) -#define FSFW_LOGDT(...) sif::debug_t(__FILENAME__, __LINE__, __VA_ARGS__) +#define FSFW_LOGD(...) sif::debug_s(__FILENAME__, __LINE__, __VA_ARGS__) +#define FSFW_LOGDT(...) sif::debug_st(__FILENAME__, __LINE__, __VA_ARGS__) #define FSFW_LOGW(...) sif::warning_s(__FILENAME__, __LINE__, __VA_ARGS__) #define FSFW_LOGWT(...) sif::warning_st(__FILENAME__, __LINE__, __VA_ARGS__) #define FSFW_LOGE(...) sif::error_s(__FILENAME__, __LINE__, __VA_ARGS__) #define FSFW_LOGET(...) sif::error_st(__FILENAME__, __LINE__, __VA_ARGS__) + +// Using those reduced binary size marginally.. + +//#define FSFW_LOGD(...) sif::debug(__VA_ARGS__) +//#define FSFW_LOGDT(...) sif::debug_t(__VA_ARGS__) + +//#define FSFW_LOGW(...) sif::warning(__VA_ARGS__) +//#define FSFW_LOGWT(...) sif::warning_t(__VA_ARGS__) + +//#define FSFW_LOGE(...) sif::error(__VA_ARGS__) +//#define FSFW_LOGET(...) sif::error(__VA_ARGS__) diff --git a/src/fsfw/storagemanager/LocalPool.cpp b/src/fsfw/storagemanager/LocalPool.cpp index 44e8e818..54e00e75 100644 --- a/src/fsfw/storagemanager/LocalPool.cpp +++ b/src/fsfw/storagemanager/LocalPool.cpp @@ -199,7 +199,7 @@ ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t* storeI bool ignoreFault) { ReturnValue_t status = getSubPoolIndex(size, &storeId->poolIndex); if (status != RETURN_OK) { - FSFW_LOGW("ID {:#08x} | reserveSpace: Packet too large\n", SystemObject::getObjectId()); + FSFW_LOGW("ID {:#010x} | reserveSpace: Packet too large\n", SystemObject::getObjectId()); return status; } status = findEmpty(storeId->poolIndex, &storeId->packetIndex); diff --git a/src/fsfw/tcdistribution/TcDistributor.cpp b/src/fsfw/tcdistribution/TcDistributor.cpp index b9b3a999..7a225e90 100644 --- a/src/fsfw/tcdistribution/TcDistributor.cpp +++ b/src/fsfw/tcdistribution/TcDistributor.cpp @@ -35,7 +35,7 @@ ReturnValue_t TcDistributor::handlePacket() { void TcDistributor::print() { FSFW_LOGI("{}", "Distributor content is:\nID\t| Message Queue ID"); for (const auto& queueMapIter : queueMap) { - FSFW_LOGI("{} \t| {:#08x}", queueMapIter.first, queueMapIter.second); + FSFW_LOGI("{} \t| {:#010x}", queueMapIter.first, queueMapIter.second); } } diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index 82ab4fbf..d61f330d 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -87,7 +87,7 @@ ReturnValue_t TmTcBridge::handleTm() { ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = handleTmQueue(); if (result != RETURN_OK) { - FSFW_LOGET("handleTm: Error handling TM queue with error code {:#04x}\n", result); + FSFW_LOGET("handleTm: Error handling TM queue with error code {:#06x}\n", result); status = result; } @@ -183,7 +183,7 @@ ReturnValue_t TmTcBridge::handleStoredTm() { result = sendTm(data, size); if (result != RETURN_OK) { - FSFW_LOGW("handleStoredTm: Could not send stored downlink data, code {:#04x}\n", result); + FSFW_LOGW("handleStoredTm: Could not send stored downlink data, code {:#06x}\n", result); status = result; } packetSentCounter++; diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 6b5ae826..f1c625e9 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -80,7 +80,7 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, uint8_t ackFlags step, parameter1, parameter2); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { - FSFW_LOGE("sendFailureReport: Error writing to queue. Code {:#04x}\n", status); + FSFW_LOGE("sendFailureReport: Error writing to queue. Code {:#06x}\n", status); } }