API
config_log.hpp
Go to the documentation of this file.
1 /** \file config_log.hpp
2  * \brief The MagAO-X logger config_log log type.
3  * \author Jared R. Males (jaredmales@gmail.com)
4  *
5  * \ingroup logger_types_files
6  *
7  * History:
8  * - 2018-09-06 created by JRM
9  */
10 #ifndef logger_types_config_log_hpp
11 #define logger_types_config_log_hpp
12 
13 #include "generated/config_log_generated.h"
14 #include "flatbuffer_log.hpp"
15 
16 namespace MagAOX
17 {
18 namespace logger
19 {
20 
21 
22 /// Log entry recording configuration settings at startup
23 /** \ingroup logger_types
24  */
25 struct config_log : public flatbuffer_log
26 {
27  ///The event code
28  static const flatlogs::eventCodeT eventCode = eventCodes::CONFIG_LOG;
29 
30  ///The default level
32 
33 
34  ///The type of the input message
35  struct messageT : public fbMessage
36  {
37  ///Construct from components
38  messageT( const std::string & name,
39  const int & code,
40  const std::string & value,
41  const std::string & source
42  )
43  {
44  auto _name = builder.CreateString(name);
45  auto _value = builder.CreateString(value);
46  auto _source = builder.CreateString(source);
47 
48 
49  auto fp = CreateConfig_log_fb(builder, _name, code, _value, _source);
50  builder.Finish(fp);
51 
52  }
53 
54  };
55 
56  static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
57  flatlogs::msgLenT len ///< [in] length of msgBuffer.
58  )
59  {
60  auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
61  return VerifyConfig_log_fbBuffer(verifier);
62  }
63 
64  ///Get the message formatte for human consumption.
65  static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
66  flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
67  )
68  {
69  static_cast<void>(len);
70 
71  auto fbs = GetConfig_log_fb(msgBuffer);
72 
73  std::string msg = "Config: ";
74 
75  if(fbs->name())
76  {
77  msg += fbs->name()->c_str();
78  }
79 
80  msg += "=";
81 
82  if(fbs->value())
83  {
84  msg += fbs->value()->c_str();
85  }
86 
87  msg += " [";
88 
89  if(fbs->source())
90  {
91  msg += fbs->source()->c_str();
92  }
93 
94  msg += "]";
95 
96  return msg;
97 
98  }
99 
100 }; //config_log
101 
102 
103 } //namespace logger
104 } //namespace MagAOX
105 
106 #endif //logger_types_config_log_hpp
107 
The MagAO-X logger flatbuffer log base type.
uint16_t eventCodeT
The type of an event code (16-bit unsigned int).
Definition: logDefs.hpp:40
msgLen2T msgLenT
The type used to refer to the message length, regardless of length.
Definition: logDefs.hpp:69
int8_t logPrioT
The type of the log priority code.
Definition: logDefs.hpp:21
static void * messageBuffer(bufferPtrT &logBuffer)
Get the message buffer address.
Definition: logHeader.hpp:621
std::shared_ptr< char > bufferPtrT
The log entry buffer smart pointer.
Definition: logHeader.hpp:58
GeneratorWrapper< T > value(T &&value)
Definition: catch.hpp:4001
std::stringstream msg
Definition: dm.hpp:24
constexpr static logPrioT LOG_INFO
Informational. The info log level is the lowest level recorded during normal operations.
Definition: logPriority.hpp:49
The type of the input message.
Definition: config_log.hpp:36
messageT(const std::string &name, const int &code, const std::string &value, const std::string &source)
Construct from components.
Definition: config_log.hpp:38
Log entry recording configuration settings at startup.
Definition: config_log.hpp:26
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatte for human consumption.
Definition: config_log.hpp:65
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
Definition: config_log.hpp:56
static const flatlogs::eventCodeT eventCode
The event code.
Definition: config_log.hpp:28
static const flatlogs::logPrioT defaultLevel
The default level.
Definition: config_log.hpp:31
Message type for resolving log messages with a f.b. builder.
flatbuffers::FlatBufferBuilder builder
Base class for logs consisting of a flatbuffer message.