GCC Code Coverage Report


Directory: ./
File: Fw/Logger/Logger.cpp
Date: 2026-09-03 21:13:48
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 5933 void Logger::log(const char* format, ...) {
22
1/1
✓ Branch 2 taken 5933 times.
5933 Fw::String formatted_string;
23 // Forward the variable arguments to the vformat format implementation
24 5933 va_list args;
25 5933 va_start(args, format);
26
1/1
✓ Branch 2 taken 5933 times.
5933 (void)formatted_string.vformat(format, args); // log string may safely truncate
27 5933 va_end(args);
28
1/1
✓ Branch 1 taken 5933 times.
5933 Logger::log(formatted_string);
29 11866 }
30
31 7978 void Logger::log(const ConstStringBase& string) {
32
2/2
✓ Branch 0 taken 4028 times.
✓ Branch 1 taken 3950 times.
7978 if (Logger::s_current_logger != nullptr) {
33 4028 Logger::s_current_logger->writeMessage(string);
34 }
35 7978 }
36
37 4000 void Logger::registerLogger(Logger* logger) {
38 4000 Logger::s_current_logger = logger;
39 4000 }
40
41 } // End namespace Fw
42