ESP32-P4 OBC Firmware
ESP-IDF firmware for Plant-B CubeSat OBC
 
Loading...
Searching...
No Matches
pal_log.h
Go to the documentation of this file.
1#ifndef __PAL_LOG_H__
2#define __PAL_LOG_H__
3
11
12#ifdef ESP_PLATFORM
13#include "pal_log_esp.h"
14#endif
15
16#ifndef PAL_LOGI
17#define PAL_LOGI(tag, fmt, ...) printf("[I] %s: " fmt "\n", tag, ##__VA_ARGS__)
18#endif
19
20#ifndef PAL_LOGE
21#define PAL_LOGE(tag, fmt, ...) printf("[E] %s: " fmt "\n", tag, ##__VA_ARGS__)
22#endif
23
24#ifndef PAL_LOGW
25#define PAL_LOGW(tag, fmt, ...) printf("[W] %s: " fmt "\n", tag, ##__VA_ARGS__)
26#endif
27
28#ifndef PAL_LOGD
29#define PAL_LOGD(tag, fmt, ...) printf("[D] %s: " fmt "\n", tag, ##__VA_ARGS__)
30#endif
31
32#ifndef PAL_LOGV
33#define PAL_LOGV(tag, fmt, ...) printf("[V] %s: " fmt "\n", tag, ##__VA_ARGS__)
34#endif
35
36#ifndef PAL_LOG_BUFFER_HEX
37static const char *_pal_level_str[] = { "E", "W", "I", "D", "V" };
38#define PAL_LOG_BUFFER_HEX(tag, buf, len, level) \
39 do { \
40 const uint8_t *_b = (const uint8_t *)(buf); \
41 for (size_t _i = 0; _i < (len); _i += 16) { \
42 char _line[64]; \
43 int _off = 0; \
44 for (size_t _j = _i; _j < (len) && _j < _i + 16; _j++) \
45 _off += snprintf(_line + _off, sizeof(_line) - _off, "%02x ", _b[_j]); \
46 printf("[%s] %s: %s\n", _pal_level_str[level], tag, _line); \
47 } \
48 } while(0)
49#endif
50
51#ifndef PAL_LOG_BUFFER_HEXDUMP
52#define PAL_LOG_BUFFER_HEXDUMP(tag, buf, len, level) \
53 PAL_LOG_BUFFER_HEX(tag, buf, len, level)
54#endif
55
56#endif // __PAL_LOG_H__
static const char * _pal_level_str[]
Definition pal_log.h:37
pal_log_level_t
Definition pal_log.h:4
@ PAL_LOG_ERROR
Definition pal_log.h:5
@ PAL_LOG_DEBUG
Definition pal_log.h:8
@ PAL_LOG_INFO
Definition pal_log.h:7
@ PAL_LOG_VERBOSE
Definition pal_log.h:9
@ PAL_LOG_WARN
Definition pal_log.h:6