summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-05-30 22:19:46 +0700
committerhathach <[email protected]>2021-05-30 22:19:46 +0700
commiteb8ca14bf8171b48832410ed5e3f888df6564800 (patch)
treedf7ba222698a05c1f8b4af833f727c0650227dba /src
parent164778a71682559670cc2549565b4d8d5f021fa9 (diff)
add level 3 log for info, add generic TU_LOG()
Diffstat (limited to 'src')
-rw-r--r--src/common/tusb_common.h36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h
index 1ebd8dd61..6f2905697 100644
--- a/src/common/tusb_common.h
+++ b/src/common/tusb_common.h
@@ -307,25 +307,40 @@ void tu_print_var(uint8_t const* buf, uint32_t bufsize)
for(uint32_t i=0; i<bufsize; i++) tu_printf("%02X ", buf[i]);
}
-// Log with debug level 1
+// Log with Level
+#define TU_LOG(n, ...) TU_LOG##n(__VA_ARGS__)
+#define TU_LOG_MEM(n, ...) TU_LOG##n##_MEM(__VA_ARGS__)
+#define TU_LOG_VAR(n, ...) TU_LOG##n##_VAR(__VA_ARGS__)
+#define TU_LOG_INT(n, ...) TU_LOG##n##_INT(__VA_ARGS__)
+#define TU_LOG_HEX(n, ...) TU_LOG##n##_HEX(__VA_ARGS__)
+#define TU_LOG_LOCATION() tu_printf("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
+#define TU_LOG_FAILED() tu_printf("%s: %d: Failed\r\n", __PRETTY_FUNCTION__, __LINE__)
+
+
+// Log Level 1: Error
#define TU_LOG1 tu_printf
#define TU_LOG1_MEM tu_print_mem
#define TU_LOG1_VAR(_x) tu_print_var((uint8_t const*)(_x), sizeof(*(_x)))
#define TU_LOG1_INT(_x) tu_printf(#_x " = %ld\n", (uint32_t) (_x) )
#define TU_LOG1_HEX(_x) tu_printf(#_x " = %lX\n", (uint32_t) (_x) )
-#define TU_LOG1_LOCATION() tu_printf("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
-#define TU_LOG1_FAILED() tu_printf("%s: %d: Failed\r\n", __PRETTY_FUNCTION__, __LINE__)
-// Log with debug level 2
-#if CFG_TUSB_DEBUG > 1
+// Log Level 2: Warn
+#if CFG_TUSB_DEBUG >= 2
#define TU_LOG2 TU_LOG1
#define TU_LOG2_MEM TU_LOG1_MEM
#define TU_LOG2_VAR TU_LOG1_VAR
#define TU_LOG2_INT TU_LOG1_INT
#define TU_LOG2_HEX TU_LOG1_HEX
- #define TU_LOG2_LOCATION() TU_LOG1_LOCATION()
#endif
+// Log Level 3: Info
+#if CFG_TUSB_DEBUG >= 3
+ #define TU_LOG3 TU_LOG1
+ #define TU_LOG3_MEM TU_LOG1_MEM
+ #define TU_LOG3_VAR TU_LOG1_VAR
+ #define TU_LOG3_INT TU_LOG1_INT
+ #define TU_LOG3_HEX TU_LOG1_HEX
+#endif
typedef struct
{
@@ -370,6 +385,15 @@ static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint3
#define TU_LOG2_LOCATION()
#endif
+#ifndef TU_LOG3
+ #define TU_LOG3(...)
+ #define TU_LOG3_MEM(...)
+ #define TU_LOG3_VAR(...)
+ #define TU_LOG3_INT(...)
+ #define TU_LOG3_HEX(...)
+ #define TU_LOG3_LOCATION()
+#endif
+
#ifdef __cplusplus
}
#endif