Chrysalis - Logging Test Coverage


logging/
File: logging/src/Logger.cpp
Date: 2026-08-27 18:35:06
Lines:
8/25
32.0%
Functions:
2/8
25.0%
Branches:
4/14
28.6%
Decisions:
0/0
-%
Calls:
39/136
28.7%

Line Branch Decision Call Exec Source
1 #include "Logger.h"
2
3 #include <string>
4 #include <memory>
5
6 #include <spdlog/common.h>
7 #include <spdlog/logger.h>
8 #include <spdlog/sinks/sink.h>
9 #include <spdlog/sinks/basic_file_sink.h>
10
11 using namespace Logging;
12
13 5 Logger::Logger(const std::string& loggingDirectory, const char* name)
14
1/2
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
10/14
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
✓ Call 8 invoked.
✓ Call 9 invoked.
✓ Call 10 invoked.
✓ Call 11 invoked.
✗ Call 12 not invoked.
✗ Call 13 not invoked.
✗ Call 14 not invoked.
✗ Call 15 not invoked.
15 : name_(name), logger_(spdlog::logger(name)),
15
2/4
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 10 not taken.
10/15
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 5 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 8 invoked.
✓ Call 11 invoked.
✓ Call 12 invoked.
✓ Call 13 invoked.
✗ Call 14 not invoked.
✗ Call 15 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
✗ Call 18 not invoked.
15 fileSink_(createFileSink<std::mutex>(loggingDirectory, name)) {
16
1/2
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
10/12
✓ 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 10 invoked.
✓ Call 11 invoked.
✗ Call 12 not invoked.
✗ Call 13 not invoked.
5 addSink(fileSink_);
17
0/6
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
5 }
18
19 ✗ void Logger::flush() const {
20
0/11
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 9 not invoked.
✗ Call 10 not invoked.
✗ fileSink_->flush();
21 ✗ }
22
23 15 void Logger::addSink(const std::shared_ptr<spdlog::sinks::sink>& sink) {
24
9/9
✓ 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.
15 logger_.sinks().push_back(sink);
25 15 }
26
27 ✗ const char* Logger::getName() const {
28
0/1
✗ Call 0 not invoked.
✗ return name_;
29 }
30
31 ✗ spdlog::level::level_enum Logger::getLevel() const {
32
0/11
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 9 not invoked.
✗ Call 10 not invoked.
✗ return logger_.level();
33 }
34
35 ✗ void Logger::setLevel(const spdlog::level::level_enum level) {
36
0/6
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ logger_.set_level(level);
37 ✗ }
38
39 ✗ void Logger::setLoggingDirectory(const std::string& loggingDirectory) {
40
0/28
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
✗ Call 13 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
✗ Call 20 not invoked.
✗ Call 21 not invoked.
✗ Call 22 not invoked.
✗ Call 23 not invoked.
✗ Call 24 not invoked.
✗ Call 25 not invoked.
✗ Call 26 not invoked.
✗ Call 27 not invoked.
✗ Call 28 not invoked.
✗ Call 29 not invoked.
✗ Call 30 not invoked.
✗ Call 31 not invoked.
✗ Call 32 not invoked.
✗ Call 33 not invoked.
✗ fileSink_ = createFileSink<std::mutex>(loggingDirectory, logger_.name().c_str());
41
0/13
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 9 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
✗ logger_.sinks()[2] = fileSink_;
42 ✗ }
43
44 ✗ void Logger::setCommonFileSink(const std::shared_ptr<spdlog::sinks::basic_file_sink_mt>& sink) {
45
0/10
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
✗ Call 7 not invoked.
✗ Call 8 not invoked.
✗ Call 9 not invoked.
✗ logger_.sinks()[1] = sink;
46 ✗ }
47