Add aaa-12 add aysn restart rsyslog

RCA:
SOL:
修改人:zhangtao
检视人:
This commit is contained in:
zhangtaohz 2019-08-15 18:18:51 +08:00
parent 32065fc0bb
commit 62998b7bd9
3 changed files with 51 additions and 1 deletions

View File

@ -229,4 +229,36 @@ int log_off_with_file(const char *path, const char *file_name)
return ret;
}
void rpc_conf_proc(rpc_conn *conn, pointer input, int input_len, int need_len, rpc_cb cb)
{
char str_err[1024];
if (input_len < need_len) {
if (snprintf(str_err, sizeof(str_err),
"The input paramter of rpc log is needed length of %u, but the actual length is %u",
need_len, input_len) < 0) {
ULOG_ERR(g_log, "Setting error to string is failure");
return;
}
ULOG_WARNING(g_log, str_err);
goto FAIL;
}
if (cb(input, str_err, sizeof(str_err)) != 0) {
ULOG_ERR(g_log, str_err);
goto FAIL;
}
if (log_sev_restart() != 0) {
if (snprintf(str_err, sizeof(str_err),
"Restarting log service is failure") < 0) {
ULOG_ERR(g_log, "Setting error to string is failure");
return;
}
goto FAIL;
}
rpc_return_null(conn);
return;
FAIL:
rpc_return_error(conn, RET_ERR, str_err);
}

View File

@ -5,6 +5,7 @@
#include "ulog_api.h"
#include "log_types.h"
#include "rpc_conn.h"
#define LOG_CONF_PATH "/etc/rsyslog.d/"
@ -14,10 +15,13 @@
#define REDIRECT_SEPERATE " "
typedef int (*rpc_cb)(const void *arg, char *str_err, int str_len);
extern ulog_t *g_log;
extern FILE *g_conf_fp;
extern char g_conf_file[MAX_PATH_SZ];
int log_conf(const u8 level, const char *conf_path, const char *conf_file, const char *filter_mod,
int (*cb_content)(FILE *fp, const u8 level, const char *filter_mod, void *arg), void *arg);
int log_conf_append(const u8 level, const char *conf_path, const char *conf_file, const char *filter_mod,
@ -26,6 +30,6 @@ int write_conf_content(FILE *fp, const u8 level, const char *filter_mod, void *a
int write_conf_content_authorizing(FILE *fp, const u8 level, const char *filter_mod, void *arg);
int log_level_to_str(const u8 level, char *str, u32 len);
int log_off_with_file(const char *path, const char *file_name);
void rpc_conf_proc(rpc_conn *conn, pointer input, int input_len, int need_len, rpc_cb cb);
#endif

View File

@ -78,8 +78,21 @@ static int config_log_console(const log_console_t *conf)
return ret;
}
static int __rpc_conf_log_console(const void *arg, char *str_err, int str_len)
{
if (config_log_console((const log_console_t *)arg) != 0) {
strncpy(str_err, "Configuring console of log is faiure", str_len);
return -1;
}
return 0;
}
void rpc_conf_log_console(rpc_conn *conn, pointer input, int input_len, pointer data)
{
rpc_conf_proc(conn, input, input_len, sizeof(log_console_t), __rpc_conf_log_console);
/*
u32 need_len = sizeof(log_console_t);
if (input_len < need_len) {
ULOG_WARNING(g_log,
@ -95,5 +108,6 @@ void rpc_conf_log_console(rpc_conn *conn, pointer input, int input_len, pointer
}
log_sev_restart();
rpc_return_null(conn);
*/
}