secgateway/Platform/user/ulog/log-sched/log_remote.c

40 lines
1.1 KiB
C
Raw Normal View History

#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include <syslog.h>
#include "log_remote.h"
#include "log_common.h"
#define LOG_CONF_REMOTE_FILE_NAME "log-remote.conf"
static int config_log_remote_host(const log_remote_host_t *conf)
{
char redirect[MAX_LINE_SZ];
if (snprintf(redirect, sizeof(redirect), "@%s:%u", conf->host, conf->port) < 0) {
ULOG_ERR(g_log, "Setting remote redirect[%s:%u] is faulure", conf->host, conf->port);
return 1;
}
log_conf_append(7, LOG_CONF_PATH, LOG_CONF_REMOTE_FILE_NAME, NULL,
write_conf_content, (void *)redirect);
return 0;
}
void rpc_conf_log_remote(rpc_conn *conn, pointer input, int input_len, pointer data)
{
u32 need_len = sizeof(log_remote_host_t);
if (input_len < need_len) {
ULOG_WARNING(g_log,
"The input paramter of rpc log remote host is needed length of %u, but the actual length is %u",
need_len, input_len);
return;
}
config_log_remote_host((const log_remote_host_t *)input);
}