F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
Logger.cpp
Go to the documentation of this file.
1 
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 void Logger::log(const char* format, ...) {
22  Fw::String formatted_string;
23  // Forward the variable arguments to the vformat format implementation
24  va_list args;
25  va_start(args, format);
26  formatted_string.vformat(format, args);
27  va_end(args);
28  Logger::log(formatted_string);
29 }
30 
31 void Logger::log(const StringBase& string) {
32  if (Logger::s_current_logger != nullptr) {
33  Logger::s_current_logger->writeMessage(string);
34  }
35 }
36 
38  Logger::s_current_logger = logger;
39 }
40 
41 } // End namespace Fw
static void registerLogger(Logger *logger)
register a logger implementation
Definition: Logger.cpp:37
static void log(const char *format,...)
log a formated string with supplied arguments
Definition: Logger.cpp:21
void vformat(const CHAR *formatString, va_list args)
write formatted string to buffer using va_list
Definition: StringBase.cpp:63