增加两个环境变量,HLOG_FLUSH_NUM和HLOG_MSG_SIZE,分别用于控制fflush文件的条数和单条log的最大长度,默认值分别为0和4096
如果有调整的需要,可以在进程运行时定义环境变量,作用范围为进程
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -11,3 +11,7 @@ build/
|
||||
core.*
|
||||
version.txt
|
||||
demo/test_handle_logger
|
||||
cmake-build-debug
|
||||
GPATH
|
||||
GRTAGS
|
||||
GTAGS
|
||||
|
||||
@@ -39,7 +39,7 @@ void call_logger(int log_num, int thread_num)
|
||||
{
|
||||
MESA_handle_runtime_log(sample_handle, RLOG_LV_INFO, "sample", "sample_handle MESA_handle_runtime_log, i = %d, thread_num = %d", i, thread_num);
|
||||
//sleep(1);
|
||||
//MESA_handle_runtime_log(test_handle, RLOG_LV_INFO, "test", "test_handle MESA_handle_runtime_log, i = %d, thread_num = %d", i, thread_num);
|
||||
MESA_handle_runtime_log(test_handle, RLOG_LV_INFO, "test", "test_handle MESA_handle_runtime_log, i = %d, thread_num = %d", i, thread_num);
|
||||
//MESA_HANDLE_RUNTIME_LOG(sample_handle, RLOG_LV_FATAL, "sample", "sample_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
||||
////sleep(1);
|
||||
//MESA_HANDLE_RUNTIME_LOG(test_handle, RLOG_LV_FATAL, "test", "test_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
#include <unistd.h>
|
||||
#include<sys/stat.h>
|
||||
|
||||
#define LOGMSG_MAX_LEN 4096
|
||||
#define FLUSH_LOG_NUM 4096
|
||||
int LOGMSG_MAX_LEN = 4096;
|
||||
int FLUSH_LOG_NUM = 0;
|
||||
typedef struct log_handle_t
|
||||
{
|
||||
int runtime_log_level;
|
||||
int flush_log_count;
|
||||
FILE *fp;
|
||||
char runtime_log_file[1200];
|
||||
char cur_log_file[LOGMSG_MAX_LEN];
|
||||
char cur_log_file[4096];
|
||||
} log_handle_t;
|
||||
|
||||
|
||||
@@ -97,7 +97,12 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level)
|
||||
{
|
||||
if(file_path == NULL)
|
||||
return NULL;
|
||||
char *max_len = getenv("HLOG_MSG_SIZE");
|
||||
char *flush_num = getenv("HLOG_FLUSH_NUM");
|
||||
|
||||
if(max_len != NULL)LOGMSG_MAX_LEN = atoi(max_len);
|
||||
if(flush_num != NULL)FLUSH_LOG_NUM = atoi(flush_num);
|
||||
|
||||
FILE *fp = NULL;
|
||||
log_handle_t *p_handle = NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user