API
empty_log.hpp
Go to the documentation of this file.
1 /** \file empty_log.hpp
2  * \brief The MagAO-X logger empty log base type.
3  * \author Jared R. Males (jaredmales@gmail.com)
4  *
5  * \ingroup logger_types_files
6  *
7  * History:
8  * - 2018-08-18 created by JRM
9  */
10 #ifndef logger_types_empty_log_hpp
11 #define logger_types_empty_log_hpp
12 
13 
14 namespace MagAOX
15 {
16 namespace logger
17 {
18 
19 
20 ///Empty type for resolving logs with no message.
21 /**
22  * \ingroup logger_types_basic
23  */
25 {
26 };
27 
28 
29 ///Base class for logs consisting of an empty message.
30 /** Such logs are used to log events. Does not have eventCode or defaultLevel,
31  * so this can not be used as a log type directly.
32  *
33  *
34  * \ingroup logger_types_basic
35  */
36 template<class derivedT>
37 struct empty_log
38 {
39  ///The type of the message
41 
42  ///Get the length of the message.
44  {
45  static_cast<void>(msg);
46 
47  return 0;
48  }
49 
50  ///Format the buffer given a message -- a no-op since the message is an emptyMessage.
51  /**
52  * \returns 0
53  */
54  static int format( void * msgBuffer, ///< [out] the buffer, which is ignored.
55  const messageT & msg ///< [in] an emptyMessage.
56  )
57  {
58  static_cast<void>(msgBuffer);
59  static_cast<void>(msg);
60 
61  return 0;
62  }
63 
64  ///Extract the message from a buffer -- a no-op since it is an emptyMessage.
65  /**
66  * \returns 0
67  */
68  static int extract( messageT & msg, ///< [out] an emptyMessage to which nothing is done.
69  void * msgBuffer, ///< [in] the empty buffer. Is ignored.
70  flatlogs::msgLenT len ///< [in] ignored length of the empty buffer.
71  )
72  {
73  static_cast<void>(msg);
74  static_cast<void>(msgBuffer);
75  static_cast<void>(len);
76 
77 
78  return 0;
79  }
80 
81  static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
82  flatlogs::msgLenT len ///< [in] length of msgBuffer.
83  )
84  {
85  static_cast<void>(logBuff);
86  return (len == 0);
87  }
88 
89  static std::string msgString( void * msgBuffer, flatlogs::msgLenT len)//messageT & msg /**< [in] [unused] the empty message */)
90  {
91  static_cast<void>(msgBuffer);
92  static_cast<void>(len);
93 
94  return derivedT::msg();
95  }
96 
97  static std::string msgJSON( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
98  flatlogs::msgLenT len, /**< [in] [unused] length of msgBuffer.*/
99  const uint8_t * binarySchema, /**< [in] [unused] */
100  const unsigned int binarySchemaLength /**< [in] [unused] */
101  )
102  {
103  static_cast<void>(len);
104  static_cast<void>(msgBuffer);
105  static_cast<void>(binarySchema);
106  static_cast<void>(binarySchemaLength);
107  return "{}";
108  }
109 };
110 
111 } //namespace logger
112 } //namespace MagAOX
113 
114 #endif //logger_types_empty_log_hpp
msgLen2T msgLenT
The type used to refer to the message length, regardless of length.
Definition: logDefs.hpp:69
std::shared_ptr< char > bufferPtrT
The log entry buffer smart pointer.
Definition: logHeader.hpp:58
Empty type for resolving logs with no message.
Definition: empty_log.hpp:25
std::stringstream msg
Definition: dm.hpp:24
Base class for logs consisting of an empty message.
Definition: empty_log.hpp:38
static int extract(messageT &msg, void *msgBuffer, flatlogs::msgLenT len)
Extract the message from a buffer – a no-op since it is an emptyMessage.
Definition: empty_log.hpp:68
emptyMessage messageT
The type of the message.
Definition: empty_log.hpp:40
static flatlogs::msgLenT length(const messageT &msg)
Get the length of the message.
Definition: empty_log.hpp:43
static std::string msgJSON(void *msgBuffer, flatlogs::msgLenT len, const uint8_t *binarySchema, const unsigned int binarySchemaLength)
Definition: empty_log.hpp:97
static int format(void *msgBuffer, const messageT &msg)
Format the buffer given a message – a no-op since the message is an emptyMessage.
Definition: empty_log.hpp:54
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Definition: empty_log.hpp:89
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
Definition: empty_log.hpp:81