2019-08-12 10:12:53 +00:00
|
|
|
#include "logging_common.h"
|
|
|
|
#include "ulog_api.h"
|
|
|
|
#include "log_types.h"
|
|
|
|
#include "configm.h"
|
|
|
|
#include "configmapi.h"
|
|
|
|
#include "ulog/ulog_in.h"
|
|
|
|
|
2019-08-27 00:49:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, cJSON **json_output)
|
2019-08-12 10:12:53 +00:00
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
char *output;
|
|
|
|
int output_len;
|
|
|
|
|
|
|
|
char *json = cJSON_PrintUnformatted(json_obj);
|
|
|
|
if (json == NULL) {
|
|
|
|
ULOG_ERR(g_log, "Converting struct to json is failure");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULOG_DEBUG(g_log, "Setting log json is %s", json);
|
2019-08-27 00:49:47 +00:00
|
|
|
|
|
|
|
ret_code ret_c = web_config_exec_sync(config_type, config_id,
|
2019-08-12 10:12:53 +00:00
|
|
|
json, strlen(json),
|
|
|
|
&output, &output_len);
|
|
|
|
if (ret_c != RET_OK) {
|
|
|
|
ULOG_ERR(g_log, "Log of Web config is failure:%d", ret_c);
|
|
|
|
} else {
|
|
|
|
ret = 0;
|
|
|
|
}
|
2019-08-27 00:49:47 +00:00
|
|
|
|
|
|
|
if ((CM_CONFIG_GET == config_type || CM_CONFIG_GET_ALL == config_type) && json_output != NULL)
|
|
|
|
{
|
|
|
|
ULOG_DEBUG(g_log, "get outputlen:%d, output:%s", output_len, output);
|
|
|
|
*json_output = output;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*json_output = NULL;
|
|
|
|
}
|
2019-08-12 10:12:53 +00:00
|
|
|
|
|
|
|
if (json != NULL) {
|
|
|
|
free(json);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-08-27 00:49:47 +00:00
|
|
|
|
|
|
|
int logging_terminal_json_parse(pointer input, pointer config_buff, int conf_id)
|
|
|
|
{
|
|
|
|
cJSON *json_obj = NULL;
|
|
|
|
|
|
|
|
if (NULL == config_buff) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
json_obj = cJSON_Parse(input);
|
|
|
|
if (!json_obj)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
s2j_create_struct_obj(log_terminal, log_console_t);
|
|
|
|
if (NULL == log_terminal)
|
|
|
|
{
|
|
|
|
cJSON_Delete(json_obj);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
s2j_struct_get_basic_element(log_terminal, json_obj, int, level);
|
|
|
|
s2j_struct_get_basic_element(log_terminal, json_obj, int, on);
|
|
|
|
s2j_struct_get_basic_element(log_terminal, json_obj, string, module);
|
|
|
|
|
|
|
|
memcpy(config_buff, log_terminal, sizeof(log_console_t));
|
|
|
|
|
|
|
|
s2j_delete_struct_obj(json_obj);
|
|
|
|
cJSON_Delete(json_obj);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|