#ifndef __OSPLOGH__ #define __OSPLOGH__ #ifdef __cplusplus extern "C" { #endif #include "ospShell.h" #define LOG_MODE_PATH "./server/logmode" #define MAX_FILE_SIZE (32*1024*1024) #define MAX_FILE_NUM (8) #define MAX_LOG_CFG_NUM (64) #define FREE_RAM_SIZE (150*1024*1024) typedef struct tag_osp_log_file_cfg_obj{ uint32_t valied; char logname[64]; uint32_t max_file_size_M; uint32_t max_file_num; uint32_t with_time; uint32_t cur_sum_len; FILE* file; uint32_t cur_file_idx; uint32_t key; uint32_t msg_type; }osp_log_file_cfg; #if 1 typedef struct OSP_LOG_MSG_INFO { int64_t i64msg_type; uint8_t *pu8msg_addr; uint32_t u32msg_size; }osp_log_msg_info_t; #endif typedef struct tMsgTransferHeader { uint8_t numMsg; uint8_t cellIndex; uint16_t rsv; uint32_t msgType; uint32_t msgLen; //uint16_t log_size; //uint16_t rsv; uint32_t log_size; uint32_t log_data[0]; } MsgTransferHeader_t; #define MSG_TRANSFER_LOG_MSG_TYPE (0x124) #define MSG_TRANSFER_SHELL_MSG_TYPE (0x125) #define SPU_LOG_CLIENT_BUF_SIZE (512) /* one log: 512Bytes */ #define SYS_LOG_MAX_LEN_OF_MESSAGE (1024) #define SYS_LOG_UDP_PORT (514) #if 0 /*SYSLOG_SERV */ #define SYSLOG_SERV_FACILITY (23) #define SYSLOG_SERV_LEVEL (7) #endif #define APE_MSG_LOG_HEAD_SIZE sizeof(osp_sw_msg_info_t) #define APE_MSG_LOG_LEN(x) (x->u16DataLen - APE_MSG_LOG_HEAD_SIZE) #define APE_MSG_LOG_HEAD_TO_COMM(x) (char *)((uint64_t)x + APE_MSG_LOG_HEAD_SIZE) OSP_STATUS osp_dbg_log(char *pbuf, uint32_t buflen); OSP_STATUS osp_dbg_log_ext(char *pbuf, uint32_t buflen, int32_t LogId); void osp_dbg_log_main(osp_sw_msg_info_t *pMsg); OSP_STATUS osp_close_log_file(FILE *fd); OSP_STATUS osp_write_diaglog(char *pbuf, uint32_t len, uint32_t logid, uint32_t msg_type); void osp_log_init(void); int32_t osp_fflush_all_logfile(void); void osp_get_current_time(void); void osp_get_msgtype_name(uint32_t msg_type, char *msg_name); /* change the log out mode: don't use pthread and msgQ */ #if 1 uint8_t osp_log_msg_create(void); int32_t osp_log_msg_get_id(void); int32_t osp_log_msg_send(int32_t i32que_id, uint8_t *pu8msg_add, uint32_t u32msg_size); int32_t osp_log_msg_recv(int32_t i32que_id, uint8_t *pu8msg_add, uint32_t u32max_size); int32_t osp_log_msg_proc(uint8_t *pu8msg_add, uint32_t u32msg_size); uint64_t osp_oam_msg_proc_task(void); #endif int32_t osp_create_oam_msg_task(uint8_t cpu, uint8_t pri); uint32_t rx_callback_oam(const char* buf,uint32_t payloadSize); uint32_t osp_get_ape_port(osp_sw_msg_info_t *pMsg); int8_t osp_log_mode_init();/*init log out mode*/ bool osp_ip_is_null(char *ip); bool osp_path_is_null(char *path); void osp_cfg_default_log_mode(void); void osp_log_mode_get(); void osp_log_cfg_reload(void); OSP_STATUS osp_ape_log_proc(osp_sw_msg_info_t *pMsg); OSP_STATUS osp_arm_log_proc(char *pbuf, uint32_t len ,uint32_t logid, uint32_t msg_type); void osp_platform_log_proc(osp_sw_msg_info_t *pMsg); void osp_net_log_proc(char *pMsg, uint32_t len, uint32_t port); uint32_t osp_filter_char(char *str, char c); int8_t osp_log_mode_cfg(void); uint32_t osp_get_freeram(void); void osp_log_output(unsigned char level, const char *fmt, ...); void osp_log_print(osp_sw_msg_info_t *pMsg); #ifdef __cplusplus } #endif #endif