GCC Code Coverage Report


Directory: ./
File: Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImplCommon.cpp
Date: 2026-09-03 21:13:48
Exec Total Coverage
Lines: 32 56 57.1%
Functions: 4 5 80.0%
Branches: 26 37 70.3%

Line Branch Exec Source
1 #include <Fw/FPrimeBasicTypes.hpp>
2 #include <Fw/Logger/Logger.hpp>
3 #include <Fw/Types/Assert.hpp>
4 #include <Svc/PassiveConsoleTextLogger/ConsoleTextLoggerImpl.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
10 3 ConsoleTextLoggerImpl::ConsoleTextLoggerImpl(const char* compName)
11
1/1
✓ Branch 14 taken 3 times.
3 : PassiveTextLoggerComponentBase(compName), m_numFilteredIDs(0), m_severityFilter() {
12 // Set severity filter defaults from config
13
2/2
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
3 this->m_severityFilter.setFilter(Fw::LogSeverity::WARNING_HI, PASSIVE_TEXT_LOGGER_FILTER_WARNING_HI_DEFAULT);
14
2/2
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
3 this->m_severityFilter.setFilter(Fw::LogSeverity::WARNING_LO, PASSIVE_TEXT_LOGGER_FILTER_WARNING_LO_DEFAULT);
15
2/2
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
3 this->m_severityFilter.setFilter(Fw::LogSeverity::COMMAND, PASSIVE_TEXT_LOGGER_FILTER_COMMAND_DEFAULT);
16
2/2
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
3 this->m_severityFilter.setFilter(Fw::LogSeverity::ACTIVITY_HI, PASSIVE_TEXT_LOGGER_FILTER_ACTIVITY_HI_DEFAULT);
17
2/2
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
3 this->m_severityFilter.setFilter(Fw::LogSeverity::ACTIVITY_LO, PASSIVE_TEXT_LOGGER_FILTER_ACTIVITY_LO_DEFAULT);
18
2/2
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
3 this->m_severityFilter.setFilter(Fw::LogSeverity::DIAGNOSTIC, PASSIVE_TEXT_LOGGER_FILTER_DIAGNOSTIC_DEFAULT);
19 3 }
20
21 6 ConsoleTextLoggerImpl::~ConsoleTextLoggerImpl() {}
22
23 void ConsoleTextLoggerImpl::configure(const FwEventIdType* filteredIds, FwSizeType count) {
24 FW_ASSERT(filteredIds != nullptr || count == 0);
25 FW_ASSERT(count <= PASSIVE_TEXT_LOGGER_ID_FILTER_SIZE, static_cast<FwAssertArgType>(count),
26 PASSIVE_TEXT_LOGGER_ID_FILTER_SIZE);
27
28 this->m_numFilteredIDs = count;
29 for (FwSizeType entry = 0; entry < count; entry++) {
30 this->m_filteredIDs[entry] = filteredIds[entry];
31 }
32 }
33
34 14 void ConsoleTextLoggerImpl::setSeverityFilter(Fw::LogSeverity severity, bool enabled) {
35
2/2
✓ Branch 5 taken 14 times.
✓ Branch 8 taken 14 times.
14 this->m_severityFilter.setFilter(severity, enabled);
36 14 }
37
38 11 void ConsoleTextLoggerImpl::TextLogger_handler(FwIndexType portNum,
39 FwEventIdType id,
40 Fw::Time& timeTag,
41 const Fw::LogSeverity& severity,
42 Fw::TextLogString& text) {
43 // Check severity filter
44
4/4
✓ Branch 5 taken 11 times.
✓ Branch 8 taken 11 times.
✓ Branch 13 taken 8 times.
✓ Branch 14 taken 3 times.
11 if (this->m_severityFilter.isFiltered(severity)) {
45 8 return;
46 }
47
48 // Check event ID filters
49
1/2
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 for (FwSizeType i = 0; i < this->m_numFilteredIDs; i++) {
50 if (this->m_filteredIDs[i] == id) {
51 return;
52 }
53 }
54
55 3 const char* severityString = nullptr;
56
4/10
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
3 switch (severity.e) {
57 1 case Fw::LogSeverity::FATAL:
58 1 severityString = "FATAL";
59 1 break;
60 1 case Fw::LogSeverity::WARNING_HI:
61 1 severityString = "WARNING_HI";
62 1 break;
63 1 case Fw::LogSeverity::WARNING_LO:
64 1 severityString = "WARNING_LO";
65 1 break;
66 case Fw::LogSeverity::COMMAND:
67 severityString = "COMMAND";
68 break;
69 case Fw::LogSeverity::ACTIVITY_HI:
70 severityString = "ACTIVITY_HI";
71 break;
72 case Fw::LogSeverity::ACTIVITY_LO:
73 severityString = "ACTIVITY_LO";
74 break;
75 case Fw::LogSeverity::DIAGNOSTIC:
76 severityString = "DIAGNOSTIC";
77 break;
78 default:
79 severityString = "SEVERITY ERROR";
80 break;
81 }
82 3 FW_ASSERT(severityString != nullptr);
83
1/1
✓ Branch 4 taken 3 times.
12 Fw::Logger::log("EVENT: (%" PRI_FwEventIdType ") (%" PRI_FwTimeBaseStoreType ":%" PRIu32 ",%" PRIu32 ") %s: %s\n",
84
1/1
✓ Branch 5 taken 3 times.
9 id, static_cast<FwTimeBaseStoreType>(timeTag.getTimeBase()), timeTag.getSeconds(),
85 6 timeTag.getUSeconds(), severityString, text.toChar());
86 }
87 } // namespace Svc
88