61 lines
2.8 KiB
C
61 lines
2.8 KiB
C
#include "../../include/MESA_handle_logger.h"
|
|
#define MAX_LOG_NUM 10
|
|
|
|
int test_default_conf(){
|
|
void* handle = MESA_create_runtime_log_handle_new("logger_id1");
|
|
int i = 0;
|
|
for(i = 0; i<MAX_LOG_NUM; i++){
|
|
MESA_handle_runtime_log(handle, RLOG_LV_DEBUG, "test_default_conf", "test debug log:%s", "xxxxx");
|
|
MESA_handle_runtime_log(handle, RLOG_LV_INFO, "test_default_conf", "test info log:%s", "xxxxx");
|
|
MESA_handle_runtime_log(handle, RLOG_LV_FATAL, "test_default_conf", "test fatal log:%s", "xxxxx");
|
|
}
|
|
MESA_destroy_runtime_log_handle(handle);
|
|
return 0;
|
|
}
|
|
|
|
int test_read_conf(){
|
|
void* handle = MESA_create_runtime_log_handle_new("logger_id1");
|
|
int rtn = MESA_read_runtime_log_handle_conf(handle, "./sample.conf");
|
|
if(rtn == -1){
|
|
return -1;
|
|
}
|
|
int i = 0;
|
|
for(i = 0; i<MAX_LOG_NUM; i++){
|
|
MESA_handle_runtime_log(handle, RLOG_LV_DEBUG, "test_read_conf", "test debug log:%s", "xxxxx");
|
|
MESA_handle_runtime_log(handle, RLOG_LV_INFO, "test_read_conf", "test info log:%s", "xxxxx");
|
|
MESA_handle_runtime_log(handle, RLOG_LV_FATAL, "test_read_conf", "test fatal log:%s", "xxxxx");
|
|
}
|
|
MESA_destroy_runtime_log_handle(handle);
|
|
return 0;
|
|
}
|
|
|
|
int test_set_opt(){
|
|
void* handle = MESA_create_runtime_log_handle_new("logger_id2");
|
|
MESA_set_runtime_log_handle_opt(handle, RLOG_LV_DEBUG, "enabled", "true");
|
|
MESA_set_runtime_log_handle_opt(handle, RLOG_LV_DEBUG, "to_file", "true");
|
|
MESA_set_runtime_log_handle_opt(handle, RLOG_LV_DEBUG, "to_standard_output", "true");
|
|
MESA_set_runtime_log_handle_opt(handle, RLOG_LV_DEBUG, "format", "[%level|%datetime{%Y-%M-%d %H:%m:%s}]: %msg");
|
|
MESA_set_runtime_log_handle_opt(handle, RLOG_LV_DEBUG, "file_name", "./log2/debug_log_%datetime{%Y-%M-%d}");
|
|
MESA_set_runtime_log_handle_opt(handle, RLOG_LV_INFO, "file_name", "./log2/info_log_%datetime{%Y-%M-%d}");
|
|
MESA_set_runtime_log_handle_opt(handle, RLOG_LV_FATAL, "file_name", "./log2/fatal_log_%datetime{%Y-%M-%d}");
|
|
//MESA_set_runtime_log_handle_opt(handle, RLOG_LV_DEBUG, "sub_second_precision", "6");
|
|
//MESA_set_runtime_log_handle_opt(handle, RLOG_LV_DEBUG, "performance_tracking", "true");
|
|
//MESA_set_runtime_log_handle_opt(handle, RLOG_LV_DEBUG, "max_log_file_size", "2097152");
|
|
//MESA_set_runtime_log_handle_opt(handle, RLOG_LV_DEBUG, "log_flush_threshold", "100");
|
|
int i = 0;
|
|
for(i = 0; i<MAX_LOG_NUM; i++){
|
|
MESA_handle_runtime_log(handle, RLOG_LV_DEBUG, "test_set_opt", "test debug log:%s", "xxxxx");
|
|
MESA_handle_runtime_log(handle, RLOG_LV_INFO, "test_set_opt", "test info log:%s", "xxxxx");
|
|
MESA_handle_runtime_log(handle, RLOG_LV_FATAL, "test_set_opt", "test fatal log:%s", "xxxxx");
|
|
}
|
|
MESA_destroy_runtime_log_handle(handle);
|
|
return 0;
|
|
}
|
|
|
|
int main(int argc, char* argv[]) {
|
|
test_default_conf();
|
|
test_read_conf();
|
|
test_set_opt();
|
|
return 0;
|
|
}
|