支持输出日志到指定目录

This commit is contained in:
guo_peixu
2022-06-22 09:44:55 +08:00
parent 93c07a240b
commit 3421f97f95
6 changed files with 1004 additions and 78 deletions

View File

@@ -2,13 +2,15 @@
#define _MESA_SHM_RING_QUEUE_H_
#include <pthread.h>
#define MESA_SHM_LOG_PATH_LEN 1024
#define MESA_SHM_RING_QUEUE_NUM 128
#define MESA_SHM_RING_QUEUE_BLOCK_NUM 8192
#define MESA_SHM_RING_QUEUE_BLOCK_BUFLEN 4096
#define MESA_SHM_RING_QUEUE_BLOCK_SIZE (MESA_SHM_RING_QUEUE_BLOCK_BUFLEN + sizeof(int) + 1) /*user buf + (int)len flag + '\n'*/
#define MESA_SHM_RING_QUEUE_BLOCK_SIZE (MESA_SHM_LOG_PATH_LEN + sizeof(int) + MESA_SHM_RING_QUEUE_BLOCK_BUFLEN) /*log file + (int)payload len + payload*/
#define MESA_SHM_KEY_OVERVIEW 35720
#define MESA_SHM_KEY_MIN (MESA_SHM_KEY_OVERVIEW + 1)
#define MESA_SHM_KEY_MAX (MESA_SHM_KEY_MIN + MESA_SHM_RING_QUEUE_NUM -1)
#define MESA_SHM_LOG_BUF_PREFIX_LEN 1024
#define MESA_SHM_RING_QUEUE_INITIAL 0
#define MESA_SHM_RING_QUEUE_IDLE 1
@@ -20,8 +22,9 @@ struct MESA_shm_queue_head *MESA_shm_get_ring_queue();
void MESA_shm_init_mutex();
void MESA_shm_init_overview();
void MESA_shm_recycle_ring_queue(struct MESA_shm_queue_head *ring_queue_head);
int MESA_shm_copy_buf_to_ring_queue(char *buf, int buflen, struct MESA_shm_queue_head *head);
void MESA_shm_write_ring_queue_to_file(int fd, struct MESA_shm_queue_head *head);
int MESA_shm_copy_buf_to_ring_queue(char *buf, int buflen, struct MESA_shm_queue_head *head, char *log_file, int log_file_len);
int MESA_shm_ring_queue_is_empty(struct MESA_shm_queue_head *head);
int MESA_shm_ring_queue_is_full(struct MESA_shm_queue_head *head);
@@ -29,6 +32,7 @@ struct MESA_shm_overview{
int shmkey;
int shmid;
int idx;
int producer_pid;
pthread_mutex_t mutex;
};