| Line |
Branch |
Decision |
Call |
Exec |
Source |
| 1 |
|
|
|
|
#include "LoggerRegistry.h" |
| 2 |
|
|
|
|
|
| 3 |
|
|
|
|
#include <mutex> |
| 4 |
|
|
|
|
#include <memory> |
| 5 |
|
|
|
|
#include <vector> |
| 6 |
|
|
|
|
#include <cstddef> |
| 7 |
|
|
|
|
|
| 8 |
|
|
|
|
#include <spdlog/sinks/stdout_sinks.h> |
| 9 |
|
|
|
|
|
| 10 |
|
|
|
|
#include "Logger.h" |
| 11 |
|
|
|
|
#include "LoggerFormatter.h" |
| 12 |
|
|
|
|
#include "BaseLoggerRegistryListener.h" |
| 13 |
|
|
|
|
#include "formatters/NameFlagFormatter.h" |
| 14 |
|
|
|
|
#include "formatters/LevelFlagFormatter.h" |
| 15 |
|
|
|
|
#include "formatters/ColoredNameFlagFormatter.h" |
| 16 |
|
|
|
|
#include "formatters/ColoredLevelFlagFormatter.h" |
| 17 |
|
|
|
|
|
| 18 |
|
|
|
|
using namespace Logging; |
| 19 |
|
|
|
|
|
| 20 |
|
|
|
3 |
LoggerRegistry::LoggerRegistry(const char* loggingDirectory, const char* fileName) |
| 21 |
2/4
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
|
|
11/16
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 8 invoked.
✓ Call 9 invoked.
✓ Call 10 invoked.
✓ Call 11 invoked.
✓ Call 14 invoked.
✗ Call 15 not invoked.
✗ Call 16 not invoked.
✗ Call 17 not invoked.
✗ Call 18 not invoked.
✗ Call 19 not invoked.
|
15 |
: fileName_(fileName), loggingDirectory_(loggingDirectory), |
| 22 |
1/2
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
|
3/5
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✗ Call 5 not invoked.
✗ Call 6 not invoked.
|
3 |
consoleSink_(std::make_shared<spdlog::sinks::stdout_sink_mt>()), |
| 23 |
1/2
✓ Branch 22 taken 3 times.
✗ Branch 23 not taken.
|
|
22/30
✓ 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 11 invoked.
✓ Call 12 invoked.
✓ Call 13 invoked.
✓ Call 14 invoked.
✓ Call 15 invoked.
✓ Call 16 invoked.
✓ Call 17 invoked.
✓ Call 18 invoked.
✓ Call 19 invoked.
✓ Call 20 invoked.
✓ Call 21 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.
|
9 |
commonFileSink_(Logger::createFileSink<std::mutex>(loggingDirectory_, fileName_)) { |
| 24 |
1/2
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
|
|
9/11
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
✓ Call 6 invoked.
✓ Call 9 invoked.
✓ Call 10 invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
|
3 |
LoggerFormatter<NameFlagFormatter, LevelFlagFormatter>::apply(commonFileSink_); |
| 25 |
1/2
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
|
|
9/11
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
✓ Call 6 invoked.
✓ Call 9 invoked.
✓ Call 10 invoked.
✗ Call 11 not invoked.
✗ Call 12 not invoked.
|
3 |
LoggerFormatter<ColoredNameFlagFormatter, ColoredLevelFlagFormatter>::apply(consoleSink_); |
| 26 |
|
|
0/14
✗ 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.
✗ Call 13 not invoked.
|
3 |
} |
| 27 |
|
|
|
|
|
| 28 |
|
|
13/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 11 invoked.
✓ Call 12 invoked.
|
21 |
LoggerRegistry::~LoggerRegistry() { |
| 29 |
2/2
✓ Branch 13 taken 5 times.
✓ Branch 14 taken 3 times.
|
2/2
✓ Decision 'true' taken 5 times.
✓ Decision 'false' taken 3 times.
|
13/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 11 invoked.
✓ Call 12 invoked.
|
8 |
for (const auto logger: loggers_) { |
| 30 |
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
|
3/3
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
|
5 |
delete logger; |
| 31 |
|
|
|
|
} |
| 32 |
|
|
14/14
✓ 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 11 invoked.
✓ Call 12 invoked.
✓ Call 13 invoked.
|
21 |
} |
| 33 |
|
|
|
|
|
| 34 |
|
|
|
✗ |
std::vector<Logger*>::const_iterator LoggerRegistry::begin() const { |
| 35 |
|
|
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.
|
✗ |
return loggers_.cbegin(); |
| 36 |
|
|
|
|
} |
| 37 |
|
|
|
|
|
| 38 |
|
|
|
✗ |
std::vector<Logger*>::const_iterator LoggerRegistry::end() const { |
| 39 |
|
|
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.
|
✗ |
return loggers_.cend(); |
| 40 |
|
|
|
|
} |
| 41 |
|
|
|
|
|
| 42 |
|
|
|
✗ |
size_t LoggerRegistry::size() const { |
| 43 |
|
|
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.
|
✗ |
return loggers_.size(); |
| 44 |
|
|
|
|
} |
| 45 |
|
|
|
|
|
| 46 |
|
|
|
✗ |
void LoggerRegistry::flush() const { |
| 47 |
|
|
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.
|
✗ |
commonFileSink_->flush(); |
| 48 |
|
|
|
✗ |
} |
| 49 |
|
|
|
|
|
| 50 |
|
|
|
✗ |
void LoggerRegistry::addListener(BaseLoggerRegistryListener* listener) { |
| 51 |
|
|
0/4
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
|
✗ |
listeners_.push_front(listener); |
| 52 |
|
|
|
✗ |
} |
| 53 |
|
|
|
|
|
| 54 |
|
|
|
✗ |
const std::string& LoggerRegistry::getFileName() const { |
| 55 |
|
|
0/3
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
|
✗ |
return fileName_; |
| 56 |
|
|
|
|
} |
| 57 |
|
|
|
|
|
| 58 |
|
|
|
✗ |
const std::string& LoggerRegistry::getLoggingDirectory() const { |
| 59 |
|
|
0/5
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
|
✗ |
return loggingDirectory_; |
| 60 |
|
|
|
|
} |
| 61 |
|
|
|
|
|
| 62 |
|
|
|
✗ |
void LoggerRegistry::setFileName(const std::string& fileName) { |
| 63 |
|
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
0/4
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
|
✗ |
if (fileName_ == fileName) return; |
| 64 |
|
|
0/4
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
|
✗ |
fileName_ = fileName; |
| 65 |
|
|
0/15
✗ 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 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.
|
✗ |
commonFileSink_ = Logger::createFileSink<std::mutex>(loggingDirectory_, fileName_); |
| 66 |
|
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
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.
|
✗ |
for (const auto& logger: loggers_) { |
| 67 |
|
|
0/7
✗ 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.
|
✗ |
logger->setCommonFileSink(commonFileSink_); |
| 68 |
|
|
|
|
} |
| 69 |
|
|
|
|
} |
| 70 |
|
|
|
|
|
| 71 |
|
|
|
✗ |
void LoggerRegistry::setLoggingDirectory(const std::string& loggingDirectory) { |
| 72 |
|
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
0/5
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
|
✗ |
if (loggingDirectory_ == loggingDirectory) return; |
| 73 |
|
|
0/5
✗ Call 0 not invoked.
✗ Call 1 not invoked.
✗ Call 2 not invoked.
✗ Call 3 not invoked.
✗ Call 4 not invoked.
|
✗ |
loggingDirectory_ = loggingDirectory; |
| 74 |
|
|
0/15
✗ 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 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.
|
✗ |
commonFileSink_ = Logger::createFileSink<std::mutex>(loggingDirectory_, fileName_); |
| 75 |
|
0/2
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
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.
|
✗ |
for (const auto& logger: loggers_) { |
| 76 |
|
|
0/7
✗ 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.
|
✗ |
logger->setCommonFileSink(commonFileSink_); |
| 77 |
|
|
0/7
✗ 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.
|
✗ |
logger->setLoggingDirectory(loggingDirectory_); |
| 78 |
|
|
|
|
} |
| 79 |
|
|
|
|
} |
| 80 |
|
|
|
|
|
| 81 |
|
|
|
✗ |
Logger* LoggerRegistry::at(const int i) const { |
| 82 |
|
|
0/7
✗ 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.
|
✗ |
return loggers_[i]; |
| 83 |
|
|
|
|
} |
| 84 |
|
|
|
|
|
| 85 |
|
|
|
3196 |
Logger* LoggerRegistry::get(const char* name) { |
| 86 |
2/2
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 3191 times.
|
2/2
✓ Decision 'true' taken 5 times.
✓ Decision 'false' taken 3191 times.
|
4/4
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
|
3196 |
if (!loggersMap_.contains(name)) { |
| 87 |
2/6
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
|
7/8
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 4 invoked.
✓ Call 5 invoked.
✓ Call 6 invoked.
✓ Call 7 invoked.
✓ Call 8 invoked.
✗ Call 13 not invoked.
|
5 |
const auto logger = new Logger(loggingDirectory_, name); |
| 88 |
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 |
logger->addSink(consoleSink_); |
| 89 |
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 |
logger->addSink(commonFileSink_); |
| 90 |
|
|
|
|
|
| 91 |
1/2
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
|
4/4
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
|
5 |
loggers_.push_back(logger); |
| 92 |
1/2
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
|
4/4
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
|
5 |
loggersMap_.emplace(name, logger); |
| 93 |
1/2
✗ Branch 13 not taken.
✓ Branch 14 taken 5 times.
|
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 5 times.
|
10/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 not invoked.
✗ Call 10 not invoked.
✗ Call 11 not invoked.
✓ Call 12 invoked.
|
5 |
for (const auto listener: listeners_) { |
| 94 |
|
|
0/7
✗ 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.
|
✗ |
listener->loggerAdded(logger); |
| 95 |
|
|
|
|
} |
| 96 |
|
|
|
|
} |
| 97 |
|
|
5/5
✓ Call 0 invoked.
✓ Call 1 invoked.
✓ Call 2 invoked.
✓ Call 3 invoked.
✓ Call 4 invoked.
|
3196 |
return loggersMap_.at(name); |
| 98 |
|
|
|
|
} |
| 99 |
|
|
|
|
|