F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
ConsoleTextLoggerImplCommon.cpp
Go to the documentation of this file.
2 #include <Fw/Logger/Logger.hpp>
3 #include <Fw/Types/Assert.hpp>
5 
6 namespace Svc {
7 static_assert(std::numeric_limits<FwSizeType>::max() >= PASSIVE_TEXT_LOGGER_ID_FILTER_SIZE,
8  "PASSIVE_TEXT_LOGGER_ID_FILTER_SIZE must fit within range of FwSizeType");
9 
11  : PassiveTextLoggerComponentBase(compName), m_numFilteredIDs(0) {}
12 
14 
16  FW_ASSERT(count < PASSIVE_TEXT_LOGGER_ID_FILTER_SIZE, static_cast<FwAssertArgType>(count),
18 
19  this->m_numFilteredIDs = count;
20  for (FwSizeType entry = 0; entry < count; entry++) {
21  this->m_filteredIDs[entry] = filteredIds[entry];
22  }
23 }
24 
25 void ConsoleTextLoggerImpl::TextLogger_handler(FwIndexType portNum,
26  FwEventIdType id,
27  Fw::Time& timeTag,
28  const Fw::LogSeverity& severity,
29  Fw::TextLogString& text) {
30  // Check event ID filters
31  for (FwSizeType i = 0; i < this->m_numFilteredIDs; i++) {
32  if (this->m_filteredIDs[i] == id) {
33  return;
34  }
35  }
36 
37  const char* severityString = nullptr;
38  switch (severity.e) {
40  severityString = "FATAL";
41  break;
43  severityString = "WARNING_HI";
44  break;
46  severityString = "WARNING_LO";
47  break;
49  severityString = "COMMAND";
50  break;
52  severityString = "ACTIVITY_HI";
53  break;
55  severityString = "ACTIVITY_LO";
56  break;
58  severityString = "DIAGNOSTIC";
59  break;
60  default:
61  severityString = "SEVERITY ERROR";
62  break;
63  }
64  Fw::Logger::log("EVENT: (%" PRI_FwEventIdType ") (%" PRI_FwTimeBaseStoreType ":%" PRIu32 ",%" PRIu32 ") %s: %s\n",
65  id, static_cast<FwTimeBaseStoreType>(timeTag.getTimeBase()), timeTag.getSeconds(),
66  timeTag.getUSeconds(), severityString, text.toChar());
67 }
68 } // namespace Svc
PlatformSizeType FwSizeType
Auto-generated base for PassiveTextLogger component.
static void log(const char *format,...)
log a formated string with supplied arguments
Definition: Logger.cpp:21
TimeBase getTimeBase() const
Definition: Time.cpp:96
const char * toChar() const
T e
The raw enum value.
Software diagnostic events.
#define PRI_FwEventIdType
FwIdType FwEventIdType
The type of an event identifier.
Less important informational events.
An activity related to commanding.
A less serious but recoverable event.
void configure(const FwEventIdType *filteredIds, FwSizeType count)
Configure component with event ID filters.
U32 getSeconds() const
Definition: Time.cpp:88
A serious but recoverable event.
Enum representing event severity.
#define PRI_FwTimeBaseStoreType
Important informational events.
U32 getUSeconds() const
Definition: Time.cpp:92
PlatformIndexType FwIndexType
A fatal non-recoverable event.
RateGroupDivider component implementation.
#define FW_ASSERT(...)
Definition: Assert.hpp:14