API
logHeader.hpp
Go to the documentation of this file.
1 /** \file logHeader.hpp
2  * \brief The flatlogs buffer header format.
3  * \author Jared R. Males (jaredmales@gmail.com)
4  *
5  * \ingroup flatlogs_files
6  *
7  * History:
8  * - 2017-08-29 created by JRM
9  * - 2018-08-17 moved to flatlogs
10  *
11  */
12 #ifndef flatlogs_logHeader_hpp
13 #define flatlogs_logHeader_hpp
14 
15 #include <memory>
16 #include "logDefs.hpp"
17 #include "timespecX.hpp"
18 #include "logPriority.hpp"
19 
20 namespace flatlogs
21 {
22 
23 /** The log entry is a binary buffer with the following format:
24  * \addtogroup flatlogs
25  * \verbatim
26  1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2
27  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8
28  |p|evt|time_s |time_ns|l| [message (0-254)]
29  |p|evt|time_s |time_ns|E|len| [message (255-65534)]
30  |p|evt|time_s |time_ns|F|len | [message (>65535)]
31  \endverbatim
32  * where the header consists of everything up to the [message]. Table notations are:
33  * - p (uint8_t) denotes the log priority.
34  * - evt (uint16_t) denotes the event code.
35  * - time_s (uint32_t) is the time in seconds since the epoch
36  * - time_ns (uint32_t) denotes the nanoseconds past that second.
37  * - l/len is the message length field, which is variable in length
38  * depending on the size of the message:
39  * - Message length 0-253: uint8_t in a single byte.
40  * - Message length 255-65534: uint8_t = 0xFF-1 in the first byte, uint16_t in the next two bytes.
41  * - Message length 65535 and up: uint8_t=0xFF in the first byte, uint64_t in the next 8 bytes.
42  *
43  * Rationale for variable length: this keeps the space used for 0 length and short messages
44  * to a minimum, while allowing for progressively larger messages to be saved.
45  * The savings will be large for small messages, while the the cost is proportionally small
46  * for larger messages. For larger messages, this requires a progressive read to
47  * sniff out the entire length. Likewise, the cost is small relative to the cost of reading
48  * the larger message.
49  *
50  * If a non-zero message exists, it is usually a flatlogs serialized buffer.
51  *
52  *
53  */
54 
55 ///The log entry buffer smart pointer.
56 /** \ingroup logbuff
57  */
58 typedef std::shared_ptr<char> bufferPtrT;
59 
60 
61 /// The log entry header
62 /**
63  * This class is designed to work with the log header only as a shared pointer to it,
64  * not directly on the members. The actual header struct is private so we ensure that it is
65  * accessed properly. As such all of the member methods are static and take a shared_ptr as
66  * first argument.
67  *
68  * \ingroup logbuff
69  */
70 class logHeader
71 {
72 
73 public:
74 
75  ///The max value in the msgLen0 field.
76  constexpr static size_t MAX_LEN0 = std::numeric_limits<msgLen0T>::max() ;
77 
78  ///The max value in the msgLen1 field.
79  constexpr static size_t MAX_LEN1 = std::numeric_limits<msgLen1T>::max();
80 
81  ///The minimum header size
82  /** A buffer must be allocated to at least this size.
83  */
84  constexpr static int minHeadSize = sizeof(logPrioT) + sizeof(eventCodeT) +
85  sizeof(secT) + sizeof(nanosecT) + sizeof(msgLen0T);
86 
87  ///The maximum header size
88  /** The header component could be as big as this.
89  */
90  constexpr static int maxHeadSize = minHeadSize + sizeof(msgLen2T);
91 
92 private:
93 
95  {
99  msgLen0T msgLen0; ///< The short message length. Always present.
100  union
101  {
102  msgLen1T msgLen1; ///< The intermediate message length. Only present if msgLen0 == max-1 of msgLen0T.
103  msgLen2T msgLen2; ///< The long message length. Only present if msgLen1 == max-value of msgLen0T.
104  };
105  } __attribute__((packed));
106 
107 public:
108 
109  ///Set the level of a log entry in a logBuffer header
110  /**
111  * \returns 0 on success
112  * \returns -1 on error
113  *
114  * \ingroup logbuff
115  */
116  static int logLevel( bufferPtrT & logBuffer, ///< [in/out] a shared_ptr<char> containing a raw log entry buffer.
117  const logPrioT & lvl ///< [in] the new log level.
118  );
119 
120  ///Extract the level of a log entry
121  /**
122  * \returns the level
123  *
124  * \ingroup logbuff
125  */
126  static logPrioT logLevel( bufferPtrT & logBuffer /**< [in] a shared_ptr<char> containing a raw log entry buffer.*/);
127 
128  ///Extract the level of a log entry
129  /**
130  * \returns the level
131  *
132  * \ingroup logbuff
133  */
134  static logPrioT logLevel( char * logBuffer /**< [in] a pointer to a raw log entry buffer.*/);
135 
136  ///Set the event code of a log entry
137  /**
138  * \returns 0 on success
139  * \returns -1 on error
140  *
141  * \ingroup logbuff
142  */
143  static int eventCode( bufferPtrT & logBuffer, ///< [in,out] a shared_ptr<char> containing a raw log entry buffer.
144  const eventCodeT & ec ///< [in] the new event code.
145  );
146 
147  ///Extract the event code of a log entry
148  /**
149  * \returns the event code
150  *
151  * \ingroup logbuff
152  */
153  static eventCodeT eventCode( bufferPtrT & logBuffer /**< [in] a shared_ptr<char> containing a raw log entry buffer.*/);
154 
155  ///Extract the event code of a log entry
156  /**
157  * \returns the event code
158  *
159  * \ingroup logbuff
160  */
161  static eventCodeT eventCode( char * logBuffer /**< [in] a pointer a raw log entry buffer.*/);
162 
163  ///Set the timespec of a log entry
164  /**
165  * \returns 0 on success
166  * \returns -1 on error
167  *
168  * \ingroup logbuff
169  */
170  static int timespec( bufferPtrT & logBuffer, ///< [in, out] a shared_ptr<char> containing a raw log entry buffer.*/
171  const timespecX & ts ///< [in] the new timespec
172  );
173 
174  ///Extract the timespec of a log entry
175  /**
176  * \returns the timespec
177  *
178  * \ingroup logbuff
179  */
180  static timespecX timespec( bufferPtrT & logBuffer /**< [in] a shared_ptr<char> containing a raw log entry buffer.*/);
181 
182  ///Extract the timespec of a log entry
183  /**
184  * \returns the timespec
185  *
186  * \ingroup logbuff
187  */
188  static timespecX timespec( char * logBuffer /**< [in] a pointer to a raw log entry buffer.*/);
189 
190  ///Get the size in bytes of the length field for an existing logBuffer.
191  /**
192  * \returns the number of bytes in the length field.
193  *
194  * \ingroup logbuff
195  */
196  static size_t lenSize( bufferPtrT & logBuffer /**< [in] a shared_ptr<char> containing a raw log entry buffer.*/);
197 
198  ///Get the size in bytes of the length field for an existing logBuffer.
199  /**
200  * \returns the number of bytes in the length field.
201  *
202  * \ingroup logbuff
203  */
204  static size_t lenSize( char * logBuffer /**< [in] a pointer to a raw log entry buffer.*/);
205 
206  ///Get the size in bytes of the length field for a logBuffer given the intended message length
207  /**
208  * \returns the number of bytes to be put in the length field.
209  *
210  * \ingroup logbuff
211  */
212  static size_t lenSize( msgLenT & msgSz /**< [in] the size of the intended message.*/);
213 
214  ///Set the message length of a log entry message
215  /**
216  * \note The logBuffer must already be allocated with a header large enough for this message size.
217  *
218  * \returns 0 on success
219  * \returns -1 on error
220  *
221  * \ingroup logbuff
222  */
223  static int msgLen( bufferPtrT & logBuffer, ///< [out] a shared_ptr<char> containing a raw log entry buffer allocated with large enough header for this message length.
224  const msgLenT & msgLen ///< [in] the message length to set.
225  );
226 
227  ///Extract the short message length of a log entry message
228  /** This is always safe on a minimally allocated logBuffer, can be used to test for progressive reading.
229  *
230  * \returns the short message length field
231  *
232  * \ingroup logbuff
233  */
234  static msgLen0T msgLen0( bufferPtrT & logBuffer /**< [in] a shared_ptr<char> containing a raw log entry buffer.*/);
235 
236  ///Extract the short message length of a log entry message
237  /** This is always safe on a minimally allocated logBuffer, can be used to test for progressive reading.
238  *
239  * \returns the short message length field
240  *
241  * \ingroup logbuff
242  */
243  static msgLen0T msgLen0( char * logBuffer /**< [in] a pointer to a raw log entry buffer.*/);
244 
245  ///Extract the medium message length of a log entry message
246  /** This is NOT always safe, and should only be caled if msgLen0 is 0xFE. Can be used to test for progressive reading.
247  *
248  * \returns the medium message length field
249  *
250  * \ingroup logbuff
251  */
252  static msgLen1T msgLen1( bufferPtrT & logBuffer /**< [in] a shared_ptr<char> containing a raw log entry buffer.*/);
253 
254  ///Extract the medium message length of a log entry message
255  /** This is NOT always safe, and should only be caled if msgLen0 is 0xFE. Can be used to test for progressive reading.
256  *
257  * \returns the medium message length field
258  *
259  * \ingroup logbuff
260  */
261  static msgLen1T msgLen1( char * logBuffer /**< [in] a pointer to a raw log entry buffer.*/);
262 
263  ///Extract the message length of a log entry message
264  /**
265  * \returns the message length
266  *
267  * \ingroup logbuff
268  */
269  static msgLenT msgLen( bufferPtrT & logBuffer /**< [in] a shared_ptr<char> containing a raw log entry buffer.*/);
270 
271  ///Extract the message length of a log entry message
272  /**
273  * \returns the message length
274  *
275  * \ingroup logbuff
276  */
277  static msgLenT msgLen( char * logBuffer /**< [in] a pointer to a raw log entry buffer.*/);
278 
279  ///Get the size of the header, including the variable size length field, for an existing logBuffer.
280  /**
281  * \returns the size of the header in this log entry.
282  *
283  * \ingroup logbuff
284  */
285  static size_t headerSize( bufferPtrT & logBuffer /**< [in] a shared_ptr<char> containing a raw log entry buffer.*/);
286 
287  ///Get the size of the header, including the variable size length field, for an existing logBuffer.
288  /**
289  * \returns the size of the header in this log entry.
290  *
291  * \ingroup logbuff
292  */
293  static size_t headerSize( char* logBuffer /**< [in] a pointer to a raw log entry buffer.*/);
294 
295  ///Get the size of the header, including the variable size length field, given a message size.
296  /**
297  * \returns the size to be used for the header.
298  *
299  * \ingroup logbuff
300  */
301  static size_t headerSize( msgLenT & msgSz /**< [in] the size of the intended message.*/);
302 
303  ///Get the total size of the log entry, including the message buffer.
304  /**
305  * \returns the total size of this log entry.
306  *
307  * \ingroup logbuff
308  */
309  static size_t totalSize( bufferPtrT & logBuffer /**< [in] a shared_ptr<char> containing a raw log entry buffer.*/);
310 
311  ///Get the total size of the log entry, including the message buffer.
312  /**
313  * \returns the total size of this log entry.
314  *
315  * \ingroup logbuff
316  */
317  static size_t totalSize( char * logBuffer /**< [in] a pointer to a raw log entry buffer.*/);
318 
319  ///Get the total size of a log entry, given the message buffer size.
320  /**
321  * \returns the total size to be used for a log entry.
322  *
323  * \ingroup logbuff
324  */
325  static size_t totalSize( msgLenT & msgSz /**< [in] the intended size of the message buffer.*/);
326 
327  ///Get the message buffer address.
328  /**
329  * \returns the address of the message buffer.
330  *
331  * \ingroup logbuff
332  */
333  static void * messageBuffer( bufferPtrT & logBuffer /**< [in] a shared_ptr<char> containing a raw log entry buffer.*/);
334 
335  ///Get the message buffer address.
336  /**
337  * \returns the address of the message buffer.
338  *
339  * \ingroup logbuff
340  */
341  static void * messageBuffer( char * logBuffer /**< [in] a pointer to a raw log entry buffer.*/);
342 
343  /// Create a formatted log entry, filling in a buffer.
344  /** This version has the timestamp provided.
345  *
346  * \tparam logT is a log entry type
347  *
348  * \returns 0 on success, -1 on error.
349  */
350  template<typename logT>
351  static int createLog( bufferPtrT & logBuffer, ///< [out] a shared_ptr<logBuffer>, which will be allocated and populated with the log entry
352  const timespecX & ts, ///< [in] the timestamp of this log entry.
353  const typename logT::messageT & msg, ///< [in] the message to log (could be of type emptyMessage)
354  const logPrioT & level ///< [in] the level (verbosity) of this log
355  );
356 
357  ///Extract the basic details of a log entry
358  /** Convenience wrapper for the other extraction functions.
359  *
360  * \returns 0 on success, -1 on error.
361  *
362  * \ingroup logbuff
363  */
364  static int extractBasicLog( logPrioT & lvl, ///< [out] The log level
365  eventCodeT & ec, ///< [out] the event code
366  timespecX & ts, ///< [out] the timestamp of the log entry
367  msgLenT & len, ///< [out] the message length
368  bufferPtrT & logBuffer ///< [in] a shared_ptr<char> containing a raw log entry buffer.
369  );
370 
371  ///Extract the basic details of a log entry
372  /** Convenience wrapper for the other extraction functions.
373  *
374  * \returns 0 on success, -1 on error.
375  *
376  * \ingroup logbuff
377  */
378  static int extractBasicLog( logPrioT & lvl, ///< [out] The log level
379  eventCodeT & ec, ///< [out] the event code
380  timespecX & ts, ///< [out] the timestamp of the log entry
381  msgLenT & len, ///< [out] the message length
382  char* logBuffer ///< [in] a pointer to a raw log entry buffer.
383  );
384 
385 };
386 
387 inline
389  const logPrioT & lvl
390  )
391 {
392  reinterpret_cast<internal_logHeader *>(logBuffer.get())->m_logLevel = lvl;
393 
394  return 0;
395 }
396 
397 inline
399 {
400  return logLevel( logBuffer.get() );
401 
402  //return reinterpret_cast<internal_logHeader *>(logBuffer.get())->m_logLevel;
403 }
404 
405 inline
406 logPrioT logHeader::logLevel( char * logBuffer)
407 {
408  return reinterpret_cast<internal_logHeader *>(logBuffer)->m_logLevel;
409 }
410 
411 inline
413  const eventCodeT & ec
414  )
415 {
416  reinterpret_cast<internal_logHeader *>(logBuffer.get())->m_eventCode = ec;
417 
418  return 0;
419 }
420 
421 inline
423 {
424  return eventCode(logBuffer.get());
425  //return reinterpret_cast<internal_logHeader *>(logBuffer.get())->m_eventCode;
426 }
427 
428 inline
430 {
431  return reinterpret_cast<internal_logHeader *>(logBuffer)->m_eventCode;
432 }
433 
434 inline
436  const timespecX & ts
437  )
438 {
439  reinterpret_cast<internal_logHeader *>(logBuffer.get())->m_timespecX = ts;
440 
441  return 0;
442 }
443 
444 inline
446 {
447  return timespec(logBuffer.get());
448  //return reinterpret_cast<internal_logHeader *>(logBuffer.get())->m_timespecX;
449 }
450 
451 inline
452 timespecX logHeader::timespec( char * logBuffer)
453 {
454  return reinterpret_cast<internal_logHeader *>(logBuffer)->m_timespecX;
455 }
456 
457 inline
458 size_t logHeader::lenSize( bufferPtrT & logBuffer )
459 {
460  return lenSize(logBuffer.get());
461 // msgLen0T len0 = reinterpret_cast<internal_logHeader *>(logBuffer.get())->msgLen0;
462 //
463 // if(len0 < MAX_LEN0-1) return sizeof(msgLen0T);
464 //
465 // if(len0 == MAX_LEN0-1)
466 // {
467 // return sizeof(msgLen0T) + sizeof(msgLen1T);
468 // }
469 //
470 // return sizeof(msgLen0T) + sizeof(msgLen2T);
471 }
472 
473 inline
474 size_t logHeader::lenSize( char* logBuffer )
475 {
476  msgLen0T len0 = reinterpret_cast<internal_logHeader *>(logBuffer)->msgLen0;
477 
478  if(len0 < MAX_LEN0-1) return sizeof(msgLen0T);
479 
480  if(len0 == MAX_LEN0-1)
481  {
482  return sizeof(msgLen0T) + sizeof(msgLen1T);
483  }
484 
485  return sizeof(msgLen0T) + sizeof(msgLen2T);
486 }
487 
488 inline
489 size_t logHeader::lenSize( msgLenT & msgSz /**< [in] the size of the intended message.*/)
490 {
491  if(msgSz < MAX_LEN0-1) return sizeof(msgLen0T);
492 
493  if(msgSz < MAX_LEN1) return sizeof(msgLen0T) + sizeof(msgLen1T);
494 
495  return sizeof(msgLen0T) + sizeof(msgLen2T);
496 }
497 
498 inline
499 size_t logHeader::headerSize( bufferPtrT & logBuffer )
500 {
501  return headerSize(logBuffer.get());
502  //return sizeof(logPrioT) + sizeof(eventCodeT) + sizeof(secT) + sizeof(nanosecT) + lenSize(logBuffer);
503 }
504 
505 inline
506 size_t logHeader::headerSize( char* logBuffer )
507 {
508  return sizeof(logPrioT) + sizeof(eventCodeT) + sizeof(secT) + sizeof(nanosecT) + lenSize(logBuffer);
509 }
510 
511 inline
513 {
514  return sizeof(logPrioT) + sizeof(eventCodeT) + sizeof(timespecX) + lenSize(msgSz);
515 }
516 
517 inline
518 int logHeader::msgLen( bufferPtrT & logBuffer,
519  const msgLenT & msgLen
520  )
521 {
522  internal_logHeader * lh = reinterpret_cast<internal_logHeader *>(logBuffer.get());
523 
524  if( msgLen < MAX_LEN0-1 ) //254 for uint8_t
525  {
526  lh->msgLen0 = msgLen;
527  return 0;
528  }
529 
530  if(msgLen < MAX_LEN1) //65535 for uint16_t
531  {
532  lh->msgLen0 = MAX_LEN0-1; //254 for uint8_t
533  lh->msgLen1 = msgLen;
534  return 0;
535  }
536 
537  lh->msgLen0 = MAX_LEN0; //255 for uint8_t
538  lh->msgLen2 = msgLen;
539  return 0;
540 }
541 
542 inline
544 {
545  return msgLen0(logBuffer.get());
546  //return reinterpret_cast<internal_logHeader *>(logBuffer.get())->msgLen0;
547 }
548 
549 inline
550 msgLen0T logHeader::msgLen0( char * logBuffer )
551 {
552  return reinterpret_cast<internal_logHeader *>(logBuffer)->msgLen0;
553 }
554 
555 inline
557 {
558  return msgLen1(logBuffer.get());
559  //return reinterpret_cast<internal_logHeader *>(logBuffer.get())->msgLen1;
560 }
561 
562 inline
563 msgLen1T logHeader::msgLen1( char* logBuffer )
564 {
565  return reinterpret_cast<internal_logHeader *>(logBuffer)->msgLen1;
566 }
567 
568 inline
570 {
571  return msgLen(logBuffer.get());
572 // msgLen0T len0 = reinterpret_cast<internal_logHeader *>(logBuffer.get())->msgLen0;
573 //
574 // if(len0 < MAX_LEN0-1) return len0;
575 //
576 // if(len0 == MAX_LEN0-1)
577 // {
578 // return reinterpret_cast<internal_logHeader *>(logBuffer.get())->msgLen1;
579 // }
580 //
581 // return reinterpret_cast<internal_logHeader *>(logBuffer.get())->msgLen2;
582 }
583 
584 inline
585 msgLenT logHeader::msgLen( char* logBuffer )
586 {
587  msgLen0T len0 = reinterpret_cast<internal_logHeader *>(logBuffer)->msgLen0;
588 
589  //std::cerr << "len0: " << (int) len0 << "\n";
590 
591  if(len0 < MAX_LEN0-1) return len0;
592 
593  if(len0 == MAX_LEN0-1)
594  {
595  return reinterpret_cast<internal_logHeader *>(logBuffer)->msgLen1;
596  }
597 
598  return reinterpret_cast<internal_logHeader *>(logBuffer)->msgLen2;
599 }
600 
601 inline
602 size_t logHeader::totalSize( bufferPtrT & logBuffer )
603 {
604  return totalSize(logBuffer.get());
605  //return headerSize(logBuffer) + msgLen(logBuffer);
606 }
607 
608 inline
609 size_t logHeader::totalSize( char* logBuffer )
610 {
611  return headerSize(logBuffer) + msgLen(logBuffer);
612 }
613 
614 inline
615 size_t logHeader::totalSize( msgLenT & msgSz )
616 {
617  return headerSize(msgSz) + msgSz;
618 }
619 
620 inline
622 {
623  return messageBuffer(logBuffer.get());
624  //return logBuffer.get() + headerSize(logBuffer);
625 }
626 
627 inline
628 void * logHeader::messageBuffer( char* logBuffer )
629 {
630  return logBuffer + headerSize(logBuffer);
631 }
632 
633 template<typename logT>
635  const timespecX & ts,
636  const typename logT::messageT & msg,
637  const logPrioT & level
638  )
639 {
640  logPrioT lvl;
641  if(level == logPrio::LOG_DEFAULT)
642  {
643  lvl = logT::defaultLevel;
644  }
645  else lvl = level;
646 
647  //We first allocate the buffer.
648  msgLenT len = logT::length(msg);
649  logBuffer = bufferPtrT( (char *) ::operator new(totalSize(len)*sizeof(char)) );
650 
651  //Now load the basics.
652  logLevel(logBuffer, lvl);
653  eventCode(logBuffer, +logT::eventCode); //The + fixes an issue with undefined references
654  timespec(logBuffer, ts);
655 
656  msgLen( logBuffer, len);
657 
658 
659  //Each log-type is responsible for loading its message
660  logT::format( messageBuffer(logBuffer), msg);
661 
662  return 0;
663 
664 }
665 
666 inline
668  eventCodeT & ec,
669  timespecX & ts,
670  msgLenT & len,
671  bufferPtrT & logBuffer
672  )
673 {
674  return extractBasicLog(lvl, ec, ts, len, logBuffer.get());
675 // lvl = logLevel(logBuffer);
676 //
677 // ec = eventCode(logBuffer);
678 //
679 // ts = timespec(logBuffer);
680 //
681 // len = logHeader::msgLen(logBuffer);
682 //
683 // return 0;
684 }
685 
686 inline
688  eventCodeT & ec,
689  timespecX & ts,
690  msgLenT & len,
691  char* logBuffer
692  )
693 {
694  lvl = logLevel(logBuffer);
695 
696  ec = eventCode(logBuffer);
697 
698  ts = timespec(logBuffer);
699 
700  len = logHeader::msgLen(logBuffer);
701 
702  return 0;
703 }
704 
705 
706 
707 } //namespace flatlogs
708 
709 #endif //flatlogs_logHeader_hpp
710 
The log entry header.
Definition: logHeader.hpp:71
constexpr static size_t MAX_LEN1
The max value in the msgLen1 field.
Definition: logHeader.hpp:79
constexpr static size_t MAX_LEN0
The max value in the msgLen0 field.
Definition: logHeader.hpp:76
constexpr static int minHeadSize
The minimum header size.
Definition: logHeader.hpp:84
msgLen0T msgLen0
The short message length. Always present.
Definition: logHeader.hpp:99
constexpr static int maxHeadSize
The maximum header size.
Definition: logHeader.hpp:90
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.
Definition: logHeader.hpp:634
uint16_t msgLen1T
The type used for intermediate message length.
Definition: logDefs.hpp:54
uint16_t eventCodeT
The type of an event code (16-bit unsigned int).
Definition: logDefs.hpp:40
uint64_t msgLen2T
The type used for long message length.
Definition: logDefs.hpp:62
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
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
static msgLen1T msgLen1(bufferPtrT &logBuffer)
Extract the medium message length of a log entry message.
Definition: logHeader.hpp:556
static int eventCode(bufferPtrT &logBuffer, const eventCodeT &ec)
Set the event code of a log entry.
Definition: logHeader.hpp:412
static msgLen0T msgLen0(bufferPtrT &logBuffer)
Extract the short message length of a log entry message.
Definition: logHeader.hpp:543
static size_t totalSize(bufferPtrT &logBuffer)
Get the total size of the log entry, including the message buffer.
Definition: logHeader.hpp:602
static void * messageBuffer(bufferPtrT &logBuffer)
Get the message buffer address.
Definition: logHeader.hpp:621
std::shared_ptr< char > bufferPtrT
The log entry buffer smart pointer.
Definition: logHeader.hpp:58
static int extractBasicLog(logPrioT &lvl, eventCodeT &ec, timespecX &ts, msgLenT &len, bufferPtrT &logBuffer)
Extract the basic details of a log entry.
Definition: logHeader.hpp:667
static size_t headerSize(bufferPtrT &logBuffer)
Get the size of the header, including the variable size length field, for an existing logBuffer.
Definition: logHeader.hpp:499
static int msgLen(bufferPtrT &logBuffer, const msgLenT &msgLen)
Set the message length of a log entry message.
Definition: logHeader.hpp:518
static size_t lenSize(bufferPtrT &logBuffer)
Get the size in bytes of the length field for an existing logBuffer.
Definition: logHeader.hpp:458
static int logLevel(bufferPtrT &logBuffer, const logPrioT &lvl)
Set the level of a log entry in a logBuffer header.
Definition: logHeader.hpp:388
static int timespec(bufferPtrT &logBuffer, const timespecX &ts)
Set the timespec of a log entry.
Definition: logHeader.hpp:435
Type definitions for the flatlogs format.
The MagAO-X logger log priority levels.
std::stringstream msg
constexpr static logPrioT LOG_DEFAULT
Used to denote "use the default level for this log type".
Definition: logPriority.hpp:61
uint32_t nanosecT
The type used for nanoseconds.
Definition: logDefs.hpp:34
A fixed-width timespec structure.
Definition: timespecX.hpp:35
A fixed-width timespec structure and utilities.