GCC Code Coverage Report


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