log_module.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 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 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #include <stdio.h>
26 #include "esp_common_log.h"
27 
28 #ifdef MODULE_LOG_PRINTFNOFORMAT
29 
30 static inline void log_write(unsigned level, const char *format, ...) {
31  (void)level;
32  puts(format);
33 }
34 
35 #else /* MODULE_LOG_PRINTFNOFORMAT */
36 
37 #define log_write(level, ...) \
38  do { \
39  if (level == LOG_ERROR) { \
40  LOG_TAG(LOG_ERROR, E, __func__, ##__VA_ARGS__); \
41  } \
42  else if (level == LOG_WARNING) { \
43  LOG_TAG(LOG_WARNING, W, __func__, ##__VA_ARGS__); \
44  } \
45  else if (level == LOG_INFO) { \
46  LOG_TAG(LOG_INFO, D, __func__, ##__VA_ARGS__); \
47  } \
48  else if (level == LOG_DEBUG) { \
49  LOG_TAG(LOG_DEBUG, E, __func__, ##__VA_ARGS__); \
50  } \
51  } while (0U)
52 
53 #endif /* MODULE_LOG_PRINTFNOFORMAT */
54 
55 #ifdef __cplusplus
56 }
57 #endif
Common log macros for ESP SoCs.
void log_write(unsigned level, const char *format,...)
log_write overridden function for colored output