2019-10-22 15:13:14 +08:00
|
|
|
/*************************************************************************
|
|
|
|
|
> File Name: logging.c
|
|
|
|
|
> Author:
|
|
|
|
|
> Mail:
|
|
|
|
|
> Created Time: 2018年06月18日 星期一 22时45分43秒
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <pwd.h>
|
|
|
|
|
#include <dirent.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
|
|
#include "verify_policy_logging.h"
|
2020-06-22 15:15:52 +08:00
|
|
|
#include <MESA/MESA_prof_load.h>
|
|
|
|
|
#include <MESA/MESA_handle_logger.h>
|
|
|
|
|
|
2019-10-22 15:13:14 +08:00
|
|
|
|
|
|
|
|
RTLogInit2Data logging_sc_lid;
|
|
|
|
|
|
|
|
|
|
void mesa_logging_print(int log_level, const char *module, const char *msg)
|
|
|
|
|
{
|
|
|
|
|
MESA_handle_runtime_log(logging_sc_lid.run_log_handle, log_level, (const char *)module, msg);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void * verify_syslog_init(const char *config)
|
|
|
|
|
{
|
|
|
|
|
|
2020-09-28 16:59:41 +08:00
|
|
|
MESA_load_profile_int_def(config, (const char *)"SYSTEM",(const char *)"DEBUG_SWITCH",
|
|
|
|
|
&logging_sc_lid.debug_switch, 1);
|
|
|
|
|
MESA_load_profile_string_def(config, (const char *)"SYSTEM",(const char *)"RUN_LOG_PATH",
|
|
|
|
|
logging_sc_lid.run_log_path, 128, "conf/zlog.conf");
|
2019-10-22 15:13:14 +08:00
|
|
|
|
2020-09-28 16:59:41 +08:00
|
|
|
if (0 != MESA_handle_runtime_log_creation(logging_sc_lid.run_log_path))
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Create log runtime_log_handle error, init failed\n");
|
|
|
|
|
goto finish;
|
|
|
|
|
}
|
2019-10-22 15:13:14 +08:00
|
|
|
|
2022-02-28 14:53:04 +08:00
|
|
|
logging_sc_lid.run_log_handle = MESA_create_runtime_log_handle("verify_policy", RLOG_LV_DEBUG);
|
2019-10-22 15:13:14 +08:00
|
|
|
if(logging_sc_lid.run_log_handle == NULL){
|
|
|
|
|
mesa_runtime_log(RLOG_LV_FATAL, MODULE_NAME, "Create log runtime_log_handle error, init failed!");
|
|
|
|
|
goto finish;
|
|
|
|
|
}else{
|
|
|
|
|
mesa_runtime_log(RLOG_LV_INFO, MODULE_NAME, "Log module initialization");
|
|
|
|
|
}
|
2020-01-09 14:32:00 +08:00
|
|
|
|
|
|
|
|
mesa_runtime_log(RLOG_LV_INFO, MODULE_NAME, "%s:%d", "Log level", logging_sc_lid.run_log_level);
|
|
|
|
|
mesa_runtime_log(RLOG_LV_INFO, MODULE_NAME, "%s:%s", "Log Directory", logging_sc_lid.run_log_path);
|
|
|
|
|
|
2019-10-22 15:13:14 +08:00
|
|
|
return logging_sc_lid.run_log_handle;
|
|
|
|
|
finish:
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|