Fixposition SDK 0.0.0-heads/main-0-g7b59b93
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 {
  FATAL , ERROR , WARNING , NOTICE ,
  INFO , DEBUG , TRACE
}
 Logging verbosity levels, default is INFO. More...
 
enum class  LoggingColour { AUTO = 0 , YES , NO , JOURNAL }
 Logging "colours". 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.
 
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 uint64_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 201 of file logging.hpp.

Enumeration Type Documentation

◆ LoggingLevel

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 151 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 188 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

◆ LoggingSetParams()

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

Configure logging.

Parameters
[in]paramsLogging parameters

Examples:

@ DEBUG
[7/debug] Debugging (for libs and apps)
LoggingParams LoggingSetParams(const LoggingParams &params)
Configure logging.
@ YES
Use colours (terminal escape sequences)
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 uint64_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