Motion_EC_Stm32_archived/App/Src/th_elog.c

92 lines
2.3 KiB
C
Raw Normal View History

2021-03-09 18:17:28 +08:00
/*
* @Description:
* @Date: 2021-03-09 11:30:52
* @LastEditors: CK.Zh
2021-03-11 19:09:05 +08:00
* @LastEditTime: 2021-03-10 14:46:32
2021-03-09 18:17:28 +08:00
* @FilePath: \NaviKit_EC_stm32\App\Src\th_elog.c
*/
#define LOG_TAG "TH-Elog"
#include <th_elog.h>
#include "main.h"
2021-03-14 23:24:59 +08:00
//semaphore
const osSemaphoreAttr_t ElogOutputBinarySem_attributes = {
.name = "ElogOutputBinarySem"
};
2021-03-15 19:26:10 +08:00
//semaphore
const osSemaphoreAttr_t ElogUartBinarySem_attributes = {
.name = "ElogUartBinarySem"
2021-03-11 19:09:05 +08:00
};
2021-03-10 12:03:49 +08:00
const osMutexAttr_t ElogOutputMutex_attributes = {
.name = "ElogOutputMutex"
};
2021-03-14 23:24:59 +08:00
//task
2021-03-09 18:17:28 +08:00
const osThreadAttr_t ElogInitTask_attributes = {
.name = "ElogInitTask",
2021-03-11 19:09:05 +08:00
.priority = (osPriority_t) osPriorityNormal,
2021-03-10 11:03:35 +08:00
.stack_size = 128 * 4
};
const osThreadAttr_t ElogFlushTask_attributes = {
.name = "ElogFlushTask",
2021-03-15 19:26:10 +08:00
.priority = (osPriority_t) osPriorityLow1,
2021-03-14 23:24:59 +08:00
.stack_size = 256 * 4
2021-03-09 18:17:28 +08:00
};
2021-03-15 19:26:10 +08:00
void ElogInitTask(void *argument){
2021-03-09 18:17:28 +08:00
2021-03-10 11:03:35 +08:00
// my_elog_init();
2021-03-09 18:17:28 +08:00
2021-03-10 11:03:35 +08:00
// osThreadExit();//exit this thread,execute this code only once
}
2021-03-09 18:17:28 +08:00
2021-03-15 19:26:10 +08:00
//intervalbuffer flush time interval
void ElogFlushTask(uint8_t intervnal){
2021-03-09 18:17:28 +08:00
log_d("Start Log Flush Task");
2021-03-10 11:03:35 +08:00
for(;;){
elog_flush();
2021-03-15 19:26:10 +08:00
osDelay(intervnal);
2021-03-10 11:03:35 +08:00
}
2021-03-09 18:17:28 +08:00
}
2021-03-10 11:03:35 +08:00
2021-03-09 18:17:28 +08:00
void my_elog_init(){
elog_init();
/* close printf buffer */
setbuf(stdout, NULL);
2021-03-10 11:03:35 +08:00
#ifdef DEBUG //debug mode:output all information
2021-03-09 18:17:28 +08:00
ElogFmtIndex ELOG_FMT_SETTING = ELOG_FMT_ALL ;
#else //release mode :only output level、time information
ElogFmtIndex ELOG_FMT_SETTING = ELOG_FMT_LVL | ELOG_FMT_TIME;
2021-03-09 18:17:28 +08:00
#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);
2021-03-11 19:09:05 +08:00
// enable text color (dynamic)
elog_set_text_color_enabled(true);
2021-03-09 18:17:28 +08:00
/* start EasyLogger */
elog_start();
}
2021-03-15 19:26:10 +08:00
void HAL_UART1_TxCpltCallback(UART_HandleTypeDef *huart){
2021-03-15 19:26:10 +08:00
}
//void elog_set_filter(uint8_t level, const char *tag, const char *keyword);