Virgil IoT KIT
Functions
logger-hal.h File Reference

Logger HAL functions declarations. More...

#include <stdbool.h>

Go to the source code of this file.

Functions

bool vs_logger_output_hal (const char *buffer)
 Function signature for unterminated string output. More...
 
bool vs_logger_current_time_hal (void)
 Output current date/time function signature. More...
 

Detailed Description

Logger HAL functions declarations.

These functions have to be implemented to use logger module. See #logger_usage for details.

Logger HAL Implementation

Warning
If VS_IOT_LOGGER_USE_LIBRARY is set to 1, user has to provide logger output function vs_logger_output_hal. The goal of this function is to add a part of string to the output. It can be implemented as shown :
#include <stdio.h>
bool
vs_logger_output_hal(const char *buffer) {
if (!buffer) {
return false;
}
return printf("%s", buffer) != 0;
}
Warning
If VS_IOT_LOGGER_OUTPUT_TIME is set to 1, user has to implement vs_logger_current_time_hal function that outputs current time. It can be implemented as shown below :
#include <stdio.h>
#include <time.h>
#if VS_IOT_LOGGER_OUTPUT_TIME == 1
bool
time_t result = time(NULL);
if(result != -1) {
printf( "%s", asctime(gmtime(&result)) );
return true;
}
return false;
}
#endif // #if VS_IOT_LOGGER_OUTPUT_TIME == 1

Function Documentation

◆ vs_logger_current_time_hal()

bool vs_logger_current_time_hal ( void  )

Output current date/time function signature.

This is the HAL function that has to be implemented by user if VS_IOT_LOGGER_OUTPUT_TIME == 1. It adds current date and/or time to the output, e.g. by using vs_logger_output_hal.

Returns
true in case of success or false if any error occurs

◆ vs_logger_output_hal()

bool vs_logger_output_hal ( const char *  buffer)

Function signature for unterminated string output.

This is the HAL function that has to be implemented by user if VS_IOT_LOGGER_USE_LIBRARY == 1. It sends string to the output.

Parameters
[in]bufferBuffer with part of the string. Cannot be NULL
Returns
true in case of success or false if any error occurs
vs_logger_current_time_hal
bool vs_logger_current_time_hal(void)
Output current date/time function signature.
vs_logger_output_hal
bool vs_logger_output_hal(const char *buffer)
Function signature for unterminated string output.