36 lines
1.1 KiB
C
36 lines
1.1 KiB
C
|
|
#ifndef _PDEBUG_H
|
|
#define _PDEBUG_H
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "uart_dev.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, ...) term_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__, '\\'); term_printf("[INFO] [%s:%d] " M "\r\n", p+1, __LINE__, ##__VA_ARGS__);}}
|
|
#define log_warn(M, ...) {if(log_warn_enable){char *p = strrchr(__FILE__, '\\'); term_printf("[WARN] [%s:%d] " M "\r\n", p+1, __LINE__, ##__VA_ARGS__);}}
|
|
#define log_error(M, ...) {if(log_error_enable){char *p = strrchr(__FILE__, '\\');term_printf("[ERROR] [%s:%d] " M "\r\n", p+1, __LINE__,##__VA_ARGS__);}}
|
|
#endif
|
|
#endif
|