UPDATE:logger2行为模式更新:
1、对于logger1的行为,默认使用snapshot文件初始化 2、对于logger2传入null或者无法访问或者错误格式的初始化profile,尝试使用null初始化,默认行为为stdout
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
#include "MESA_handle_logger.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
void *sample_handle = NULL;
|
||||
@@ -12,6 +13,7 @@ void *test_handle = NULL;
|
||||
#define LOG_NUM 100000
|
||||
#define MAX_THREAD_NUM 65535
|
||||
|
||||
int g_mode = 0;
|
||||
int g_log_num = 0;
|
||||
int g_thread_num = 0;
|
||||
const char *g_zlog_conf = NULL;
|
||||
@@ -80,7 +82,10 @@ void sig_int_handler(int sig)
|
||||
MESA_destroy_runtime_log_handle(test_handle);
|
||||
sample_handle = NULL;
|
||||
test_handle = NULL;
|
||||
MESA_handle_runtime_log_destruction();
|
||||
if (g_mode == 2)
|
||||
{
|
||||
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);
|
||||
}
|
||||
@@ -96,24 +101,28 @@ int main(int argc, char ** args)
|
||||
pthread_t t[MAX_THREAD_NUM];
|
||||
int i = 0;
|
||||
|
||||
if(argc != 4)
|
||||
if (argc != 5)
|
||||
{
|
||||
printf("Usage: ./($app) $zlog_conf_path $thread_num $log_num \n");
|
||||
printf("Usage: ./($app) $mode[1 or 2] $zlog_conf_path $thread_num $log_num \n");
|
||||
return -1;
|
||||
}
|
||||
g_zlog_conf = args[1];
|
||||
g_thread_num = atoi(args[2]);
|
||||
g_log_num = atoi(args[3]);
|
||||
g_mode = atoi(args[1]);
|
||||
g_zlog_conf = args[2];
|
||||
g_thread_num = atoi(args[3]);
|
||||
g_log_num = atoi(args[4]);
|
||||
|
||||
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))
|
||||
if (g_mode == 2)
|
||||
{
|
||||
printf("MESA_handle_runtime_log_creation return error\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)
|
||||
|
||||
Reference in New Issue
Block a user