secgateway/Platform/user/logging/logging_common.c

37 lines
917 B
C
Executable File

#include "logging_common.h"
#include "ulog_api.h"
#include "log_types.h"
#include "configm.h"
#include "configmapi.h"
#include "ulog/ulog_in.h"
int set_log_conf(cJSON *json_obj, uint64 config_id)
{
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);
ret_code ret_c = web_config_exec_sync(CM_CONFIG_SET, config_id,
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;
}
if (json != NULL) {
free(json);
}
return ret;
}