added way to completely disable printouts

This commit is contained in:
Robin Müller 2021-01-06 19:49:58 +01:00
parent db7d28f852
commit 91cf5f1764
5 changed files with 38 additions and 19 deletions

View File

@ -38,7 +38,7 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
"mode for read call." << std::endl; "mode for read call." << std::endl;
#else #else
fsfw::printWarning("LocalPoolVariable: Invalid read write " fsfw::printWarning("LocalPoolVariable: Invalid read write "
"mode for read call."); "mode for read call.\n\r");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return PoolVariableIF::INVALID_READ_WRITE_MODE; return PoolVariableIF::INVALID_READ_WRITE_MODE;
} }
@ -53,8 +53,8 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
<< std::dec << " failed." << std::setfill(' ') << std::endl; << std::dec << " failed." << std::setfill(' ') << std::endl;
#else #else
fsfw::printError("LocalPoolVariable: Read of local pool variable of " fsfw::printError("LocalPoolVariable: Read of local pool variable of "
"object 0x%08x and lp ID 0x08x failed.", hkManager->getOwner(), "object 0x%08x and lp ID 0x%08x failed.\n\r",
localPoolId); hkManager->getOwner(), localPoolId);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return result; return result;
} }
@ -75,7 +75,10 @@ inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
if(readWriteMode == pool_rwm_t::VAR_READ) { if(readWriteMode == pool_rwm_t::VAR_READ) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolVariable: Invalid read write " sif::warning << "LocalPoolVariable: Invalid read write "
"mode for commit() call." << std::endl; "mode for commit call." << std::endl;
#else
fsfw::printWarning("LocalPoolVariable: Invalid read write "
"mode for commit call.\n\r");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return PoolVariableIF::INVALID_READ_WRITE_MODE; return PoolVariableIF::INVALID_READ_WRITE_MODE;
} }
@ -89,8 +92,8 @@ inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
<< std::dec << " failed." << std::endl; << std::dec << " failed." << std::endl;
#else #else
fsfw::printError("LocalPoolVariable: Read of local pool variable of " fsfw::printError("LocalPoolVariable: Read of local pool variable of "
"object 0x%08x and lp ID 0x08x failed.", hkManager->getOwner(), "object 0x%08x and lp ID 0x%08x failed.\n\r",
localPoolId); hkManager->getOwner(), localPoolId);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return result; return result;
} }

View File

@ -6,12 +6,14 @@
#include <cstdarg> #include <cstdarg>
#include <cstdint> #include <cstdint>
fsfw::PrintLevel printLevel = fsfw::PrintLevel::DEBUG; fsfw::PrintLevel printLevel = fsfw::PrintLevel::DEBUG;
uint8_t printBuffer[fsfwconfig::FSFW_PRINT_BUFFER_SIZE];
#if defined(WIN32) && FSFW_COLORED_OUTPUT == 1 #if defined(WIN32) && FSFW_COLORED_OUTPUT == 1
bool consoleInitialized = false; bool consoleInitialized = false;
#endif #endif /* defined(WIN32) && FSFW_COLORED_OUTPUT == 1 */
#if FSFW_DISABLE_PRINTOUT == 0
uint8_t printBuffer[fsfwconfig::FSFW_PRINT_BUFFER_SIZE];
void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) { void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) {
@ -81,13 +83,6 @@ void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) {
printf("%s", printBuffer); printf("%s", printBuffer);
} }
void fsfw::setPrintLevel(PrintLevel printLevel_) {
printLevel = printLevel_;
}
fsfw::PrintLevel fsfw::getPrintLevel() {
return printLevel;
}
void fsfw::printInfo(const char *fmt, ...) { void fsfw::printInfo(const char *fmt, ...) {
va_list args; va_list args;
@ -116,3 +111,20 @@ void fsfw::printError(const char *fmt, ...) {
fsfwPrint(fsfw::PrintLevel::ERROR_TYPE, fmt, args); fsfwPrint(fsfw::PrintLevel::ERROR_TYPE, fmt, args);
va_end(args); va_end(args);
} }
#else
void fsfw::printInfo(const char *fmt, ...) {}
void fsfw::printWarning(const char *fmt, ...) {}
void fsfw::printDebug(const char *fmt, ...) {}
void fsfw::printError(const char *fmt, ...) {}
#endif /* FSFW_DISABLE_PRINTOUT == 0 */
void fsfw::setPrintLevel(PrintLevel printLevel_) {
printLevel = printLevel_;
}
fsfw::PrintLevel fsfw::getPrintLevel() {
return printLevel;
}

View File

@ -1,4 +1,6 @@
#if FSFW_DISABLE_PRINTOUT == 0
#include <stdio.h> #include <stdio.h>
#endif
namespace fsfw { namespace fsfw {

View File

@ -3,7 +3,9 @@
ReturnValue_t unitt::put_error(std::string errorId) { ReturnValue_t unitt::put_error(std::string errorId) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Unit Tester error: Failed at test ID " sif::error << "Unit Tester error: Failed at test ID "
<< errorId << "\n" << std::flush; << errorId << std::endl;
#endif #else
fsfw::printError("Unit Tester error: Failed at test ID 0x%08x", errorId);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }

View File

@ -2,7 +2,7 @@
#define UNITTEST_INTERNAL_UNITTDEFINITIONS_H_ #define UNITTEST_INTERNAL_UNITTDEFINITIONS_H_
#include "../../returnvalues/HasReturnvaluesIF.h" #include "../../returnvalues/HasReturnvaluesIF.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterface.h"
#include <cstdint> #include <cstdint>
#include <cstddef> #include <cstddef>
#include <string> #include <string>