API
 
Loading...
Searching...
No Matches

The log entry header. More...

#include <logHeader.hpp>

Collaboration diagram for flatlogs::logHeader:
Collaboration graph

Classes

struct  internal_logHeader
 
union  internal_logHeader.__unnamed4__
 

Static Public Member Functions

static int logLevel (bufferPtrT &logBuffer, const logPrioT &lvl)
 Set the level of a log entry in a logBuffer header.
 
static logPrioT logLevel (bufferPtrT &logBuffer)
 Extract the level of a log entry.
 
static logPrioT logLevel (char *logBuffer)
 Extract the level of a log entry.
 
static int eventCode (bufferPtrT &logBuffer, const eventCodeT &ec)
 Set the event code of a log entry.
 
static eventCodeT eventCode (bufferPtrT &logBuffer)
 Extract the event code of a log entry.
 
static eventCodeT eventCode (char *logBuffer)
 Extract the event code of a log entry.
 
static int timespec (bufferPtrT &logBuffer, const timespecX &ts)
 Set the timespec of a log entry.
 
static timespecX timespec (bufferPtrT &logBuffer)
 Extract the timespec of a log entry.
 
static timespecX timespec (char *logBuffer)
 Extract the timespec of a log entry.
 
static size_t lenSize (bufferPtrT &logBuffer)
 Get the size in bytes of the length field for an existing logBuffer.
 
static size_t lenSize (char *logBuffer)
 Get the size in bytes of the length field for an existing logBuffer.
 
static size_t lenSize (msgLenT &msgSz)
 Get the size in bytes of the length field for a logBuffer given the intended message length.
 
static int msgLen (bufferPtrT &logBuffer, const msgLenT &msgLen)
 Set the message length of a log entry message.
 
static msgLen0T msgLen0 (bufferPtrT &logBuffer)
 Extract the short message length of a log entry message.
 
static msgLen0T msgLen0 (char *logBuffer)
 Extract the short message length of a log entry message.
 
static msgLen1T msgLen1 (bufferPtrT &logBuffer)
 Extract the medium message length of a log entry message.
 
static msgLen1T msgLen1 (char *logBuffer)
 Extract the medium message length of a log entry message.
 
static msgLenT msgLen (bufferPtrT &logBuffer)
 Extract the message length of a log entry message.
 
static msgLenT msgLen (char *logBuffer)
 Extract the message length of a log entry message.
 
static size_t headerSize (bufferPtrT &logBuffer)
 Get the size of the header, including the variable size length field, for an existing logBuffer.
 
static size_t headerSize (char *logBuffer)
 Get the size of the header, including the variable size length field, for an existing logBuffer.
 
static size_t headerSize (msgLenT &msgSz)
 Get the size of the header, including the variable size length field, given a message size.
 
static size_t totalSize (bufferPtrT &logBuffer)
 Get the total size of the log entry, including the message buffer.
 
static size_t totalSize (char *logBuffer)
 Get the total size of the log entry, including the message buffer.
 
static size_t totalSize (msgLenT &msgSz)
 Get the total size of a log entry, given the message buffer size.
 
static void * messageBuffer (bufferPtrT &logBuffer)
 Get the message buffer address.
 
static void * messageBuffer (char *logBuffer)
 Get the message buffer address.
 
template<typename logT >
static int createLog (bufferPtrT &logBuffer, const timespecX &ts, const typename logT::messageT &msg, const logPrioT &level)
 Create a formatted log entry, filling in a buffer.
 
static int extractBasicLog (logPrioT &lvl, eventCodeT &ec, timespecX &ts, msgLenT &len, bufferPtrT &logBuffer)
 Extract the basic details of a log entry.
 
static int extractBasicLog (logPrioT &lvl, eventCodeT &ec, timespecX &ts, msgLenT &len, char *logBuffer)
 Extract the basic details of a log entry.
 

Static Public Attributes

static constexpr size_t MAX_LEN0 = std::numeric_limits<msgLen0T>::max()
 The max value in the msgLen0 field.
 
static constexpr size_t MAX_LEN1 = std::numeric_limits<msgLen1T>::max()
 The max value in the msgLen1 field.
 
static constexpr int minHeadSize
 The minimum header size.
 
static constexpr int maxHeadSize = minHeadSize + sizeof(msgLen2T)
 The maximum header size.
 

Detailed Description

The log entry header.

This class is designed to work with the log header only as a shared pointer to it, not directly on the members. The actual header struct is private so we ensure that it is accessed properly. As such all of the member methods are static and take a shared_ptr as first argument.

Definition at line 70 of file logHeader.hpp.


Class Documentation

◆ flatlogs::logHeader::internal_logHeader

struct flatlogs::logHeader::internal_logHeader

Definition at line 94 of file logHeader.hpp.

Collaboration diagram for flatlogs::logHeader::internal_logHeader:
Collaboration graph
Class Members
union internal_logHeader.__unnamed4__ __unnamed__
eventCodeT m_eventCode
logPrioT m_logLevel
timespecX m_timespecX
msgLen0T msgLen0 The short message length. Always present.

◆ flatlogs::logHeader::internal_logHeader.__unnamed4__

union flatlogs::logHeader::internal_logHeader.__unnamed4__

Definition at line 100 of file logHeader.hpp.

Collaboration diagram for flatlogs::logHeader::internal_logHeader.__unnamed4__:
Collaboration graph
Class Members
msgLen1T msgLen1 The intermediate message length. Only present if msgLen0 == max-1 of msgLen0T.
msgLen2T msgLen2 The long message length. Only present if msgLen1 == max-value of msgLen0T.

Member Function Documentation

◆ createLog()

template<typename logT >
int flatlogs::logHeader::createLog ( bufferPtrT logBuffer,
const timespecX ts,
const typename logT::messageT &  msg,
const logPrioT level 
)
static

Create a formatted log entry, filling in a buffer.

This version has the timestamp provided.

Template Parameters
logTis a log entry type
Returns
0 on success, -1 on error.
Parameters
[out]logBuffera shared_ptr<logBuffer>, which will be allocated and populated with the log entry
[in]tsthe timestamp of this log entry.
[in]msgthe message to log (could be of type emptyMessage)
[in]levelthe level (verbosity) of this log

Definition at line 634 of file logHeader.hpp.

Member Data Documentation

◆ MAX_LEN0

constexpr size_t flatlogs::logHeader::MAX_LEN0 = std::numeric_limits<msgLen0T>::max()
staticconstexpr

The max value in the msgLen0 field.

Definition at line 76 of file logHeader.hpp.

Referenced by logdump::execute(), logdump::gettimes(), lenSize(), lenSize(), msgLen(), and msgLen().

◆ MAX_LEN1

constexpr size_t flatlogs::logHeader::MAX_LEN1 = std::numeric_limits<msgLen1T>::max()
staticconstexpr

The max value in the msgLen1 field.

Definition at line 79 of file logHeader.hpp.

Referenced by lenSize(), and msgLen().

◆ maxHeadSize

constexpr int flatlogs::logHeader::maxHeadSize = minHeadSize + sizeof(msgLen2T)
staticconstexpr

The maximum header size.

The header component could be as big as this.

Definition at line 90 of file logHeader.hpp.

Referenced by logdump::execute(), and logdump::gettimes().

◆ minHeadSize

constexpr int flatlogs::logHeader::minHeadSize
staticconstexpr
Initial value:
= sizeof(logPrioT) + sizeof(eventCodeT) +
sizeof(secT) + sizeof(nanosecT) + sizeof(msgLen0T)
uint16_t eventCodeT
The type of an event code (16-bit unsigned int).
Definition logDefs.hpp:40
int8_t logPrioT
The type of the log priority code.
Definition logDefs.hpp:21
uint32_t secT
The type used for seconds.
Definition logDefs.hpp:29
uint8_t msgLen0T
The type used for the short message length.
Definition logDefs.hpp:47
uint32_t nanosecT
The type used for nanoseconds.
Definition logDefs.hpp:34

The minimum header size.

A buffer must be allocated to at least this size.

Definition at line 84 of file logHeader.hpp.

Referenced by logdump::execute(), and logdump::gettimes().


The documentation for this class was generated from the following file: