some format fixes

This commit is contained in:
Robin Müller 2022-05-09 01:28:26 +02:00
parent f518bc53db
commit e8a5f1e095
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
13 changed files with 57 additions and 33 deletions

View File

@ -34,7 +34,7 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId,
auto* hkOwner = ObjectManager::instance()->get<HasLocalDataPoolIF>(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);
}

View File

@ -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);
}
}

View File

@ -35,7 +35,7 @@ ReturnValue_t FailureIsolationBase::initialize() {
owner = ObjectManager::instance()->get<HasHealthIF>(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<ConfirmsFailuresIF>(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());

View File

@ -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);
}
}

View File

@ -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<uint32_t>(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
}

View File

@ -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;
}

View File

@ -56,7 +56,7 @@ ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue
auto* possibleTarget = ObjectManager::instance()->get<ReceivesParameterMessagesIF>(*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;

View File

@ -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;
}

View File

@ -44,7 +44,7 @@ template <typename... T>
size_t logTraced(LogLevel level, const char* file, unsigned int line, bool timed,
fmt::format_string<T...> 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 <typename... T>
size_t log(LogLevel level, bool timed, fmt::format_string<T...> 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<T...> fmt, T&&... args
}
template <typename... T>
void debug(const char* file, unsigned int line, fmt::format_string<T...> fmt,
T&&... args) noexcept {
void debug(fmt::format_string<T...> fmt, T&&... args) noexcept {
log(LogLevel::DEBUG, false, fmt, args...);
}
template <typename... T>
void debug_t(fmt::format_string<T...> fmt, T&&... args) noexcept {
log(LogLevel::DEBUG, true, fmt, args...);
}
/**
* Debug logger with source file information
*/
template <typename... T>
void debug_s(const char* file, unsigned int line, fmt::format_string<T...> 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 <typename... T>
void debug_t(const char* file, unsigned int line, fmt::format_string<T...> fmt,
T&&... args) noexcept {
void debug_st(const char* file, unsigned int line, fmt::format_string<T...> 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<T...> 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__)

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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++;

View File

@ -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);
}
}