diff --git a/.gitignore b/.gitignore index 0433f2f..647907e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,7 @@ build/ core.* version.txt demo/test_handle_logger +cmake-build-debug +GPATH +GRTAGS +GTAGS diff --git a/demo/test_handle_logger.c b/demo/test_handle_logger.c index 816d11c..448c14b 100644 --- a/demo/test_handle_logger.c +++ b/demo/test_handle_logger.c @@ -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); diff --git a/src/MESA_handle_logger.c b/src/MESA_handle_logger.c index 7e7724c..84b0612 100644 --- a/src/MESA_handle_logger.c +++ b/src/MESA_handle_logger.c @@ -8,15 +8,15 @@ #include #include -#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;