From 933b3d6c34847d9c3b55f3a4062914ace755830d Mon Sep 17 00:00:00 2001 From: "lishuang.xie" Date: Wed, 27 Sep 2023 18:21:49 +0800 Subject: [PATCH] fixed New Feature#1093# 1. modify ospLog.c 2. naming rule: coreId_index_msgtype.log 3. testcase: 3.1 spu(case34)+arm(case5): pass 3.2 spu(case44)+arm(case5): pass 3.3 spu(case21)+arm(case21):pass 3.4 spu(case14)+arm(case3): pass --- osp/src/ospLog.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/osp/src/ospLog.c b/osp/src/ospLog.c index 3c6208a..4b55b3d 100644 --- a/osp/src/ospLog.c +++ b/osp/src/ospLog.c @@ -202,14 +202,14 @@ OSP_STATUS osp_update_log(uint32_t len, uint32_t logid, uint32_t msg_type) char path[150] = {0}; char msg_name[10] = {0}; int32_t file_idx = 0; - uint32_t type = 0; + uint32_t type = 0; //uint32_t ulfreeram = 0; - + if (logid >= MAX_LOG_CFG_NUM || logid < 0) { return OSP_ERROR; } - + osp_get_msgtype_name(msg_type, msg_name); type = osp_get_msgtype_id(msg_type); if (log_file_cfg_table[logid][type].valied == 0) @@ -233,7 +233,7 @@ OSP_STATUS osp_update_log(uint32_t len, uint32_t logid, uint32_t msg_type) UCP_PRINT_LOG("osp_update_log line:%d logid:%d type:0x%x g_ucFflushEnable:%u name:%s\n", __LINE__, logid, type, g_ucFflushEnable, name); osp_log_cfg_reload(); } - + if (p_log_file_cfg[logid][type].cur_sum_len >= p_log_file_cfg[logid][type].max_file_size_M) { p_log_file_cfg[logid][type].cur_sum_len = 0; @@ -241,16 +241,18 @@ OSP_STATUS osp_update_log(uint32_t len, uint32_t logid, uint32_t msg_type) file_idx = p_log_file_cfg[logid][type].cur_file_idx & 0x7; if(p_log_file_cfg[logid][type].cur_file_idx >= p_log_file_cfg[logid][type].max_file_num) - { - sprintf(name, "rm -rf %s%u-%u-%s.log", p_log_file_cfg[logid][type].logname, file_idx, logid, msg_name); + { + /* naming rule: coreid-index-type.log */ + sprintf(name, "rm -rf %s%u-%u-%s.log", p_log_file_cfg[logid][type].logname, logid, file_idx, msg_name); + //sprintf(name, "rm -rf %s%u-%u-%s.log", p_log_file_cfg[logid][type].logname, file_idx, logid, msg_name); //sprintf(name, "%s-%d-%s-%u-%u-%s.log", p_log_file_cfg[logid][type].logname, getpid(), g_time_now, p_log_file_cfg[logid][type].cur_file_idx, logid, msg_name); system(name); UCP_PRINT_LOG("osp_update_log line:%d logid:%d type:0x%x remove name:%s\n", __LINE__, logid, type, name); } - + /*判断当前文件是否合法文件*/ if(NULL == p_log_file_cfg[logid][type].file) - { + { UCP_PRINT_LOG("osp_update_log line:%d logid:%d type:%d file:%p\n", __LINE__, logid, type, p_log_file_cfg[logid][type].file); return OSP_ERROR; } @@ -261,16 +263,17 @@ OSP_STATUS osp_update_log(uint32_t len, uint32_t logid, uint32_t msg_type) if (access(path, F_OK) != 0) { - osp_mkdirs(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + osp_mkdirs(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); } - - sprintf(name, "%s%u-%u-%s.log", p_log_file_cfg[logid][type].logname, file_idx, logid, msg_name); + + /* naming rule: coreid-index-type.log */ + sprintf(name, "%s%u-%u-%s.log", p_log_file_cfg[logid][type].logname, logid, file_idx, msg_name); //sprintf(name, "%s-%d-%s-%u-%u-%s.log", p_log_file_cfg[logid][type].logname, getpid(), g_time_now, p_log_file_cfg[logid][type].cur_file_idx, logid, msg_name); UCP_PRINT_LOG("osp_update_log line:%d logid:%d type:0x%x name:%s\n", __LINE__, logid, type, name); /*二进制格式*/ if(0x61 == msg_type) - { + { p_log_file_cfg[logid][type].file = fopen(name, "wb+"); /*判断文件是否创建成功*/ if(p_log_file_cfg[logid][type].file <= 0) @@ -280,7 +283,7 @@ OSP_STATUS osp_update_log(uint32_t len, uint32_t logid, uint32_t msg_type) } } else - { + { p_log_file_cfg[logid][type].file = fopen(name, "w+"); /*判断文件是否创建成功*/ if(p_log_file_cfg[logid][type].file <= 0) @@ -299,10 +302,12 @@ OSP_STATUS osp_update_log(uint32_t len, uint32_t logid, uint32_t msg_type) if (access(path, F_OK) != 0) { - osp_mkdirs(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + osp_mkdirs(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); } - - sprintf(name, "%s%u-%u-%s.log", p_log_file_cfg[logid][type].logname, p_log_file_cfg[logid][type].cur_file_idx, logid, msg_name); + + /* naming rule: coreid-index-type.log */ + sprintf(name, "%s%u-%u-%s.log", p_log_file_cfg[logid][type].logname, logid, p_log_file_cfg[logid][type].cur_file_idx, msg_name); + //sprintf(name, "%s%u-%u-%s.log", p_log_file_cfg[logid][type].logname, p_log_file_cfg[logid][type].cur_file_idx, logid, msg_name); //sprintf(name, "%s-%d-%s-%u-%u-%s.log", p_log_file_cfg[logid][type].logname, getpid(), g_time_now, p_log_file_cfg[logid][type].cur_file_idx, logid, msg_name); UCP_PRINT_LOG("osp_update_log line:%d logid:%d type:0x%x name:%s\n", __LINE__, logid, type, name); @@ -318,7 +323,7 @@ OSP_STATUS osp_update_log(uint32_t len, uint32_t logid, uint32_t msg_type) } } else - { + { p_log_file_cfg[logid][type].file = fopen(name, "w+"); /*判断文件是否创建成功*/ if(p_log_file_cfg[logid][type].file <= 0)