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 /* 配置打印等级 TODO:每个模块可配置打印等级 */
|
|
|
|
/*
|
|
* 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 /* 不打印任何参数 */
|
|
} log_level_t;
|
|
|
|
/*******************************************************************************
|
|
* 4.Global variable extern declarations
|
|
*******************************************************************************/
|
|
|
|
/*******************************************************************************
|
|
* 5.Global function prototypes
|
|
*******************************************************************************/
|
|
void LOG_printf(const char *fmt, ...);
|
|
|
|
#endif
|