Fixposition SDK 0.0.0-heads/main-0-g90a51ff
Collection of c++ libraries and apps for use with Fixposition products
Loading...
Searching...
No Matches
fpsdk::common::logging Namespace Reference

Logging. More...

Classes

struct  LoggingParams
 Logging parameters. More...
 

Typedefs

using LoggingPrintFunc = void (*)(const LoggingParams&, const LoggingLevel, const char*)
 Custom logging print function signature.
 

Enumerations

enum class  LoggingLevel : int {
  FATAL = 2 , ERROR = 3 , WARNING = 4 , NOTICE = 5 ,
  INFO = 6 , DEBUG = 7 , TRACE = 8
}
 Logging verbosity levels, default is INFO. More...
 
enum class  LoggingColour { AUTO = 0 , YES , NO , JOURNAL }
 Logging "colours". More...
 
enum class  LoggingTimestamps { NONE = 0 , RELATIVE , ABSOLUTE }
 Logging timestamps. More...
 

Functions

LoggingLeveloperator++ (LoggingLevel &level)
 Increase verbosity (pre-increment)
 
LoggingLeveloperator-- (LoggingLevel &level)
 Decrease verbosity (pre-decrement)
 
LoggingLevel operator++ (LoggingLevel &level, int)
 Increase verbosity (post-increment)
 
LoggingLevel operator-- (LoggingLevel &level, int)
 Decrease verbosity (post-decrement)
 
const char * LoggingLevelStr (const LoggingLevel level)
 Stringify log level.
 
bool LoggingIsLevel (const LoggingLevel level)
 Check if given level would print.
 
const char * LoggingColourStr (const LoggingColour colour)
 Stringify log level.
 
const char * LoggingTimestampsStr (const LoggingTimestamps timestamps)
 Stringify log level.
 
LoggingParams LoggingSetParams (const LoggingParams &params)
 Configure logging.
 
LoggingParams LoggingGetParams ()
 Get current logging params.
 
void LoggingPrint (const LoggingLevel level, const char *fmt,...) PRINTF_ATTR(2)
 Print a log message.
 
void LoggingHexdump (const LoggingLevel level, const uint8_t *data, const std::size_t size, const char *prefix, const char *fmt,...) PRINTF_ATTR(5)
 Print a hexdump.
 

Detailed Description

Logging.

Typedef Documentation

◆ LoggingPrintFunc

using fpsdk::common::logging::LoggingPrintFunc = void (*)(const LoggingParams&, const LoggingLevel, const char*)

Custom logging print function signature.

Definition at line 255 of file logging.hpp.

Enumeration Type Documentation

◆ LoggingLevel

enum class fpsdk::common::logging::LoggingLevel : int
strong

Logging verbosity levels, default is INFO.

The logging levels loosely follow syslog levels (indicated in [] below, see also https://en.wikipedia.org/wiki/Syslog)

Libraries (fpsdk_common, fpsdk_ros1, ...) code shall only use WARNING and DEBUG.

Enumerator
FATAL 

[2/crit] Hard errors, critical conditions (for apps). Cannot be silenced.

ERROR 

[3/err] Errors (for apps)

WARNING 

[4/warning] Warnings (for libs and apps)

NOTICE 

[5/notice] Significant stuff, for example headings (for apps)

INFO 

[6/info] Interesting stuff, the default level (for apps)

DEBUG 

[7/debug] Debugging (for libs and apps)

TRACE 

[7/debug] Extra debugging, only compiled-in in non-Release builds

Definition at line 177 of file logging.hpp.

◆ LoggingColour

Logging "colours".

Enumerator
AUTO 

Automatic (default), use colours if stderr is an interactive terminal.

YES 

Use colours (terminal escape sequences)

NO 

Do not use colours.

JOURNAL 

Use systemd journal level indicators (instead of terminal colours), useful for systemd services.

Definition at line 214 of file logging.hpp.

◆ LoggingTimestamps

Logging timestamps.

Enumerator
NONE 

No timestamps.

RELATIVE 

Relative timestamps (since first logging message, sssss.sss format)

ABSOLUTE 

Absolute timestamps (local time, yyyy-mm-dd hh::mm:ss.sss format)

Definition at line 234 of file logging.hpp.

Function Documentation

◆ LoggingLevelStr()

const char * fpsdk::common::logging::LoggingLevelStr ( const LoggingLevel level)

Stringify log level.

Parameters
[in]levelThe logging level
Returns
a unique string identifying the level

◆ LoggingIsLevel()

bool fpsdk::common::logging::LoggingIsLevel ( const LoggingLevel level)

Check if given level would print.

Parameters
[in]levelThe logging level in question
Returns
true if the given level would print, false otherwise

◆ LoggingColourStr()

const char * fpsdk::common::logging::LoggingColourStr ( const LoggingColour colour)

Stringify log level.

Parameters
[in]colourThe logging colour
Returns
a unique string identifying the level

◆ LoggingTimestampsStr()

const char * fpsdk::common::logging::LoggingTimestampsStr ( const LoggingTimestamps timestamps)

Stringify log level.

Parameters
[in]timestampsThe logging timestamps
Returns
a unique string identifying the level

◆ LoggingSetParams()

LoggingParams fpsdk::common::logging::LoggingSetParams ( const LoggingParams & params)

Configure logging.

Parameters
[in]paramsLogging parameters

Examples:

LoggingParams LoggingSetParams(const LoggingParams &params)
Configure logging.
@ RELATIVE
Relative timestamps (since first logging message, sssss.sss format)
@ DEBUG
[7/debug] Debugging (for libs and apps)
@ YES
Use colours (terminal escape sequences)
@ AUTO
Automatic (default), use colours if stderr is an interactive terminal.
Returns
a copy of the applied logging parameters

◆ LoggingGetParams()

LoggingParams fpsdk::common::logging::LoggingGetParams ( )

Get current logging params.

Returns
a copy of the current logging params

◆ LoggingPrint()

void fpsdk::common::logging::LoggingPrint ( const LoggingLevel level,
const char * fmt,
... )

Print a log message.

Note
Use INFO(), DEBUG(), WARNING() etc. instead of this function.
Parameters
[in]levelLogging level
[in]fmtprintf() style format string
[in]...arguments to the format string

◆ LoggingHexdump()

void fpsdk::common::logging::LoggingHexdump ( const LoggingLevel level,
const uint8_t * data,
const std::size_t size,
const char * prefix,
const char * fmt,
... )

Print a hexdump.

Note
Typically, use DEBUG_HEXDUMP() or TRACE_HEXDUMP() instead of this function.
Parameters
[in]levelLogging level
[in]dataPointer to start of data to dump
[in]sizeSize of data to dump
[in]prefixPrefix to add to each line, can be NULL to omit
[in]fmtprintf() style format string (for a first line to print), can be NULL to omit
[in]...Arguments to the format string