API
 
Loading...
Searching...
No Matches
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#include "../logMeta.hpp"
14
15#include "flatbuffer_log.hpp"
16
17namespace MagAOX
18{
19namespace logger
20{
21
22
23///Empty type for resolving logs with no message.
24/**
25 * \ingroup logger_types_basic
26 */
28{
29};
30
31
32/// Base class for logs consisting of an empty message.
33/** Such logs are used to log events. Does not have eventCode or defaultLevel,
34 * so this can not be used as a log type directly.
35 *
36 *
37 * \ingroup logger_types_basic
38 */
39template<class derivedT>
41{
42 ///The type of the message
44
45 ///Get the length of the message.
46 static flatlogs::msgLenT length( const messageT & msg)
47 {
48 static_cast<void>(msg);
49
50 return 0;
51 }
52
53 ///Format the buffer given a message -- a no-op since the message is an emptyMessage.
54 /**
55 * \returns 0
56 */
57 static int format( void * msgBuffer, ///< [out] the buffer, which is ignored.
58 const messageT & msg ///< [in] an emptyMessage.
59 )
60 {
61 static_cast<void>(msgBuffer);
62 static_cast<void>(msg);
63
64 return 0;
65 }
66
67 ///Extract the message from a buffer -- a no-op since it is an emptyMessage.
68 /**
69 * \returns 0
70 */
71 static int extract( messageT & msg, ///< [out] an emptyMessage to which nothing is done.
72 void * msgBuffer, ///< [in] the empty buffer. Is ignored.
73 flatlogs::msgLenT len ///< [in] ignored length of the empty buffer.
74 )
75 {
76 static_cast<void>(msg);
77 static_cast<void>(msgBuffer);
78 static_cast<void>(len);
79
80
81 return 0;
82 }
83
84 static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
85 flatlogs::msgLenT len ///< [in] length of msgBuffer.
86 )
87 {
88 static_cast<void>(logBuff);
89 return (len == 0);
90 }
91
92 static std::string msgString( void * msgBuffer, flatlogs::msgLenT len)//messageT & msg /**< [in] [unused] the empty message */)
93 {
94 static_cast<void>(msgBuffer);
95 static_cast<void>(len);
96
97 return derivedT::msg();
98 }
99
100 static std::string msgJSON( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
101 flatlogs::msgLenT len, /**< [in] [unused] length of msgBuffer.*/
102 const uint8_t * binarySchema, /**< [in] [unused] */
103 const unsigned int binarySchemaLength /**< [in] [unused] */
104 )
105 {
106 static_cast<void>(len);
107 static_cast<void>(msgBuffer);
108 static_cast<void>(binarySchema);
109 static_cast<void>(binarySchemaLength);
110 return "{}";
111 }
112
113 /// Get an empty logMetaDetail because meta data doesn't make sense for this log
114 /**
115 * \returns an empty logMetaDetail
116 */
117 static logMetaDetail getAccessor( const std::string & member /**< [in] the name of the member */ )
118 {
119 static_cast<void>(member);
120
121 std::cerr << "meta data doesn't make sense for " << eventCodeName(derivedT::eventCode) << "\n";
122 return logMetaDetail();
123 }
124};
125
126} //namespace logger
127} //namespace MagAOX
128
129#endif //logger_types_empty_log_hpp
The MagAO-X logger flatbuffer log base type.
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:28
std::string eventCodeName(flatlogs::eventCodeT ec)
Definition logCodes.hpp:298
Definition dm.hpp:19
Base class for logs consisting of an empty message.
Definition empty_log.hpp:41
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:71
emptyMessage messageT
The type of the message.
Definition empty_log.hpp:43
static logMetaDetail getAccessor(const std::string &member)
Get an empty logMetaDetail because meta data doesn't make sense for this log.
static flatlogs::msgLenT length(const messageT &msg)
Get the length of the message.
Definition empty_log.hpp:46
static std::string msgJSON(void *msgBuffer, flatlogs::msgLenT len, const uint8_t *binarySchema, const unsigned int binarySchemaLength)
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:57
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Definition empty_log.hpp:92
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
Definition empty_log.hpp:84