44 lines
1.2 KiB
C
44 lines
1.2 KiB
C
|
/*
|
|||
|
* pdebug.h
|
|||
|
*
|
|||
|
* Created on: 2024<EFBFBD><EFBFBD>6<EFBFBD><EFBFBD>27<EFBFBD><EFBFBD>
|
|||
|
* Author: psx
|
|||
|
*/
|
|||
|
|
|||
|
#ifndef APP_INC_PDEBUG_H_
|
|||
|
#define APP_INC_PDEBUG_H_
|
|||
|
|
|||
|
#include <stdio.h>
|
|||
|
#include <string.h>
|
|||
|
#include "uart_dev.h"
|
|||
|
#include "debug.h"
|
|||
|
|
|||
|
/* Comment out this define to include debug messages */
|
|||
|
//#define NDEBUG
|
|||
|
|
|||
|
#define log_info_enable 1
|
|||
|
#define log_warn_enable 1
|
|||
|
#define log_error_enable 1
|
|||
|
|
|||
|
|
|||
|
/* Comment out this define to include log messages */
|
|||
|
//#define NLOG
|
|||
|
|
|||
|
#ifdef NDEBUG
|
|||
|
#define debug(M, ...) do {}while(0)
|
|||
|
#else
|
|||
|
#define debug(M, ...) 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__, '\\'); printf("[INFO] [%s:%d] " M "\r\n", p+1, __LINE__, ##__VA_ARGS__);}}
|
|||
|
#define log_warn(M, ...) {if(log_warn_enable){char *p = strrchr(__FILE__, '\\'); printf("[WARN] [%s:%d] " M "\r\n", p+1, __LINE__, ##__VA_ARGS__);}}
|
|||
|
#define log_error(M, ...) {if(log_error_enable){char *p = strrchr(__FILE__, '\\'); printf("[ERROR] [%s:%d] " M "\r\n", p+1, __LINE__,##__VA_ARGS__);}}
|
|||
|
#endif
|
|||
|
|
|||
|
#endif /* APP_INC_PDEBUG_H_ */
|