Motion_EC_Stm32_archived/App/Src/th_elog.c

87 lines
2.8 KiB
C

/*
* @Description:
* @Date: 2021-03-09 11:30:52
* @LastEditors: CK.Zh
* @LastEditTime: 2021-03-09 17:50:24
* @FilePath: \NaviKit_EC_stm32\App\Src\th_elog.c
*/
#define LOG_TAG "TH-Elog"
#include <th_elog.h>
#include "main.h"
const osThreadAttr_t ElogInitTask_attributes = {
.name = "ElogInitTask",
.priority = (osPriority_t) osPriorityLow,
.stack_size = 128 * 4
};
void StartElogInitTask(void *argument){
elog_init();
/* close printf buffer */
setbuf(stdout, NULL);
#ifndef DEBUG //release mode :only output level、tag、time information
ElogFmtIndex ELOG_FMT_SETTING = ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME;
#else //debug mode:output all information
ElogFmtIndex ELOG_FMT_SETTING = ELOG_FMT_ALL ;
#endif
/* set EasyLogger log format */
/* 断言:输出所有内容 */
elog_set_fmt(ELOG_LVL_ASSERT, ELOG_FMT_SETTING);
/* 错误:输出级别、标签和时间 */
elog_set_fmt(ELOG_LVL_ERROR, ELOG_FMT_SETTING);
/* 警告:输出级别、标签和时间 */
elog_set_fmt(ELOG_LVL_WARN, ELOG_FMT_SETTING);
/* 信息:输出级别、标签和时间 */
elog_set_fmt(ELOG_LVL_INFO, ELOG_FMT_SETTING);
/* 调试:输出除了方法名之外的所有内容 */
elog_set_fmt(ELOG_LVL_DEBUG, ELOG_FMT_SETTING);
/* 详细:输出除了方法名之外的所有内容 */
elog_set_fmt(ELOG_LVL_VERBOSE, ELOG_FMT_SETTING);
/* start EasyLogger */
elog_start();
// log_a("Hello EasyLogger!");
// log_e("Hello EasyLogger!");
// log_w("Hello EasyLogger!");
// log_i("Hello EasyLogger!");
// log_d("Hello EasyLogger!");
// log_v("Hello EasyLogger!");
//
// osDelay(10000);
// log_d("Hello EasyLogger!");
// osThreadExit();//exit this thread,execute this code only once
}
void my_elog_init(){
elog_init();
/* close printf buffer */
setbuf(stdout, NULL);
#ifndef DEBUG //release mode :only output level、tag、time information
ElogFmtIndex ELOG_FMT_SETTING = ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME;
#else //debug mode:output all information
ElogFmtIndex ELOG_FMT_SETTING = ELOG_FMT_ALL ;
#endif
/* set EasyLogger log format */
/* 断言:输出所有内容 */
elog_set_fmt(ELOG_LVL_ASSERT, ELOG_FMT_SETTING);
/* 错误:输出级别、标签和时间 */
elog_set_fmt(ELOG_LVL_ERROR, ELOG_FMT_SETTING);
/* 警告:输出级别、标签和时间 */
elog_set_fmt(ELOG_LVL_WARN, ELOG_FMT_SETTING);
/* 信息:输出级别、标签和时间 */
elog_set_fmt(ELOG_LVL_INFO, ELOG_FMT_SETTING);
/* 调试:输出除了方法名之外的所有内容 */
elog_set_fmt(ELOG_LVL_DEBUG, ELOG_FMT_SETTING);
/* 详细:输出除了方法名之外的所有内容 */
elog_set_fmt(ELOG_LVL_VERBOSE, ELOG_FMT_SETTING);
/* start EasyLogger */
elog_start();
}