10 #ifndef logger_types_software_log_hpp
11 #define logger_types_software_log_hpp
13 #include "generated/software_log_generated.h"
40 const int32_t errnoCode,
41 const int32_t otherCode,
42 const char * explanation
45 auto _file =
builder.CreateString(file);
46 auto _expl =
builder.CreateString(explanation);
48 auto gs = CreateSoftware_log_fb(
builder, _file, line, errnoCode, otherCode, _expl);
57 const int32_t errnoCode,
58 const int32_t otherCode,
59 const std::string & explanation
62 auto _file =
builder.CreateString(file);
63 auto _expl =
builder.CreateString(explanation);
65 auto gs = CreateSoftware_log_fb(
builder, _file, line, errnoCode, otherCode, _expl);
72 const int32_t errnoCode
75 auto _file =
builder.CreateString(file);
77 auto gs = CreateSoftware_log_fb(
builder, _file, line, errnoCode, 0, 0);
84 const int32_t errnoCode,
85 const char * explanation
88 auto _file =
builder.CreateString(file);
89 auto _expl =
builder.CreateString(explanation);
91 auto gs = CreateSoftware_log_fb(
builder, _file, line, errnoCode, 0, _expl);
98 const int32_t errnoCode,
99 const std::string & explanation
102 auto _file =
builder.CreateString(file);
103 auto _expl =
builder.CreateString(explanation);
105 auto gs = CreateSoftware_log_fb(
builder, _file, line, errnoCode, 0, _expl);
112 const std::string & explanation
115 auto _file =
builder.CreateString(file);
116 auto _expl =
builder.CreateString(explanation);
118 auto gs = CreateSoftware_log_fb(
builder, _file, line, 0,0,_expl);
127 auto _file =
builder.CreateString(file);
129 auto gs = CreateSoftware_log_fb(
builder, _file, line, 0,0,0);
141 return VerifySoftware_log_fbBuffer(verifier);
150 static_cast<void>(len);
152 auto rgs = GetSoftware_log_fb(msgBuffer);
154 std::string ret =
"SW FILE: ";
155 if(rgs->file() !=
nullptr)
157 ret += rgs->file()->c_str();
165 ret += mx::ioutils::convertToString(rgs->line());
169 ret += mx::ioutils::convertToString(rgs->errnoCode());
171 ret += strerror(rgs->errnoCode());
177 ret += mx::ioutils::convertToString(rgs->otherCode());
178 if(rgs->explanation())
181 ret += rgs->explanation()->c_str();
185 else if(rgs->explanation())
188 ret += rgs->explanation()->c_str();
The MagAO-X logger flatbuffer log base type.
uint16_t eventCodeT
The type of an event code (16-bit unsigned int).
msgLen2T msgLenT
The type used to refer to the message length, regardless of length.
int8_t logPrioT
The type of the log priority code.
static void * messageBuffer(bufferPtrT &logBuffer)
Get the message buffer address.
std::shared_ptr< char > bufferPtrT
The log entry buffer smart pointer.
constexpr static logPrioT LOG_DEBUG
Used for debugging.
constexpr static logPrioT LOG_CRITICAL
The process can not continue and will shut down (fatal)
constexpr static logPrioT LOG_ERROR
An error has occured which the software will attempt to correct.
constexpr static logPrioT LOG_INFO
Informational. The info log level is the lowest level recorded during normal operations.
constexpr static logPrioT LOG_DEBUG2
Used for debugging, providing a 2nd level.
constexpr static logPrioT LOG_ALERT
This should only be used if some action is required by operators to keep the system safe.
constexpr static logPrioT LOG_EMERGENCY
Normal operations of the entire system should be shut down immediately.
constexpr static logPrioT LOG_WARNING
A condition has occurred which may become an error, but the process continues.
constexpr static logPrioT LOG_NOTICE
A normal but significant condition.
Message type for resolving log messages with a f.b. builder.
flatbuffers::FlatBufferBuilder builder
Base class for logs consisting of a flatbuffer message.
Software ALERT log entry.
static const flatlogs::logPrioT defaultLevel
The default level.
Software CRITICAL log entry.
static const flatlogs::logPrioT defaultLevel
The default level.
Software DEBUG2 log entry.
static const flatlogs::logPrioT defaultLevel
The default level.
Software DEBUG log entry.
static const flatlogs::logPrioT defaultLevel
The default level.
Software EMERGENCY log entry.
static const flatlogs::logPrioT defaultLevel
The default level.
static const flatlogs::logPrioT defaultLevel
The default level.
static const flatlogs::logPrioT defaultLevel
The default level.
messageT(const char *file, const uint32_t line, const int32_t errnoCode, const int32_t otherCode, const std::string &explanation)
C'tor with full specification, overloaded for a std::string in explanation.
messageT(const char *file, const uint32_t line, const std::string &explanation)
C'tor with no codes, just the explanation.
messageT(const char *file, const uint32_t line, const int32_t errnoCode)
C'tor for errno only – code explanation can be looked up later.
messageT(const char *file, const uint32_t line, const int32_t errnoCode, const std::string &explanation)
C'tor for errno with additional explanation, std::string overload.
messageT(const char *file, const uint32_t line)
C'tor for a trace log, only the file and line.
messageT(const char *file, const uint32_t line, const int32_t errnoCode, const int32_t otherCode, const char *explanation)
C'tor with full specification.
messageT(const char *file, const uint32_t line, const int32_t errnoCode, const char *explanation)
C'tor for errno with additional explanation.
Base class for software logs.
static bool verify(flatlogs::bufferPtrT &logBuff, flatlogs::msgLenT len)
static const flatlogs::eventCodeT eventCode
The event code.
static std::string msgString(void *msgBuffer, flatlogs::msgLenT len)
Get the message formatted for human consumption.
Software NOTICE log entry.
static const flatlogs::logPrioT defaultLevel
The default level.
static const flatlogs::logPrioT defaultLevel
The default level.