diff --git a/Svc/ActiveTextLogger/ActiveTextLogger.cpp b/Svc/ActiveTextLogger/ActiveTextLogger.cpp index de8e73f994..45e5514147 100644 --- a/Svc/ActiveTextLogger/ActiveTextLogger.cpp +++ b/Svc/ActiveTextLogger/ActiveTextLogger.cpp @@ -9,15 +9,28 @@ #include namespace Svc { +static_assert(std::numeric_limits::max() >= ACTIVE_TEXT_LOGGER_ID_FILTER_SIZE, + "ACTIVE_TEXT_LOGGER_ID_FILTER_SIZE must fit within range of FwSizeType"); // ---------------------------------------------------------------------- // Initialization/Exiting // ---------------------------------------------------------------------- -ActiveTextLogger::ActiveTextLogger(const char* name) : ActiveTextLoggerComponentBase(name), m_log_file() {} +ActiveTextLogger::ActiveTextLogger(const char* name) + : ActiveTextLoggerComponentBase(name), m_log_file(), m_numFilteredIDs(0) {} ActiveTextLogger::~ActiveTextLogger() {} +void ActiveTextLogger::configure(const FwEventIdType* filteredIds, FwSizeType count) { + FW_ASSERT(count < ACTIVE_TEXT_LOGGER_ID_FILTER_SIZE, static_cast(count), + ACTIVE_TEXT_LOGGER_ID_FILTER_SIZE); + + this->m_numFilteredIDs = count; + for (FwSizeType entry = 0; entry < count; entry++) { + this->m_filteredIDs[entry] = filteredIds[entry]; + } +} + // ---------------------------------------------------------------------- // Handlers to implement for typed input ports // ---------------------------------------------------------------------- @@ -32,6 +45,12 @@ void ActiveTextLogger::TextLogger_handler(FwIndexType portNum, if (Fw::LogSeverity::DIAGNOSTIC == severity.e) { return; } + // Check event ID filters + for (FwSizeType i = 0; i < this->m_numFilteredIDs; i++) { + if (this->m_filteredIDs[i] == id) { + return; + } + } // Format the string here, so that it is done in the task context // of the caller. Format doc borrowed from PassiveTextLogger. diff --git a/Svc/ActiveTextLogger/ActiveTextLogger.hpp b/Svc/ActiveTextLogger/ActiveTextLogger.hpp index 4b287161cd..f7c47b78f4 100644 --- a/Svc/ActiveTextLogger/ActiveTextLogger.hpp +++ b/Svc/ActiveTextLogger/ActiveTextLogger.hpp @@ -8,6 +8,7 @@ #include #include +#include namespace Svc { @@ -49,6 +50,9 @@ class ActiveTextLogger final : public ActiveTextLoggerComponentBase { //! \return true if creating the file was successful, false otherwise bool set_log_file(const char* fileName, const U32 maxSize, const U32 maxBackups = 10); + //! Configure component with event ID filters + void configure(const FwEventIdType* filteredIds, FwSizeType count); + private: // ---------------------------------------------------------------------- // Prohibit Copying @@ -100,6 +104,10 @@ class ActiveTextLogger final : public ActiveTextLoggerComponentBase { // The optional file to text logs to: LogFile m_log_file; + + // Event ID filters + FwSizeType m_numFilteredIDs; + FwEventIdType m_filteredIDs[ACTIVE_TEXT_LOGGER_ID_FILTER_SIZE]; }; } // namespace Svc diff --git a/Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImpl.hpp b/Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImpl.hpp index c87293187e..763c25313a 100644 --- a/Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImpl.hpp +++ b/Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImpl.hpp @@ -2,6 +2,7 @@ #define SVC_TEXT_LOGGER_IMPL_HPP #include +#include namespace Svc { @@ -11,6 +12,9 @@ class ConsoleTextLoggerImpl final : public PassiveTextLoggerComponentBase { ConsoleTextLoggerImpl(const char* compName); ~ConsoleTextLoggerImpl(); + //! Configure component with event ID filters + void configure(const FwEventIdType* filteredIds, FwSizeType count); + private: // downcalls for input ports void TextLogger_handler(FwIndexType portNum, @@ -18,6 +22,10 @@ class ConsoleTextLoggerImpl final : public PassiveTextLoggerComponentBase { Fw::Time& timeTag, const Fw::LogSeverity& severity, Fw::TextLogString& text); + + // Event ID filters + FwSizeType m_numFilteredIDs; + FwEventIdType m_filteredIDs[PASSIVE_TEXT_LOGGER_ID_FILTER_SIZE]; }; } // namespace Svc diff --git a/Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImplCommon.cpp b/Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImplCommon.cpp index 3640453da0..e38e7e7602 100644 --- a/Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImplCommon.cpp +++ b/Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImplCommon.cpp @@ -4,16 +4,36 @@ #include namespace Svc { +static_assert(std::numeric_limits::max() >= PASSIVE_TEXT_LOGGER_ID_FILTER_SIZE, + "PASSIVE_TEXT_LOGGER_ID_FILTER_SIZE must fit within range of FwSizeType"); -ConsoleTextLoggerImpl::ConsoleTextLoggerImpl(const char* compName) : PassiveTextLoggerComponentBase(compName) {} +ConsoleTextLoggerImpl::ConsoleTextLoggerImpl(const char* compName) + : PassiveTextLoggerComponentBase(compName), m_numFilteredIDs(0) {} ConsoleTextLoggerImpl::~ConsoleTextLoggerImpl() {} +void ConsoleTextLoggerImpl::configure(const FwEventIdType* filteredIds, FwSizeType count) { + FW_ASSERT(count < PASSIVE_TEXT_LOGGER_ID_FILTER_SIZE, static_cast(count), + PASSIVE_TEXT_LOGGER_ID_FILTER_SIZE); + + this->m_numFilteredIDs = count; + for (FwSizeType entry = 0; entry < count; entry++) { + this->m_filteredIDs[entry] = filteredIds[entry]; + } +} + void ConsoleTextLoggerImpl::TextLogger_handler(FwIndexType portNum, FwEventIdType id, Fw::Time& timeTag, const Fw::LogSeverity& severity, Fw::TextLogString& text) { + // Check event ID filters + for (FwSizeType i = 0; i < this->m_numFilteredIDs; i++) { + if (this->m_filteredIDs[i] == id) { + return; + } + } + const char* severityString = nullptr; switch (severity.e) { case Fw::LogSeverity::FATAL: diff --git a/default/config/ActiveTextLoggerCfg.hpp b/default/config/ActiveTextLoggerCfg.hpp new file mode 100644 index 0000000000..69228c881e --- /dev/null +++ b/default/config/ActiveTextLoggerCfg.hpp @@ -0,0 +1,8 @@ +#ifndef Config_ActiveTextLoggerCfg_HPP_ +#define Config_ActiveTextLoggerCfg_HPP_ + +enum { + ACTIVE_TEXT_LOGGER_ID_FILTER_SIZE = 25, //!< Size of event ID filter +}; + +#endif /* Config_ActiveTextLoggerCfg_HPP_ */ diff --git a/default/config/CMakeLists.txt b/default/config/CMakeLists.txt index 2673af2f3a..4bee4c86a7 100644 --- a/default/config/CMakeLists.txt +++ b/default/config/CMakeLists.txt @@ -15,6 +15,7 @@ register_fprime_config( HEADERS "${CMAKE_CURRENT_LIST_DIR}/EventManagerCfg.hpp" "${CMAKE_CURRENT_LIST_DIR}/ActiveRateGroupCfg.hpp" + "${CMAKE_CURRENT_LIST_DIR}/ActiveTextLoggerCfg.hpp" "${CMAKE_CURRENT_LIST_DIR}/BufferManagerComponentImplCfg.hpp" "${CMAKE_CURRENT_LIST_DIR}/CommandDispatcherImplCfg.hpp" "${CMAKE_CURRENT_LIST_DIR}/DpCatalogCfg.hpp" @@ -24,6 +25,7 @@ register_fprime_config( "${CMAKE_CURRENT_LIST_DIR}/FpConfig.hpp" "${CMAKE_CURRENT_LIST_DIR}/FPrimeNumericalConfig.h" "${CMAKE_CURRENT_LIST_DIR}/IpCfg.hpp" + "${CMAKE_CURRENT_LIST_DIR}/PassiveTextLoggerCfg.hpp" "${CMAKE_CURRENT_LIST_DIR}/PrmDbImplCfg.hpp" "${CMAKE_CURRENT_LIST_DIR}/PrmDbImplTesterCfg.hpp" "${CMAKE_CURRENT_LIST_DIR}/StaticMemoryConfig.hpp" diff --git a/default/config/PassiveTextLoggerCfg.hpp b/default/config/PassiveTextLoggerCfg.hpp new file mode 100644 index 0000000000..c0efd3ea42 --- /dev/null +++ b/default/config/PassiveTextLoggerCfg.hpp @@ -0,0 +1,8 @@ +#ifndef Config_PassiveTextLoggerCfg_HPP_ +#define Config_PassiveTextLoggerCfg_HPP_ + +enum { + PASSIVE_TEXT_LOGGER_ID_FILTER_SIZE = 25, //!< Size of event ID filter +}; + +#endif /* Config_PassiveTextLoggerCfg_HPP_ */