Add aaa-12 add log configure manager
RCA: SOL: 修改人:zhangtao 检视人:
This commit is contained in:
parent
08f496cbc5
commit
dd6153aac3
|
@ -34,13 +34,14 @@ COMMON_SRCS = configserver.c \
|
||||||
jumppage_config/jumppage.c \
|
jumppage_config/jumppage.c \
|
||||||
agingtime_config/agingtime.c \
|
agingtime_config/agingtime.c \
|
||||||
user_manager_config/user_group_config.c user_manager_config/user_account_config.c user_manager_config/usermanager-server/array_index.c \
|
user_manager_config/user_group_config.c user_manager_config/user_account_config.c user_manager_config/usermanager-server/array_index.c \
|
||||||
user_manager_config/usermanager-server/user_group.c user_manager_config/usermanager-server/user_mod.c user_manager_config/usermanager-server/user.c
|
user_manager_config/usermanager-server/user_group.c user_manager_config/usermanager-server/user_mod.c user_manager_config/usermanager-server/user.c \
|
||||||
|
log_config/log_config_console.c log_config/log_config_init.c
|
||||||
|
|
||||||
# MRS Board Source Files
|
# MRS Board Source Files
|
||||||
PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
||||||
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
||||||
|
|
||||||
COMMOM_CFLAGS = -I../user/configm/config-server/include -I../../Common -I../common/redismq -I../common/configm -I../common/rpc -I../common/rpc/hashtable
|
COMMOM_CFLAGS = -I../user/configm/config-server/include -I../../Common -I../common/redismq -I../common/configm -I../common/rpc -I../common/rpc/hashtable -I../common/ulog
|
||||||
# gcc CFLAGS
|
# gcc CFLAGS
|
||||||
PLAT_ARM64_CFLAGS := $(COMMOM_CFLAGS) -I../thirdparty/arm64/usr/local/include
|
PLAT_ARM64_CFLAGS := $(COMMOM_CFLAGS) -I../thirdparty/arm64/usr/local/include
|
||||||
PLAT_LINUX_CFLAGS := $(COMMOM_CFLAGS) -I../thirdparty/x86_64/usr/local/include
|
PLAT_LINUX_CFLAGS := $(COMMOM_CFLAGS) -I../thirdparty/x86_64/usr/local/include
|
||||||
|
@ -49,10 +50,10 @@ PLAT_ARM64_LDFLAGS :=
|
||||||
PLAT_LINUX_LDFLAGS :=
|
PLAT_LINUX_LDFLAGS :=
|
||||||
|
|
||||||
#gcc libs
|
#gcc libs
|
||||||
ARM64_LIBS := ../thirdparty/arm64/libev-arm64.so ./libopenrpc-arm64.so ./libnetlinku-arm64.so ./libredismq-arm64.so
|
ARM64_LIBS := ../thirdparty/arm64/libev-arm64.so ./libopenrpc-arm64.so ./libnetlinku-arm64.so ./libredismq-arm64.so ./libulogapi-arm64.so
|
||||||
ARM64_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis
|
ARM64_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis
|
||||||
|
|
||||||
LINUX_LIBS := ../thirdparty/x86_64/libev-linux.so ./libopenrpc-linux.so ./libnetlinku-linux.so ./libredismq-linux.so
|
LINUX_LIBS := ../thirdparty/x86_64/libev-linux.so ./libopenrpc-linux.so ./libnetlinku-linux.so ./libredismq-linux.so ./libulogapi-linux.so
|
||||||
LINUX_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis
|
LINUX_LIBS += -lpthread -lm -lcjson -levent -ljson-c -lhiredis
|
||||||
|
|
||||||
ifeq ($(PLAT_ARM64), TRUE)
|
ifeq ($(PLAT_ARM64), TRUE)
|
||||||
|
|
|
@ -34,7 +34,7 @@ PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
||||||
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
||||||
|
|
||||||
# gcc CFLAGS
|
# gcc CFLAGS
|
||||||
PLAT_ARM64_CFLAGS := -fPIC -I../../Common -I../common/rpc -I../user/ulog
|
PLAT_ARM64_CFLAGS := -fPIC -I../../Common -I../common/rpc -I../common/ulog -I../user/ulog
|
||||||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef _ULOG_IN_H
|
||||||
|
#define _ULOG_IN_H
|
||||||
|
|
||||||
|
#define SERVICE_LOG_FILE_NAME "log-file"
|
||||||
|
#define SERIVCE_LOG_CONSOLE_NAME "log-console"
|
||||||
|
#define SERVICE_LOG_PTY_NAME "log-pty"
|
||||||
|
#define SERVICE_LOG_REMOTE_NAME "log-remote"
|
||||||
|
|
||||||
|
#define CONF_LOG_CONSOLE_FUNC "conf_log_console"
|
||||||
|
|
||||||
|
#endif
|
|
@ -7,6 +7,7 @@
|
||||||
#include "../../../../../Common/commuapinl.h"
|
#include "../../../../../Common/commuapinl.h"
|
||||||
#include "../user_manager_config/user_group_config.h"
|
#include "../user_manager_config/user_group_config.h"
|
||||||
#include "../user_manager_config/user_account_config.h"
|
#include "../user_manager_config/user_account_config.h"
|
||||||
|
#include "log_config.h"
|
||||||
#include "authfree.h"
|
#include "authfree.h"
|
||||||
#include "localportal.h"
|
#include "localportal.h"
|
||||||
#include "jumppage.h"
|
#include "jumppage.h"
|
||||||
|
@ -24,6 +25,9 @@
|
||||||
/*PORTAL SERVER CONFIG */
|
/*PORTAL SERVER CONFIG */
|
||||||
#define LOCALAUTH_CONFIG_MODULE 0x00000003
|
#define LOCALAUTH_CONFIG_MODULE 0x00000003
|
||||||
|
|
||||||
|
#define LOG_CONFIG_MODULE 0x00000004
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* config id define*/
|
/* config id define*/
|
||||||
#define IPCONFIG_V4 (uint64)((uint64)NETCONFIG_MODULE<<32|1)
|
#define IPCONFIG_V4 (uint64)((uint64)NETCONFIG_MODULE<<32|1)
|
||||||
|
@ -37,12 +41,18 @@
|
||||||
#define JUMPPAGE_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|4)
|
#define JUMPPAGE_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|4)
|
||||||
#define AGINGTIME_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|5)
|
#define AGINGTIME_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|5)
|
||||||
|
|
||||||
|
#define LOG_CONFIG_CONSOLE (uint64)((uint64)LOG_CONFIG_MODULE<<32|1)
|
||||||
|
|
||||||
#define CONFIG_INIT_ARRAY \
|
#define CONFIG_INIT_ARRAY \
|
||||||
{\
|
{\
|
||||||
{\
|
{\
|
||||||
NETCONFIG_MODULE,\
|
NETCONFIG_MODULE,\
|
||||||
NULL\
|
NULL\
|
||||||
}\
|
},\
|
||||||
|
{ \
|
||||||
|
LOG_CONFIG_MODULE, \
|
||||||
|
log_config_init \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -137,6 +147,16 @@
|
||||||
user_config_proc, \
|
user_config_proc, \
|
||||||
user_config_get, \
|
user_config_get, \
|
||||||
user_config_get_all \
|
user_config_get_all \
|
||||||
|
},\
|
||||||
|
{\
|
||||||
|
LOG_CONFIG_CONSOLE, \
|
||||||
|
CONFIG_FROM_WEB, \
|
||||||
|
FALSE, \
|
||||||
|
FALSE, \
|
||||||
|
log_console_config_chk, \
|
||||||
|
log_console_config_proc, \
|
||||||
|
NULL, \
|
||||||
|
NULL \
|
||||||
}\
|
}\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef _LOG_CONFIG_H
|
||||||
|
#define _LOG_CONFIG_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "rpc_types.h"
|
||||||
|
#include "rpc_common.h"
|
||||||
|
|
||||||
|
ret_code log_config_init();
|
||||||
|
ret_code log_console_config_chk(uint source, uint *config_type,
|
||||||
|
pointer input, int *input_len,
|
||||||
|
pointer output, int *output_len);
|
||||||
|
ret_code log_console_config_proc(uint source, uint config_type,
|
||||||
|
pointer input, int input_len,
|
||||||
|
pointer output, int *output_len);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,63 @@
|
||||||
|
#include <cjson/cJSON.h>
|
||||||
|
|
||||||
|
#include "rpc_server.h"
|
||||||
|
#include "log_config.h"
|
||||||
|
#include "configm.h"
|
||||||
|
#include "log_types.h"
|
||||||
|
#include "ulog_in.h"
|
||||||
|
#include "log_config_h.h"
|
||||||
|
|
||||||
|
ret_code log_console_config_chk(uint source, uint *config_type,
|
||||||
|
pointer input, int *input_len,
|
||||||
|
pointer output, int *output_len)
|
||||||
|
{
|
||||||
|
if (input == NULL) {
|
||||||
|
ULOG_ERR(g_log_h, "input can't null");
|
||||||
|
return RET_INPUTERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON *json_obj = cJSON_Parse(input);
|
||||||
|
if(!json_obj)
|
||||||
|
{
|
||||||
|
ULOG_ERR(g_log_h, "Error log console format");
|
||||||
|
return RET_INPUTERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULOG_DEBUG("json input: %s", cJSON_Print(json_obj));
|
||||||
|
|
||||||
|
s2j_create_struct_obj(log_console, log_console_t);
|
||||||
|
if(log_console == NULL)
|
||||||
|
{
|
||||||
|
cJSON_Delete(json_obj);
|
||||||
|
ULOG_ERR(g_log_h, "Creating log console of object is failure");
|
||||||
|
return RET_NOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
s2j_struct_get_basic_element(log_console, json_obj, int, level);
|
||||||
|
s2j_struct_get_basic_element(log_console, json_obj, int, on);
|
||||||
|
S2J_STRUCT_GET_STRING_ELEMENT_N(log_console, json_obj, module_name, MAX_MODULE_NAME_SZ);
|
||||||
|
|
||||||
|
*input_len = sizeof(*log_console);
|
||||||
|
memcpy(input, log_console, *input_len);
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret_code log_console_config_proc(uint source, uint config_type,
|
||||||
|
pointer input, int input_len,
|
||||||
|
pointer output, int *output_len)
|
||||||
|
{
|
||||||
|
if ((input == NULL)
|
||||||
|
&& input_len < sizeof(log_console_t)) {
|
||||||
|
return RET_INPUTERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret_code ret = rpc_client_call(g_log_client, SERIVCE_LOG_CONSOLE_NAME,
|
||||||
|
CONF_LOG_CONSOLE_FUNC, input, input_len, NULL, NULL);
|
||||||
|
if (ret != RET_OK) {
|
||||||
|
ULOG_ERR(g_log_h, "rpc call is failure[ret:%u, method:%s]", ret, CONF_LOG_CONSOLE_FUNC);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef _LOG_CONFIG_H_H
|
||||||
|
#define _LOG_CONFIG_H_H
|
||||||
|
|
||||||
|
extern rpc_client *g_log_client;
|
||||||
|
extern ulog_t *g_log_h;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,27 @@
|
||||||
|
#include "rpc_server.h"
|
||||||
|
#include "log_config.h"
|
||||||
|
#include "ulog_in.h"
|
||||||
|
#include "ulog_api.h"
|
||||||
|
|
||||||
|
rpc_client *g_log_client;
|
||||||
|
ulog_t *g_log_h;
|
||||||
|
|
||||||
|
|
||||||
|
ret_code log_config_init()
|
||||||
|
{
|
||||||
|
g_log_h = ulog_init("log_config", 1);
|
||||||
|
if (g_log_h) {
|
||||||
|
fprintf(stderr, "Initiating log_config is failure");
|
||||||
|
return RET_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_log_client = rpc_client_connect_ex(RPC_MODULE_SYSLOG_NAME);
|
||||||
|
if (g_log_client == NULL) {
|
||||||
|
ULOG_ERR(g_log_h, "Initiating rpc client is failure");
|
||||||
|
return RET_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ int log_conf_append(const u8 level, const char *conf_path, const char *conf_file
|
||||||
return __log_conf("a", level, conf_path, conf_file, filter_mod, cb_content, arg);
|
return __log_conf("a", level, conf_path, conf_file, filter_mod, cb_content, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int log_level_to_str(const u8 level, char *str, u8 len)
|
int log_level_to_str(const u8 level, char *str, u32 len)
|
||||||
{
|
{
|
||||||
u8 i;
|
u8 i;
|
||||||
char tmp[20];
|
char tmp[20];
|
||||||
|
|
|
@ -41,7 +41,7 @@ int log_conf_append(const u8 level, const char *conf_path, const char *conf_file
|
||||||
int (*cb_content)(FILE *fp, const u8 level, const char *filter_mod, void *arg), void *arg);
|
int (*cb_content)(FILE *fp, const u8 level, const char *filter_mod, void *arg), void *arg);
|
||||||
int write_conf_content(FILE *fp, const u8 level, const char *filter_mod, void *arg);
|
int write_conf_content(FILE *fp, const u8 level, const char *filter_mod, void *arg);
|
||||||
int write_conf_content_authorizing(FILE *fp, const u8 level, const char *filter_mod, void *arg);
|
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, u8 len);
|
int log_level_to_str(const u8 level, char *str, u32 len);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "log_console.h"
|
#include "log_console.h"
|
||||||
|
#include "log_types.h"
|
||||||
#include "log_common.h"
|
#include "log_common.h"
|
||||||
|
|
||||||
#define LOG_CONF_COSOLE_FILE_NAME "log-console.conf"
|
#define LOG_CONF_COSOLE_FILE_NAME "log-console.conf"
|
||||||
|
|
|
@ -5,12 +5,6 @@
|
||||||
#include "common_types.h"
|
#include "common_types.h"
|
||||||
#include "rpc_common.h"
|
#include "rpc_common.h"
|
||||||
|
|
||||||
typedef struct _log_console {
|
|
||||||
u8 level;
|
|
||||||
u8 on;
|
|
||||||
char module_name[MAX_MODULE_NAME_SZ];
|
|
||||||
} log_console_t;
|
|
||||||
|
|
||||||
void rpc_conf_log_console(rpc_conn *conn, pointer input, int input_len, pointer data);
|
void rpc_conf_log_console(rpc_conn *conn, pointer input, int input_len, pointer data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "log_pty.h"
|
#include "log_pty.h"
|
||||||
|
#include "log_types.h"
|
||||||
#include "log_common.h"
|
#include "log_common.h"
|
||||||
|
|
||||||
#define LOG_DEV_PTY_DIR LOG_DEV_DIR"pts/"
|
#define LOG_DEV_PTY_DIR LOG_DEV_DIR"pts/"
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
#include "log_console.h"
|
#include "log_console.h"
|
||||||
|
|
||||||
typedef log_console_t log_pty_t;
|
|
||||||
|
|
||||||
void rpc_conf_log_pty(rpc_conn *conn, pointer input, int input_len, pointer data);
|
void rpc_conf_log_pty(rpc_conn *conn, pointer input, int input_len, pointer data);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -172,7 +172,7 @@ static int remote_conf_level_content(FILE *fp, const u8 level)
|
||||||
ULOG_DEBUG(g_log, "Recover old line:%s to file:%s", rewrite_line, path);
|
ULOG_DEBUG(g_log, "Recover old line:%s to file:%s", rewrite_line, path);
|
||||||
n1 = fwrite(rewrite_line, 1, n3, fp);
|
n1 = fwrite(rewrite_line, 1, n3, fp);
|
||||||
if (n3 != n1) {
|
if (n3 != n1) {
|
||||||
ULOG_ERR(g_log, "Recovering old line:%s to file is failure:%s", line, strerror(errno));
|
ULOG_ERR(g_log, "Recovering old line:%s to file is failure:%s", rewrite_line, strerror(errno));
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,15 +12,11 @@
|
||||||
#include "log_pty.h"
|
#include "log_pty.h"
|
||||||
#include "log_remote.h"
|
#include "log_remote.h"
|
||||||
#include "rpc_module.h"
|
#include "rpc_module.h"
|
||||||
|
#include "ulog_in.h"
|
||||||
|
|
||||||
|
|
||||||
#define LOG_SCHED_MODULE_NAME "log-sched"
|
#define LOG_SCHED_MODULE_NAME "log-sched"
|
||||||
|
|
||||||
#define SERVICE_LOG_FILE_NAME "log-file"
|
|
||||||
#define SERIVCE_LOG_CONSOLE_NAME "log-console"
|
|
||||||
#define SERVICE_LOG_PTY_NAME "log-pty"
|
|
||||||
#define SERVICE_LOG_REMOTE_NAME "log-remote"
|
|
||||||
|
|
||||||
#define DEFAULT_CONFIG_FILE "/etc/log-sched.conf"
|
#define DEFAULT_CONFIG_FILE "/etc/log-sched.conf"
|
||||||
|
|
||||||
ulog_t *g_log = NULL;
|
ulog_t *g_log = NULL;
|
||||||
|
@ -89,7 +85,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* 注册配置处理函数 */
|
/* 注册配置处理函数 */
|
||||||
rpc_server_regservice(server, SERVICE_LOG_FILE_NAME, "conf_log_file", rpc_conf_log_file);
|
rpc_server_regservice(server, SERVICE_LOG_FILE_NAME, "conf_log_file", rpc_conf_log_file);
|
||||||
rpc_server_regservice(server, SERIVCE_LOG_CONSOLE_NAME, "conf_log_console", rpc_conf_log_console);
|
rpc_server_regservice(server, SERIVCE_LOG_CONSOLE_NAME, CONF_LOG_CONSOLE_FUNC, rpc_conf_log_console);
|
||||||
rpc_server_regservice(server, SERVICE_LOG_PTY_NAME, "conf_log_pty", rpc_conf_log_pty);
|
rpc_server_regservice(server, SERVICE_LOG_PTY_NAME, "conf_log_pty", rpc_conf_log_pty);
|
||||||
rpc_server_regservice(server, SERVICE_LOG_REMOTE_NAME, "conf_log_add_remote", rpc_conf_log_add_remote);
|
rpc_server_regservice(server, SERVICE_LOG_REMOTE_NAME, "conf_log_add_remote", rpc_conf_log_add_remote);
|
||||||
rpc_server_regservice(server, SERVICE_LOG_REMOTE_NAME, "conf_log_del_remote", rpc_conf_log_del_remote);
|
rpc_server_regservice(server, SERVICE_LOG_REMOTE_NAME, "conf_log_del_remote", rpc_conf_log_del_remote);
|
||||||
|
|
Loading…
Reference in New Issue