Chrysalis - Logging Test Coverage


logging/
File: logging/src/NameFlagFormatter.cpp
Date: 2026-08-27 18:35:06
Lines:
8/10
80.0%
Functions:
2/2
100.0%
Branches:
4/14
28.6%
Decisions:
1/4
25.0%
Calls:
23/40
57.5%

Line Branch Decision Call Exec Source
1 #include "formatters/NameFlagFormatter.h"
2
3 #include <ctime>
4 #include <string>
5 #include <memory>
6
7 #include <spdlog/common.h>
8 #include <spdlog/details/log_msg.h>
9 #include <spdlog/pattern_formatter.h>
10
11 #include "Logger.h"
12
13 using namespace Logging;
14
15 81 void NameFlagFormatter::format(const spdlog::details::log_msg& msg, const std::tm& tm_time, spdlog::memory_buf_t& dest) {
16
1/2
✓ Branch 11 taken 81 times.
✗ Branch 12 not taken.
12/13
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 8 invoked.
✓ Call 9 invoked.
✓ Call 10 invoked.
✓ Call 13 invoked.
✗ Call 14 not invoked.
243 std::string name(msg.logger_name.begin(), msg.logger_name.end());
17
1/2
✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
1/2
✓ Decision 'true' taken 81 times.
✗ Decision 'false' not taken.
1/1
✓ Call 0 invoked.
81 if (name.length() < Logger::LOGGER_NAME_LENGTH) {
18
1/2
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
2/2
✓ Call 0 invoked.
✓ Call 1 invoked.
81 name.append(Logger::LOGGER_NAME_LENGTH - name.length(), ' ');
19
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
0/1
✗ Call 0 not invoked.
✗ } else if (name.length() > Logger::LOGGER_NAME_LENGTH) {
20
0/14
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 9 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
✗ Call 13 not invoked.
✗ Call 14 not invoked.
✗ Call 15 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
✗ name = name.substr(0, Logger::LOGGER_NAME_LENGTH - 3) + "...";
21 }
22
1/2
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
2/2
✓ Call 0 invoked.
✓ Call 1 invoked.
81 dest.append(name);
23
1/2
✓ Call 0 invoked.
✗ Call 1 not invoked.
162 }
24
25 11 std::unique_ptr<spdlog::custom_flag_formatter> NameFlagFormatter::clone() const {
26
5/5
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
11 return std::unique_ptr<custom_flag_formatter>(new NameFlagFormatter(*this));
27 }
28