更新test_handle_log,适配更新zlog后的三个函数
This commit is contained in:
@@ -14,6 +14,7 @@ void *test_handle = NULL;
|
||||
|
||||
int g_log_num = 0;
|
||||
int g_thread_num = 0;
|
||||
const char *g_zlog_conf = NULL;
|
||||
volatile long g_start_time = 0;
|
||||
volatile long g_end_time = 0;
|
||||
|
||||
@@ -37,11 +38,11 @@ void call_logger(int log_num, int thread_num)
|
||||
}
|
||||
for(i = 0; i < log_num; i++)
|
||||
{
|
||||
MESA_handle_runtime_log(sample_handle, RLOG_LV_INFO, "sample", "sample_handle MESA_handle_runtime_log, i = %d, thread_num = %d", i, thread_num);
|
||||
MESA_handle_runtime_log(sample_handle, RLOG_LV_DEBUG, "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(sample_handle, RLOG_LV_FATAL, "sample", "sample_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
||||
////sleep(1);
|
||||
//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);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
@@ -72,35 +73,48 @@ void *thread_logger(void *arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void sig_handler(int sig)
|
||||
void sig_int_handler(int sig)
|
||||
{
|
||||
printf("ctrl+c recviced!\n");
|
||||
MESA_destroy_runtime_log_handle(sample_handle);
|
||||
MESA_destroy_runtime_log_handle(test_handle);
|
||||
sample_handle = NULL;
|
||||
test_handle = NULL;
|
||||
printf("%d thread write %d log using %ld us, avg speed %f /s, %ld -> %ld\n", g_thread_num, g_thread_num*g_log_num, g_end_time-g_start_time, ((float)(g_thread_num*g_log_num)/(float)(g_end_time-g_start_time))*1000000, g_start_time, g_end_time);
|
||||
MESA_handle_runtime_log_destruction();
|
||||
printf("%d thread write %d log using %ld us, avg speed %f /s, %ld -> %ld\n", g_thread_num, g_thread_num * g_log_num, g_end_time - g_start_time, ((float)(g_thread_num * g_log_num) / (float)(g_end_time - g_start_time)) * 1000000, g_start_time, g_end_time);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void sig_hup_handler(int sig)
|
||||
{
|
||||
printf("SIGHUP recviced!\n");
|
||||
MESA_handle_runtime_log_reconstruction(g_zlog_conf);
|
||||
}
|
||||
|
||||
int main(int argc, char ** args)
|
||||
{
|
||||
pthread_t t[MAX_THREAD_NUM];
|
||||
int i = 0;
|
||||
|
||||
if(argc != 3)
|
||||
if(argc != 4)
|
||||
{
|
||||
printf("Usage: ./($app) $thread_num $log_num \n");
|
||||
printf("Usage: ./($app) $zlog_conf_path $thread_num $log_num \n");
|
||||
return -1;
|
||||
}
|
||||
g_thread_num = atoi(args[1]);
|
||||
g_log_num = atoi(args[2]);
|
||||
g_zlog_conf = args[1];
|
||||
g_thread_num = atoi(args[2]);
|
||||
g_log_num = atoi(args[3]);
|
||||
|
||||
if(g_thread_num <= 0 || g_log_num <= 0)
|
||||
{
|
||||
printf("Error, wrong parameter!\n");
|
||||
return -1;
|
||||
}
|
||||
if(0 != MESA_handle_runtime_log_creation(g_zlog_conf))
|
||||
{
|
||||
printf("MESA_handle_runtime_log_creation return error\n");
|
||||
return -1;
|
||||
}
|
||||
sample_handle = MESA_create_runtime_log_handle("./log/sample_log", RLOG_LV_DEBUG);
|
||||
if (sample_handle == NULL)
|
||||
{
|
||||
@@ -119,7 +133,8 @@ int main(int argc, char ** args)
|
||||
{
|
||||
pthread_create(&t[i], NULL, thread_logger, (void *)(unsigned long)(i));
|
||||
}
|
||||
signal(SIGINT, sig_handler);
|
||||
signal(SIGINT, sig_int_handler);
|
||||
signal(SIGHUP, sig_hup_handler);
|
||||
while(1)
|
||||
;
|
||||
//MESA_destroy_runtime_log_handle(sample_handle);
|
||||
|
||||
Reference in New Issue
Block a user