| 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 | 1 | ConsoleTextLoggerImpl::ConsoleTextLoggerImpl(const char* compName) | |
| 11 |
1/1✓ Branch 2 taken 1 times.
|
1 | : PassiveTextLoggerComponentBase(compName), m_numFilteredIDs(0), m_severityFilter() { |
| 12 | // Set severity filter defaults from config | ||
| 13 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | this->m_severityFilter.setFilter(Fw::LogSeverity::WARNING_HI, PASSIVE_TEXT_LOGGER_FILTER_WARNING_HI_DEFAULT); |
| 14 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | this->m_severityFilter.setFilter(Fw::LogSeverity::WARNING_LO, PASSIVE_TEXT_LOGGER_FILTER_WARNING_LO_DEFAULT); |
| 15 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | this->m_severityFilter.setFilter(Fw::LogSeverity::COMMAND, PASSIVE_TEXT_LOGGER_FILTER_COMMAND_DEFAULT); |
| 16 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | this->m_severityFilter.setFilter(Fw::LogSeverity::ACTIVITY_HI, PASSIVE_TEXT_LOGGER_FILTER_ACTIVITY_HI_DEFAULT); |
| 17 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | this->m_severityFilter.setFilter(Fw::LogSeverity::ACTIVITY_LO, PASSIVE_TEXT_LOGGER_FILTER_ACTIVITY_LO_DEFAULT); |
| 18 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | this->m_severityFilter.setFilter(Fw::LogSeverity::DIAGNOSTIC, PASSIVE_TEXT_LOGGER_FILTER_DIAGNOSTIC_DEFAULT); |
| 19 | 1 | } | |
| 20 | |||
| 21 | 2 | 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 | ✗ | void ConsoleTextLoggerImpl::setSeverityFilter(Fw::LogSeverity severity, bool enabled) { | |
| 35 | ✗ | this->m_severityFilter.setFilter(severity, enabled); | |
| 36 | ✗ | } | |
| 37 | |||
| 38 | 555 | 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 1 taken 555 times.
✓ Branch 4 taken 555 times.
✓ Branch 7 taken 107 times.
✓ Branch 8 taken 448 times.
|
555 | if (this->m_severityFilter.isFiltered(severity)) { |
| 45 | 107 | return; | |
| 46 | } | ||
| 47 | |||
| 48 | // Check event ID filters | ||
| 49 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 448 times.
|
448 | for (FwSizeType i = 0; i < this->m_numFilteredIDs; i++) { |
| 50 | ✗ | if (this->m_filteredIDs[i] == id) { | |
| 51 | ✗ | return; | |
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | 448 | const char* severityString = nullptr; | |
| 56 |
5/8✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 290 times.
✓ Branch 4 taken 122 times.
✓ Branch 5 taken 28 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
448 | switch (severity.e) { |
| 57 | ✗ | case Fw::LogSeverity::FATAL: | |
| 58 | ✗ | severityString = "FATAL"; | |
| 59 | ✗ | break; | |
| 60 | 3 | case Fw::LogSeverity::WARNING_HI: | |
| 61 | 3 | severityString = "WARNING_HI"; | |
| 62 | 3 | break; | |
| 63 | 5 | case Fw::LogSeverity::WARNING_LO: | |
| 64 | 5 | severityString = "WARNING_LO"; | |
| 65 | 5 | break; | |
| 66 | 290 | case Fw::LogSeverity::COMMAND: | |
| 67 | 290 | severityString = "COMMAND"; | |
| 68 | 290 | break; | |
| 69 | 122 | case Fw::LogSeverity::ACTIVITY_HI: | |
| 70 | 122 | severityString = "ACTIVITY_HI"; | |
| 71 | 122 | break; | |
| 72 | 28 | case Fw::LogSeverity::ACTIVITY_LO: | |
| 73 | 28 | severityString = "ACTIVITY_LO"; | |
| 74 | 28 | break; | |
| 75 | ✗ | case Fw::LogSeverity::DIAGNOSTIC: | |
| 76 | ✗ | severityString = "DIAGNOSTIC"; | |
| 77 | ✗ | break; | |
| 78 | ✗ | default: | |
| 79 | ✗ | severityString = "SEVERITY ERROR"; | |
| 80 | ✗ | break; | |
| 81 | } | ||
| 82 | 448 | FW_ASSERT(severityString != nullptr); | |
| 83 |
1/1✓ Branch 4 taken 448 times.
|
896 | Fw::Logger::log("EVENT: (%" PRI_FwEventIdType ") (%" PRI_FwTimeBaseStoreType ":%" PRIu32 ",%" PRIu32 ") %s: %s\n", |
| 84 |
1/1✓ Branch 1 taken 448 times.
|
896 | id, static_cast<FwTimeBaseStoreType>(timeTag.getTimeBase()), timeTag.getSeconds(), |
| 85 | timeTag.getUSeconds(), severityString, text.toChar()); | ||
| 86 | } | ||
| 87 | } // namespace Svc | ||
| 88 |