84 lines
3.2 KiB
C
84 lines
3.2 KiB
C
|
/*******************************************************************************
|
|||
|
*
|
|||
|
*
|
|||
|
* File: tau_log.h
|
|||
|
* Description log file
|
|||
|
* Version V0.1
|
|||
|
* Date 2020-12-08
|
|||
|
* Author linyw
|
|||
|
*******************************************************************************/
|
|||
|
#ifndef _TAU_LOG_H_
|
|||
|
#define _TAU_LOG_H_
|
|||
|
|
|||
|
|
|||
|
/*******************************************************************************
|
|||
|
* 1.Included files
|
|||
|
*******************************************************************************/
|
|||
|
#include <stdint.h>
|
|||
|
#include <string.h>
|
|||
|
#include <stdarg.h>
|
|||
|
#include "ArmCM0.h"
|
|||
|
|
|||
|
/*******************************************************************************
|
|||
|
* 2.Global constant and macro definitions using #define
|
|||
|
*******************************************************************************/
|
|||
|
|
|||
|
#ifdef LOG_TAG
|
|||
|
#undef LOG_TAG
|
|||
|
#endif
|
|||
|
#define LOG_TAG "tau_log"
|
|||
|
#define LOG_CURREN_LEVEL kLOG_LEVEL_DBG /* <20><><EFBFBD>ô<EFBFBD>ӡ<EFBFBD>ȼ<EFBFBD> TODO:ÿ<><C3BF>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD>ӡ<EFBFBD>ȼ<EFBFBD> */
|
|||
|
|
|||
|
/*
|
|||
|
* Using the following three macros for conveniently logging.
|
|||
|
*/
|
|||
|
#if EDA_MODE
|
|||
|
#define TAU_LOGD(format,...)
|
|||
|
#define TAU_LOGI(format,...)
|
|||
|
#define TAU_LOGE(format,...)
|
|||
|
#else
|
|||
|
#define TAU_LOGD(format,...) \
|
|||
|
do { \
|
|||
|
if (LOG_CURREN_LEVEL <= kLOG_LEVEL_DBG) { \
|
|||
|
LOG_printf("[%s] (%04d) " format, LOG_TAG, __LINE__, ##__VA_ARGS__); \
|
|||
|
}; \
|
|||
|
} while (0)
|
|||
|
|
|||
|
|
|||
|
#define TAU_LOGI(format,...) \
|
|||
|
do { \
|
|||
|
if (LOG_CURREN_LEVEL <= kLOG_LEVEL_INF) { \
|
|||
|
LOG_printf("[%s] (%04d) " format, LOG_TAG, __LINE__, ##__VA_ARGS__); \
|
|||
|
}; \
|
|||
|
} while (0)
|
|||
|
|
|||
|
#define TAU_LOGE(format,...) \
|
|||
|
do { \
|
|||
|
if (LOG_CURREN_LEVEL <= kLOG_LEVEL_ERR) { \
|
|||
|
LOG_printf("error [%s] (%04d) " format, LOG_TAG, __LINE__, ##__VA_ARGS__); \
|
|||
|
}; \
|
|||
|
} while (0)
|
|||
|
#endif
|
|||
|
|
|||
|
/*******************************************************************************
|
|||
|
* 3.Global structures, unions and enumerations using typedef
|
|||
|
*******************************************************************************/
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
kLOG_LEVEL_DBG = 0,
|
|||
|
kLOG_LEVEL_INF,
|
|||
|
kLOG_LEVEL_ERR,
|
|||
|
kLOG_LEVEL_NONE /* <20><><EFBFBD><EFBFBD>ӡ<EFBFBD>κβ<CEBA><CEB2><EFBFBD> */
|
|||
|
} log_level_t;
|
|||
|
|
|||
|
/*******************************************************************************
|
|||
|
* 4.Global variable extern declarations
|
|||
|
*******************************************************************************/
|
|||
|
|
|||
|
/*******************************************************************************
|
|||
|
* 5.Global function prototypes
|
|||
|
*******************************************************************************/
|
|||
|
void LOG_printf(const char *fmt, ...);
|
|||
|
|
|||
|
#endif
|