ESP32-P4 OBC Firmware
ESP-IDF firmware for Plant-B CubeSat OBC
 
Loading...
Searching...
No Matches

Topics

 ESP32 log implementation
 

Macros

#define PAL_LOGI(tag, fmt, ...)
 Log an informational message.
 
#define PAL_LOGE(tag, fmt, ...)
 Log an error message.
 
#define PAL_LOGW(tag, fmt, ...)
 Log a warning message.
 
#define PAL_LOGD(tag, fmt, ...)
 Log a debug message.
 
#define PAL_LOGV(tag, fmt, ...)
 Log a verbose message.
 
#define PAL_LOG_BUFFER_HEX(tag, buf, len, level)
 Dump a buffer as hexadecimal bytes at the specified log level.
 
#define PAL_LOG_BUFFER_HEXDUMP(tag, buf, len, level)
 Dump a buffer as a hex dump at the specified log level.
 

Enumerations

enum  pal_log_level_t {
  PAL_LOG_ERROR = 0 , PAL_LOG_WARN , PAL_LOG_INFO , PAL_LOG_DEBUG ,
  PAL_LOG_VERBOSE
}
 Log severity levels in ascending order of verbosity. More...
 

Variables

static const char * _pal_level_str [] = { "E", "W", "I", "D", "V" }
 Mapping table from pal_log_level_t to PAL log level prefixes.
 

Detailed Description

Platform-agnostic logging macros. On ESP32 targets, the macros delegate to their ESP-IDF ESP_LOGx counterparts via pal_log_esp.h. On other platforms they fall back to printf with a level prefix.

Macro Definition Documentation

◆ PAL_LOG_BUFFER_HEX

#define PAL_LOG_BUFFER_HEX ( tag,
buf,
len,
level )
Value:
do { \
const uint8_t *_b = (const uint8_t *)(buf); \
for (size_t _i = 0; _i < (len); _i += 16) { \
char _line[64]; \
int _off = 0; \
for (size_t _j = _i; _j < (len) && _j < _i + 16; _j++) \
_off += snprintf(_line + _off, sizeof(_line) - _off, "%02x ", _b[_j]); \
printf("[%s] %s: %s\n", _pal_level_str[level], tag, _line); \
} \
} while(0)
static const char * _pal_level_str[]
Mapping table from pal_log_level_t to PAL log level prefixes.
Definition pal_log.h:117

Dump a buffer as hexadecimal bytes at the specified log level.

Output is split into lines of up to 16 bytes.

Parameters
tagNull-terminated string identifying the component.
bufPointer to the buffer to dump.
lenNumber of bytes to dump.
levelLog level from pal_log_level_t.

◆ PAL_LOG_BUFFER_HEXDUMP

#define PAL_LOG_BUFFER_HEXDUMP ( tag,
buf,
len,
level )
Value:
PAL_LOG_BUFFER_HEX(tag, buf, len, level)
#define PAL_LOG_BUFFER_HEX(tag, buf, len, level)
Dump a buffer as hexadecimal bytes at the specified log level.
Definition pal_log.h:129

Dump a buffer as a hex dump at the specified log level.

On non-ESP platforms this is an alias for PAL_LOG_BUFFER_HEX. On ESP32 it delegates to ESP_LOG_BUFFER_HEXDUMP, which includes an ASCII column alongside the hex output.

Parameters
tagNull-terminated string identifying the component.
bufPointer to the buffer to dump.
lenNumber of bytes to dump.
levelLog level from pal_log_level_t.

◆ PAL_LOGD

#define PAL_LOGD ( tag,
fmt,
... )
Value:
printf("[D] %s: " fmt "\n", tag, ##__VA_ARGS__)

Log a debug message.

Parameters
[in]tagNull-terminated string identifying the component.
[in]fmtprintf-style format string.
[in]...Format arguments.

◆ PAL_LOGE

#define PAL_LOGE ( tag,
fmt,
... )
Value:
printf("[E] %s: " fmt "\n", tag, ##__VA_ARGS__)

Log an error message.

Parameters
[in]tagNull-terminated string identifying the component.
[in]fmtprintf-style format string.
[in]...Format arguments.

◆ PAL_LOGI

#define PAL_LOGI ( tag,
fmt,
... )
Value:
printf("[I] %s: " fmt "\n", tag, ##__VA_ARGS__)

Log an informational message.

Parameters
[in]tagNull-terminated string identifying the component.
[in]fmtprintf-style format string.
[in]...Format arguments.

◆ PAL_LOGV

#define PAL_LOGV ( tag,
fmt,
... )
Value:
printf("[V] %s: " fmt "\n", tag, ##__VA_ARGS__)

Log a verbose message.

Parameters
[in]tagNull-terminated string identifying the component.
[in]fmtprintf-style format string.
[in]...Format arguments.

◆ PAL_LOGW

#define PAL_LOGW ( tag,
fmt,
... )
Value:
printf("[W] %s: " fmt "\n", tag, ##__VA_ARGS__)

Log a warning message.

Parameters
[in]tagNull-terminated string identifying the component.
[in]fmtprintf-style format string.
[in]...Format arguments.

Enumeration Type Documentation

◆ pal_log_level_t

Log severity levels in ascending order of verbosity.

Enumerator
PAL_LOG_ERROR 

Critical errors that require immediate attention.

PAL_LOG_WARN 

Warnings about recoverable unexpected conditions.

PAL_LOG_INFO 

General informational messages.

PAL_LOG_DEBUG 

Detailed debug information.

PAL_LOG_VERBOSE 

Highly verbose trace-level output.

Variable Documentation

◆ _pal_level_str

const char* _pal_level_str[] = { "E", "W", "I", "D", "V" }
static

Mapping table from pal_log_level_t to PAL log level prefixes.

Indexed by pal_log_level_t values, used internally by PAL_LOG_BUFFER_HEX and PAL_LOG_BUFFER_HEXDUMP.