2024-12-06 09:38:25 +00:00
|
|
|
|
|
|
|
#ifndef TOOLS_PDEBUG_H_
|
|
|
|
#define TOOLS_PDEBUG_H_
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2024-12-09 09:53:43 +00:00
|
|
|
#include "uart_dev.h"
|
2024-12-06 13:23:28 +00:00
|
|
|
// #include "pdebug.h"
|
2024-12-06 09:38:25 +00:00
|
|
|
|
|
|
|
/* Comment out this define to include debug messages */
|
2024-12-09 09:53:43 +00:00
|
|
|
// #define NDEBUG
|
2024-12-06 09:38:25 +00:00
|
|
|
|
|
|
|
#define log_info_enable 1
|
2025-01-08 09:50:37 +00:00
|
|
|
#define log_warn_enable 1
|
|
|
|
#define log_error_enable 1
|
2024-12-06 09:38:25 +00:00
|
|
|
|
|
|
|
/* Comment out this define to include log messages */
|
2024-12-09 09:53:43 +00:00
|
|
|
// #define NLOG
|
2024-12-06 09:38:25 +00:00
|
|
|
|
|
|
|
#ifdef NDEBUG
|
|
|
|
#define debug(M, ...) do {}while(0)
|
|
|
|
#else
|
|
|
|
#define debug(M, ...) debug_printf("%s:%d: " M "\r\n", __FILE__, __LINE__, ##__VA_ARGS__)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NLOG
|
|
|
|
#define log_err(M, ...) do {}while(0)
|
|
|
|
#define log_warn(M, ...) do {}while(0)
|
|
|
|
#define log_info(M, ...) do {}while(0)
|
|
|
|
#else
|
|
|
|
#define log_info(M, ...) {if(log_info_enable){char *p = strrchr(__FILE__, '\\'); debug_printf("[INFO] [%s:%d] " M "\r\n", p+1, __LINE__, ##__VA_ARGS__);}}
|
|
|
|
#define log_warn(M, ...) {if(log_warn_enable){char *p = strrchr(__FILE__, '\\'); debug_printf("[WARN] [%s:%d] " M "\r\n", p+1, __LINE__, ##__VA_ARGS__);}}
|
|
|
|
#define log_error(M, ...) {if(log_error_enable){char *p = strrchr(__FILE__, '\\'); debug_printf("[ERROR] [%s:%d] " M "\r\n", p+1, __LINE__,##__VA_ARGS__);}}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|