ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
Logging functions

Functions for printing out logs. More...

Files

file  ruuvi_interface_log.h
 

Enumerations

enum  ri_log_severity_t {
  RI_LOG_LEVEL_NONE = 0 , RI_LOG_LEVEL_ERROR , RI_LOG_LEVEL_WARNING , RI_LOG_LEVEL_INFO ,
  RI_LOG_LEVEL_DEBUG
}
 Enable implementation selected by application. More...
 

Functions

rd_status_t ri_log_init (const ri_log_severity_t min_severity)
 Runs initialization code for the logging backend and sets the severity level. More...
 
rd_status_t ri_log_flush (void)
 Blocks until remaining log messages are sent out. More...
 
void ri_log (const ri_log_severity_t severity, const char *const message)
 Queues messages into log. More...
 
void ri_log_hex (const ri_log_severity_t severity, const uint8_t *const bytes, size_t byte_length)
 Queues bytes to be logged out as a hex string. More...
 
size_t ri_error_to_string (rd_status_t error, char *error_string, size_t space_remaining)
 Write text description of error message into given string pointer and null-terminate it. The string will be cut if it cannot fit into given space. More...
 
void ri_log_sensor_configuration (const ri_log_severity_t level, const rd_sensor_configuration_t *const configuration, const char *unit)
 

Detailed Description

Functions for printing out logs.

Enumeration Type Documentation

◆ ri_log_severity_t

Enable implementation selected by application.

Severity levels of log messages. Lower numerical value means more severe.

Enumerator
RI_LOG_LEVEL_NONE 
RI_LOG_LEVEL_ERROR 
RI_LOG_LEVEL_WARNING 
RI_LOG_LEVEL_INFO 
RI_LOG_LEVEL_DEBUG 

Definition at line 39 of file ruuvi_interface_log.h.

Function Documentation

◆ ri_error_to_string()

size_t ri_error_to_string ( rd_status_t  error,
char *  error_string,
size_t  space_remaining 
)

Write text description of error message into given string pointer and null-terminate it. The string will be cut if it cannot fit into given space.

Parameters
errorerror code to convert to string
error_stringpointer to character array where error should be written
space_remainingHow many bytes there are remaining in the error string.
Returns
number of bytes written (snprintf rvalue).

Definition at line 379 of file ruuvi_interface_log.c.

◆ ri_log()

void ri_log ( const ri_log_severity_t  severity,
const char *const  message 
)

Queues messages into log.

May block or may return as soon as data is in buffer being transferred out

Parameters
severityseverity of the log message
messagemessage string

Definition at line 347 of file ruuvi_interface_log.c.

◆ ri_log_flush()

rd_status_t ri_log_flush ( void  )

Blocks until remaining log messages are sent out.

Returns
RD_SUCCESS if buffered messages were sent, error otherwise.
RD_SUCCESS if buffered messages were sent, error otherwise.

Definition at line 333 of file ruuvi_interface_log.c.

◆ ri_log_hex()

void ri_log_hex ( const ri_log_severity_t  severity,
const uint8_t *const  bytes,
size_t  byte_length 
)

Queues bytes to be logged out as a hex string.

May block or may return as soon as data is in buffer being transferred out

Parameters
severityseverity of the log message
bytesraw bytes to log
byte_lengthlength of bytes to log.

Definition at line 363 of file ruuvi_interface_log.c.

◆ ri_log_init()

rd_status_t ri_log_init ( const ri_log_severity_t  min_severity)

Runs initialization code for the logging backend and sets the severity level.

Parameters
min_severityleast severe log level that will be printed.
Return values
RD_SUCCESSif log was init.
RD_ERROR_INVALID_STATEif log had already been initialized.
Returns
RD_SUCCESS if log was init, error code otherwise.

Definition at line 322 of file ruuvi_interface_log.c.

◆ ri_log_sensor_configuration()

void ri_log_sensor_configuration ( const ri_log_severity_t  level,
const rd_sensor_configuration_t *const  configuration,
const char *  unit 
)

Log the given configuration parameters at given log level.

parameter level: Level of log. RI_LOG_ (ERROR, WARNING, INFO, DEBUG) parameter configuration: Configuration to print parameter unit: String representation to the unit of a scale

Definition at line 392 of file ruuvi_interface_log.c.