HALFRED
0.4.0
|
Logging component. More...
Logging component.
#include "hal_config.h"
#include "hal_iodevice.h"
#include <stdint.h>
#include <stdbool.h>
#include <inttypes.h>
Go to the source code of this file.
Typedefs | |
typedef uint32_t | HAL_LOG_Time |
Functions | |
bool | HAL_LOG_SetChannelOutput (const uint8_t channel, IODevice const iodev) |
bool | HAL_LOG_SetChannelTimeSource (const uint8_t channel, HAL_LOG_Time(*timeSourceFunction)(void)) |
bool | HAL_LOG_EnableChannel (const uint8_t channel) |
bool | HAL_LOG_DisableChannel (const uint8_t channel) |
bool | HAL_LOG_IsChannelEnabled (const uint8_t channel) |
typedef uint32_t HAL_LOG_Time |
defgroup hal_log LOG module
Introduction
The logging module in HAL (called LOG) provides a standard way for user applications to report their condition. The LOG module supports:
Module architecture The module itself consists of 1 header file and 1 source file. The vast majority of log customization is provided via preprocessing layer. Runtime operation uses standard C library, or proprietary "printf" functions for formatting output. The attached custom library is vastly faster than the stdio implementation, and does not require using dynamic memory allocation.
Diagnostic level This module uses standard syslog log detail naming. Below we list all of the detail levels in order from least detail to the most:
The Log module provides simple way to manage globally the log detail of all channels: In order to override default value (INFORMATIONAL level), user should define macro HAL_LOG_MAX_LEVEL with the level of choice.
Log channels Log subchannels Assertions Compile time API Global: [Required] HAL_ENABLE_LOG (0) Global log on/off switch [Optional] HAL_LOG_LAST_CHANNEL (0) amount of log channels available [Optional] HAL_LOG_LEVEL (HAL_LOG_LEVEL_INFO) Global maximum verbosity of log messages. All messages of higher detail will be discarded at compile time Per module: [Optional] HAL_LOG_CHANNEL (DEFAULT) Defines the Log channel. Every channel has to have unique name. If not provided, the LOG module will use DEFAULT channel [Required/Optional] ($CHANNEL)_LOG_CHANNEL (0) Defines descriptor number of LOG channel (basically each channel should have distinct ($CHANNEL)_LOG_CHANNEL value). The value 0 is reserved for DEFAULT LOG channel [Optional] ($CHANNEL)_LOG_CHANNEL_ENABLED (1) main on/off switch of the LOG channel [Optional] ($CHANNEL)_LOG_CHANNEL_LEVEL (HAL_LOG_LEVEL) [Optional] HAL_LOG_SUBCHANNEL () Allows to create virtual subchannel over the same interface as parent channel. [Optional] ($CHANNEL)_($SUBCHANNEL)_LOG_SUBCHANNEL_ENABLED (1) main on/off switch of the LOG subchannel [Optional] ($CHANNEL)_LOG_CHANNEL_LEVEL (($CHANNEL)_LOG_CHANNEL_LEVEL)
bool HAL_LOG_SetChannelOutput | ( | const uint8_t | channel, |
IODevice const | iodev | ||
) |
Binds I/O device to log channel
[in] | channel | channel number to have I/O device assigned |
[in] | pointer | to I/O device descriptor |
bool HAL_LOG_SetChannelTimeSource | ( | const uint8_t | channel, |
HAL_LOG_Time(*)(void) | timeSourceFunction | ||
) |
Binds time source to log channel
[in] | channel | channel number to have time source assigned |
[in] | callback | that returns current system time when invoked |
bool HAL_LOG_EnableChannel | ( | const uint8_t | channel | ) |
Enables log channel output
[in] | channel | channel number to be enabled |
bool HAL_LOG_DisableChannel | ( | const uint8_t | channel | ) |
Disables log channel output
[in] | channel | v to be disabled |
bool HAL_LOG_IsChannelEnabled | ( | const uint8_t | channel | ) |
Returns information whether the channel is enabled or not
[in] | channel | channel number |