API
 
Loading...
Searching...
No Matches
telem_usage.hpp
Go to the documentation of this file.
1/** \file telem_usage.hpp
2 * \brief The MagAO-X logger telem_usage log type.
3 * \author Chris Bohlman (cbohlmanaz@gmail.com)
4 *
5 * \ingroup logger_types_files
6 *
7 * History:
8 * - 2018-10-15 created by CJB
9 */
10#ifndef logger_types_telem_usage_hpp
11#define logger_types_telem_usage_hpp
12
14#include "flatbuffer_log.hpp"
15
16namespace MagAOX
17{
18namespace logger
19{
20
21
22/// Log entry recording disk usage
23/** \ingroup logger_types
24 */
26{
27
30
31 static timespec lastRecord; ///< The time of the last time this log was recorded. Used by the telemetry system.
32
33 ///The type of the input message
34 struct messageT : public fbMessage
35 {
36 ///Construct from components
37 messageT( float ram,
38 float boot,
39 float root,
40 float data
41 )
42 {
43
44 auto fp = CreateTelem_usage_fb(builder, ram, boot, root, data );
45
46 builder.Finish(fp);
47
48 }
49
50 };
51
52 static bool verify( flatlogs::bufferPtrT & logBuff, ///< [in] Buffer containing the flatbuffer serialized message.
53 flatlogs::msgLenT len ///< [in] length of msgBuffer.
54 )
55 {
56 auto verifier = flatbuffers::Verifier( static_cast<uint8_t*>(flatlogs::logHeader::messageBuffer(logBuff)), static_cast<size_t>(len));
57 return VerifyTelem_usage_fbBuffer(verifier);
58 }
59
60 ///Get the message formatted for human consumption.
61 static std::string msgString( void * msgBuffer, /**< [in] Buffer containing the flatbuffer serialized message.*/
62 flatlogs::msgLenT len /**< [in] [unused] length of msgBuffer.*/
63 )
64 {
65
66 static_cast<void>(len); // unused by most log types
67
68 auto rgs = GetTelem_usage_fb(msgBuffer);
69
70 std::string msg = "[usage] ram: ";
71
72 msg += std::to_string(rgs->ramUsage());
73 msg += " boot: ";
74 msg += std::to_string(rgs->bootUsage());
75 msg += " root: ";
76 msg += std::to_string(rgs->rootUsage());
77 msg += " data: ";
78 msg += std::to_string(rgs->dataUsage());
79
80 return msg;
81
82 }
83
84 /// Get the logMetaDetail for a member by name
85 /**
86 * \returns the a logMetaDetail filled in with the appropriate details
87 * \returns an empty logMetaDetail if member not recognized
88 */
89 static logMetaDetail getAccessor( const std::string & member /**< [in] the name of the member */ )
90 {
91 static_cast<void>(member);
92 std::cerr << "Meta data accessor not implemented in telem_usage\n";
93 return logMetaDetail();
94 }
95
96}; //telem_usage
97
98
99
100} //namespace logger
101} //namespace MagAOX
102
103#endif //logger_types_telem_usage_hpp
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.
std::shared_ptr< char > bufferPtrT
The log entry buffer smart pointer.
Definition logHeader.hpp:58
static constexpr flatlogs::eventCodeT TELEM_USAGE
Definition logCodes.hpp:52
bool VerifyTelem_usage_fbBuffer(::flatbuffers::Verifier &verifier)
inline ::flatbuffers::Offset< Telem_usage_fb > CreateTelem_usage_fb(::flatbuffers::FlatBufferBuilder &_fbb, float ramUsage=0.0f, float bootUsage=0.0f, float rootUsage=0.0f, float dataUsage=0.0f)
const MagAOX::logger::Telem_usage_fb * GetTelem_usage_fb(const void *buf)
Definition dm.hpp:28
static constexpr logPrioT LOG_TELEM
A telemetry recording.
Message type for resolving log messages with a f.b. builder.
flatbuffers::FlatBufferBuilder builder
Base class for logs consisting of a flatbuffer message.
The type of the input message.
messageT(float ram, float boot, float root, float data)
Construct from components.
Log entry recording disk usage.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatted for human consumption.
static const flatlogs::logPrioT defaultLevel
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static logMetaDetail getAccessor(const std::string &member)
Get the logMetaDetail for a member by name.
static timespec lastRecord
The time of the last time this log was recorded. Used by the telemetry system.
static const flatlogs::eventCodeT eventCode