API
logDefs.hpp
Go to the documentation of this file.
1 /** \file logDefs.hpp
2  * \brief Type definitions for the flatlogs format.
3  * \author Jared R. Males (jaredmales@gmail.com)
4  *
5  * \ingroup flatlogs_files
6  *
7  * History:
8  * - 2018-08-17 created by JRM
9  */
10 #ifndef flatlogs_logDefs_hpp
11 #define flatlogs_logDefs_hpp
12 
13 #include <cstdint>
14 
15 namespace flatlogs
16 {
17 
18 /// The type of the log priority code.
19 /** \ingroup logDefs
20  */
21 typedef int8_t logPrioT;
22 
23 /// The type used for seconds.
24 /** Rationale: unsigned 32 bits gives us enough to last 168 yrs from the UNIX epoch, which is more than enough.
25  * 24 bits is just 1/2 year, so we would have to use a partial byte to be more optimum.
26  *
27  * \ingroup logDefs
28  */
29 typedef uint32_t secT;
30 
31 /// The type used for nanoseconds.
32 /** Rationale: unsigned 32 bits gives >4x10^9 nanoseconds, so enough for 1x10^9 nanoseconds.
33  */
34 typedef uint32_t nanosecT;
35 
36 /// The type of an event code (16-bit unsigned int).
37 /** Rationale: gives us 65,536 individual events.
38  * \ingroup logDefs
39  */
40 typedef uint16_t eventCodeT;
41 
42 /// The type used for the short message length
43 /** Rationale: most flatlog entries are short, so we use minimum space for this.
44  *
45  * \ingroup logDefs
46  */
47 typedef uint8_t msgLen0T;
48 
49 /// The type used for intermediate message length
50 /** Rationale: using 1+2 =3 bytes for a 256 byte message is 1.2%. 1+4 = 2.0%, and 1+8 = 3.5%.
51  *
52  * \ingroup logDefs
53  */
54 typedef uint16_t msgLen1T;
55 
56 /// The type used for long message length
57 /** Rationale: once messages are 65536 or longer, the length field is negligible. This
58  * admits messages of huge sizes.
59  *
60  * \ingroup logDefs
61  */
62 typedef uint64_t msgLen2T;
63 
64 /// The type used to refer to the message length, regardless of length.
65 /** This is not necessarily what is written to the buffer. Should always be msgLen2T so it is big enough
66  * to handle any possible length.
67  * \ingroup logDefs
68  */
69 typedef msgLen2T msgLenT;
70 
71 }//namespace flatlogs
72 
73 #endif //flatlogs_logDefs_hpp
74 
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
uint32_t nanosecT
The type used for nanoseconds.
Definition: logDefs.hpp:34