mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 00:44:37 -06:00
Add event ID filters to text logger components (#4028)
* Add event ID filter to PassiveConsoleTextLogger * Add event ID filter to ActiveTextLogger * Add const qualifier to filtered event list pointers * Fix assert argument types * Fix clang format errors * Fix copy-paste error on include file Co-authored-by: Thomas Boyer-Chammard <49786685+thomas-bc@users.noreply.github.com> * Add missing initialization to ActiveTextLogger constructor --------- Co-authored-by: Ian Brault <ian.r.brault@jpl.nasa.gov> Co-authored-by: Thomas Boyer-Chammard <49786685+thomas-bc@users.noreply.github.com> Co-authored-by: M Starch <LeStarch@googlemail.com>
This commit is contained in:
parent
373f81d0f3
commit
d911fb903f
@ -9,15 +9,28 @@
|
||||
#include <ctime>
|
||||
|
||||
namespace Svc {
|
||||
static_assert(std::numeric_limits<FwSizeType>::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<FwAssertArgType>(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.
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
#include <Svc/ActiveTextLogger/ActiveTextLoggerComponentAc.hpp>
|
||||
#include <Svc/ActiveTextLogger/LogFile.hpp>
|
||||
#include <config/ActiveTextLoggerCfg.hpp>
|
||||
|
||||
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
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define SVC_TEXT_LOGGER_IMPL_HPP
|
||||
|
||||
#include <Svc/PassiveConsoleTextLogger/PassiveTextLoggerComponentAc.hpp>
|
||||
#include <config/PassiveTextLoggerCfg.hpp>
|
||||
|
||||
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
|
||||
|
||||
@ -4,16 +4,36 @@
|
||||
#include <Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImpl.hpp>
|
||||
|
||||
namespace Svc {
|
||||
static_assert(std::numeric_limits<FwSizeType>::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<FwAssertArgType>(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:
|
||||
|
||||
8
default/config/ActiveTextLoggerCfg.hpp
Normal file
8
default/config/ActiveTextLoggerCfg.hpp
Normal file
@ -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_ */
|
||||
@ -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"
|
||||
|
||||
8
default/config/PassiveTextLoggerCfg.hpp
Normal file
8
default/config/PassiveTextLoggerCfg.hpp
Normal file
@ -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_ */
|
||||
Loading…
x
Reference in New Issue
Block a user