Loading...
Searching...
No Matches
esp_log.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 Gunar Schorcht
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
9#pragma once
10
21
22#ifndef DOXYGEN /* Hide implementation details from doxygen */
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#include "log.h"
29#include_next "esp_log.h"
30
31#if defined(RIOT_VERSION)
32
33#include "esp_common.h"
34
35#ifndef LOG_LOCAL_LEVEL
36#define LOG_LOCAL_LEVEL LOG_LEVEL
37#endif
38
39#define ESP_LOG_LEVEL(level, tag, format, ...) \
40 do { \
41 if ((esp_log_level_t)level==ESP_LOG_ERROR ) { \
42 ESP_LOGE(tag, format, ##__VA_ARGS__); \
43 } \
44 else if ((esp_log_level_t)level==ESP_LOG_WARN ) { \
45 ESP_LOGW(tag, format, ##__VA_ARGS__); \
46 } \
47 else if ((esp_log_level_t)level==ESP_LOG_INFO ) { \
48 ESP_LOGI(tag, format, ##__VA_ARGS__); \
49 } \
50 else if ((esp_log_level_t)level==ESP_LOG_DEBUG ) { \
51 ESP_LOGD(tag, format, ##__VA_ARGS__); \
52 } \
53 else if ((esp_log_level_t)level==ESP_LOG_VERBOSE ) { \
54 ESP_LOGV(tag, format, ##__VA_ARGS__); \
55 } \
56 } while (0)
57
58#define ESP_LOG_LEVEL_LOCAL(level, tag, format, ...) \
59 do { \
60 if ( LOG_LOCAL_LEVEL >= level ) { \
61 ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \
62 } \
63 } while (0)
64
65#define ESP_LOGE(tag, format, ...) esp_log_write((esp_log_level_t)LOG_ERROR , tag, format "\n", ##__VA_ARGS__)
66#define ESP_LOGW(tag, format, ...) esp_log_write((esp_log_level_t)LOG_WARNING, tag, format "\n", ##__VA_ARGS__)
67#define ESP_LOGI(tag, format, ...) esp_log_write((esp_log_level_t)LOG_INFO , tag, format "\n", ##__VA_ARGS__)
68#define ESP_LOGD(tag, format, ...) esp_log_write((esp_log_level_t)LOG_DEBUG , tag, format "\n", ##__VA_ARGS__)
69#define ESP_LOGV(tag, format, ...) esp_log_write((esp_log_level_t)LOG_ALL , tag, format "\n", ##__VA_ARGS__)
70
71#if MODULE_ESP_LOG_TAGGED
72
73#define ESP_DRAM_LOG_LEVEL(level, letter, tag, format, ...) \
74 do { \
75 if ((esp_log_level_t)LOG_LOCAL_LEVEL >= level ) { \
76 esp_rom_printf(DRAM_STR(LOG_FORMAT(letter, format)), \
77 system_get_time_ms(), ##__VA_ARGS__); \
78 }\
79 } while (0U)
80
81#else
82
83#define ESP_DRAM_LOG_LEVEL(level, letter, tag, format, ...) \
84 do { \
85 if ((esp_log_level_t)LOG_LOCAL_LEVEL >= level ) { \
86 esp_rom_printf(DRAM_STR(LOG_FORMAT(letter, format)), \
87 ##__VA_ARGS__); \
88 }\
89 } while (0U)
90
91#endif
92
93#define ESP_DRAM_LOGE(tag, format, ...) ESP_DRAM_LOG_LEVEL(LOG_ERROR , E, tag, format "\n", ##__VA_ARGS__)
94#define ESP_DRAM_LOGW(tag, format, ...) ESP_DRAM_LOG_LEVEL(LOG_WARNING, W, tag, format "\n", ##__VA_ARGS__)
95#define ESP_DRAM_LOGI(tag, format, ...) ESP_DRAM_LOG_LEVEL(LOG_INFO , I, tag, format "\n", ##__VA_ARGS__)
96#define ESP_DRAM_LOGD(tag, format, ...) ESP_DRAM_LOG_LEVEL(LOG_DEBUG , D, tag, format "\n", ##__VA_ARGS__)
97#define ESP_DRAM_LOGV(tag, format, ...) ESP_DRAM_LOG_LEVEL(LOG_ALL , V, tag, format "\n", ##__VA_ARGS__)
98
99#endif /* defined(RIOT_VERSION) */
100
101#ifdef __cplusplus
102}
103#endif
104
105#endif /* DOXYGEN */
Common helper macros for ESP SoCs.