API
flatlogs Namespace Reference

Namespaces

 logPrio
 The log priority codes. These control if logs are stored on disk and how they are presented to users.
 

Classes

class  logHeader
 The log entry header. More...
 
struct  timespecX
 A fixed-width timespec structure. More...
 

Typedefs

typedef int8_t logPrioT
 The type of the log priority code. More...
 
typedef uint32_t secT
 The type used for seconds.
More...
 
typedef uint32_t nanosecT
 The type used for nanoseconds.
More...
 
typedef uint16_t eventCodeT
 The type of an event code (16-bit unsigned int). More...
 
typedef uint8_t msgLen0T
 The type used for the short message length. More...
 
typedef uint16_t msgLen1T
 The type used for intermediate message length. More...
 
typedef uint64_t msgLen2T
 The type used for long message length. More...
 
typedef msgLen2T msgLenT
 The type used to refer to the message length, regardless of length. More...
 
typedef std::shared_ptr< char > bufferPtrT
 The log entry buffer smart pointer. More...
 

Functions

std::string priorityString (logPrioT &prio)
 Get the string representation of a log priority. More...
 
logPrioT logLevelFromString (const std::string &str)
 Get the log priority from a string, which might have the number or the name. More...
 
template<typename logT , typename iosT >
iosT & jsonFormat (iosT &ios, bufferPtrT &logBuffer, const std::string &eventCodeName, const uint8_t *binarySchema, const unsigned int binarySchemaLength)
 Function for generate a JSON-formatted text representation of a flatlog record. More...
 
template<typename logT , typename iosT >
iosT & stdFormat (iosT &ios, bufferPtrT &logBuffer)
 Worker function that formats a log into the standard text representation. More...
 
template<typename logT , typename iosT >
iosT & stdShortFormat (iosT &ios, const std::string &appName, bufferPtrT &logBuffer)
 Worker function that formats a log into the standard text representation with short timespec. More...
 
template<typename logT , typename iosT >
iosT & minFormat (iosT &ios, bufferPtrT &logBuffer)
 Worker function that formats a log into the standard text representation. More...
 
bool operator< (timespecX const &tsL, timespecX const &tsR)
 TimespecX comparison operator < (see caveats) More...
 
bool operator> (timespecX const &tsL, timespecX const &tsR)
 TimespecX comparison operator > (see caveats) More...
 
bool operator== (timespecX const &tsL, timespecX const &tsR)
 TimespecX comparison operator == (see caveats) More...
 
bool operator<= (timespecX const &tsL, timespecX const &tsR)
 TimespecX comparison operator <= (see caveats) More...
 
bool operator>= (timespecX const &tsL, timespecX const &tsR)
 TimespecX comparison operator >= (see caveats) More...
 
timespecX meanTimespecX (timespecX ts1, timespecX ts2)
 
void timespecFromX (timespec &ts, const timespecX &tsX)
 Convert a timespecX to a native timespec. More...
 
template<clockid_t clk_id = CLOCK_REALTIME>
void clock_gettimeX (timespecX &tsX)
 Fill in a timespecX with the current time. More...
 

Typedef Documentation

◆ nanosecT

typedef uint32_t flatlogs::nanosecT

The type used for nanoseconds.

Rationale: unsigned 32 bits gives >4x10^9 nanoseconds, so enough for 1x10^9 nanoseconds.

Definition at line 34 of file logDefs.hpp.

Function Documentation

◆ logLevelFromString()

logPrioT flatlogs::logLevelFromString ( const std::string &  str)
inline

Get the log priority from a string, which might have the number or the name.

Evaluates the input string to find the closest match to the log level names. If the first non-whitespace character is a digit, then the string is treated as an integer and converted. If the first non-whitespace character is not a digit, then the string is converted to upper case and the log level is determined using the minimum number of characters. That is

  • EM = EMERGENCY
  • A = ALERT
  • C = CRITICAL
  • ER = ERROR
  • W = WARNING
  • N = NOTICE
  • I = INFO, returns 3
  • D, D1, DBG, DBG1, DEBUG = DEBUG
  • D2, DBG2, DEBUG2 = DEBUG2
  • DEF = DEFAULT
  • T = TELEM
Returns
the log priority value if parsing is successful.
logPrio::LOG_UNKNOWN if parsing is not successful.

Definition at line 127 of file logPriority.hpp.

Referenced by logdump::loadConfig(), and MagAOX::logger::logManager< _parentT, _logFileT >::loadConfig().

◆ meanTimespecX()

timespecX flatlogs::meanTimespecX ( timespecX  ts1,
timespecX  ts2 
)
inline

Definition at line 331 of file timespecX.hpp.

Referenced by MagAOX::logger::getLogContVal().

◆ operator<()

bool flatlogs::operator< ( timespecX const &  tsL,
timespecX const &  tsR 
)
inline

TimespecX comparison operator < (see caveats)

Caveats:

  • If the inputs are in UTC (or similar scale) this does not account for leap seconds
  • Assumes that the time_ns field does not exceed 999999999 nanoseconds
Returns
true if tsL is earlier than tsR
false otherwise
Parameters
[in]tsLthe left hand side of the comparison
[in]tsRthe right hand side of the comparison

Definition at line 251 of file timespecX.hpp.

◆ operator<=()

bool flatlogs::operator<= ( timespecX const &  tsL,
timespecX const &  tsR 
)
inline

TimespecX comparison operator <= (see caveats)

Caveats:

  • If the inputs are in UTC (or similar scale) this does not account for leap seconds
  • Assumes that the time_ns field does not exceed 999999999 nanoseconds.
Returns
true if tsL is earlier than or exactly equal to tsR
false otherwise
Parameters
[in]tsLthe left hand side of the comparison
[in]tsRthe right hand side of the comparison

Definition at line 305 of file timespecX.hpp.

◆ operator==()

bool flatlogs::operator== ( timespecX const &  tsL,
timespecX const &  tsR 
)
inline

TimespecX comparison operator == (see caveats)

Caveats:

  • If the inputs are in UTC (or similar scale) this does not account for leap seconds
  • Assumes that the time_ns field does not exceed 999999999 nanoseconds
Returns
true if tsL is exactly the same as tsR
false otherwise
Parameters
[in]tsLthe left hand side of the comparison
[in]tsRthe right hand side of the comparison

Definition at line 287 of file timespecX.hpp.

◆ operator>()

bool flatlogs::operator> ( timespecX const &  tsL,
timespecX const &  tsR 
)
inline

TimespecX comparison operator > (see caveats)

Caveats:

  • If the inputs are in UTC (or similar scale) this does not account for leap seconds
  • Assumes that the time_ns field does not exceed 999999999 nanoseconds
Returns
true if tsL is later than tsR
false otherwise
Parameters
[in]tsLthe left hand side of the comparison
[in]tsRthe right hand side of the comparison

Definition at line 269 of file timespecX.hpp.

◆ operator>=()

bool flatlogs::operator>= ( timespecX const &  tsL,
timespecX const &  tsR 
)
inline

TimespecX comparison operator >= (see caveats)

Caveats:

  • If the inputs are in UTC (or similar scale) this does not account for leap seconds
  • Assumes that the time_ns field does not exceed 999999999 nanoseconds
Returns
true if tsL is exactly equal to or is later than tsR
false otherwise
Parameters
[in]tsLthe left hand side of the comparison
[in]tsRthe right hand side of the comparison

Definition at line 323 of file timespecX.hpp.