GCC Code Coverage Report


Directory: Fw/Logger/
File: Logger.cpp
Date: 2026-09-03 21:14:55
Exec Total Coverage
Lines: 15 15 100.0%
Functions: 3 3 100.0%
Branches: 5 5 100.0%

Line Branch Exec Source
1 /**
2 * File: Logger.cpp
3 * Description: Framework logging implementation
4 * Author: mstarch
5 *
6 * This file adds in support to the core 'Fw' package, to separate it from Os and other loggers, and
7 * allow the architect of the system to select which core framework logging should be used.
8 */
9 #include <Fw/Logger/Logger.hpp>
10 #include <Fw/Types/Assert.hpp>
11 #include <Fw/Types/String.hpp>
12 #include <Fw/Types/StringUtils.hpp>
13 #include <cstdarg>
14 #include <limits>
15
16 namespace Fw {
17
18 // Initial logger is NULL
19 Logger* Logger::s_current_logger = nullptr;
20
21 4009 void Logger::log(const char* format, ...) {
22
1/1
✓ Branch 2 taken 4009 times.
4009 Fw::String formatted_string;
23 // Forward the variable arguments to the vformat format implementation
24 4009 va_list args;
25 4009 va_start(args, format);
26
1/1
✓ Branch 2 taken 4009 times.
4009 (void)formatted_string.vformat(format, args); // log string may safely truncate
27 4009 va_end(args);
28
1/1
✓ Branch 1 taken 4009 times.
4009 Logger::log(formatted_string);
29 8018 }
30
31 6129 void Logger::log(const ConstStringBase& string) {
32
2/2
✓ Branch 0 taken 4183 times.
✓ Branch 1 taken 1946 times.
6129 if (Logger::s_current_logger != nullptr) {
33 4183 Logger::s_current_logger->writeMessage(string);
34 }
35 6129 }
36
37 3884 void Logger::registerLogger(Logger* logger) {
38 3884 Logger::s_current_logger = logger;
39 3884 }
40
41 } // End namespace Fw
42