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