[添加文件]
1.添加CertStore源代码程序文件 [目录层次介绍] 1.conf为配置文件 2.make为Makefile配置文件 3.release为执行make tarball后生成的安装包文件 4.src源代码 src/components 使用的静态库所需的头文件(libevent、openssl、hiredis) src/inc 系统所需头文件 src/lib 静态库 src/package 安装包临时目录 src/rt 功能函数代码 [编译运行] 1.cd src && make 2../cert_store --debug[release/deamon] [安装包使用] 1.cd src && make tarball 2.cd release (获取安装包) 2.1.tar -zxvf xxxx.tar.gz 2.2 cd xxx.tar.gz && make install [版本问题] 1.证书生成代码屏蔽(未调通) 2.Redis超时处理未完成 3.连接响应断开后,资源未释放
This commit is contained in:
73
src/components/syslogd/logging.c
Normal file
73
src/components/syslogd/logging.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/*************************************************************************
|
||||
> File Name: logging.c
|
||||
> Author:
|
||||
> Mail:
|
||||
> Created Time: 2018年06月18日 星期一 22时45分43秒
|
||||
************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include "rt_common.h"
|
||||
#include "rt_time.h"
|
||||
#include "rt_util.h"
|
||||
#include "rt_string.h"
|
||||
#include "logging.h"
|
||||
#include "MESA_prof_load.h"
|
||||
#include "MESA_handle_logger.h"
|
||||
|
||||
void mesa_logging_print(int log_level, char *module, char *msg)
|
||||
{
|
||||
|
||||
MESA_handle_runtime_log(logging_sc_lid.run_log_handle, log_level, module, msg);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int mesa_logging_mkfile(char *file, size_t size)
|
||||
{
|
||||
char tm[64] = {0};
|
||||
char pname[64]= {0};
|
||||
|
||||
assert(file);
|
||||
|
||||
if (size < 32)
|
||||
return -1;
|
||||
|
||||
rt_curr_tms2str(EVAL_TM_STYLE, tm, 63);
|
||||
rt_get_pname_by_pid(getpid(), &pname[0]);
|
||||
snprintf(file, 255, "%s-%s-%d-%d-%s.log", pname, getpwuid(getuid())->pw_name, getpwuid(getuid())->pw_uid, getpwuid(getuid())->pw_gid, tm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cert_syslog_init(char *config)
|
||||
{
|
||||
MESA_load_profile_int_def(config, (const char *)"SYSTEM",(const char *)"DEBUG_SWITCH",
|
||||
&logging_sc_lid.debug_switch, 1);
|
||||
MESA_load_profile_int_def(config, (const char *)"SYSTEM",(const char *)"RUN_LOG_LEVEL",
|
||||
&logging_sc_lid.run_log_level, 10);
|
||||
MESA_load_profile_string_def(config, (const char *)"SYSTEM",(const char *)"RUN_LOG_PATH",
|
||||
logging_sc_lid.run_log_path, 128, NULL);
|
||||
|
||||
char file[32] = {0};
|
||||
mesa_logging_mkfile(file, 32);
|
||||
STRCAT(logging_sc_lid.run_log_path, file);
|
||||
|
||||
logging_sc_lid.run_log_handle = MESA_create_runtime_log_handle(logging_sc_lid.run_log_path, logging_sc_lid.run_log_level);
|
||||
if(logging_sc_lid.run_log_handle == NULL){
|
||||
printf("Create log runtime_log_handle error, init failed!");
|
||||
goto finish;
|
||||
}else{
|
||||
mesa_runtime_log(RLOG_LV_INFO, MODULE_NAME, "Log module initialization");
|
||||
}
|
||||
finish:
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
51
src/components/syslogd/logging.h
Normal file
51
src/components/syslogd/logging.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*************************************************************************
|
||||
> File Name: logging.h
|
||||
> Author:
|
||||
> Mail:
|
||||
> Created Time: 2018年06月18日 星期一 22时45分58秒
|
||||
************************************************************************/
|
||||
|
||||
#ifndef _LOGGING_H
|
||||
#define _LOGGING_H
|
||||
|
||||
#define MODULE_NAME "CA"
|
||||
|
||||
#define RLOG_LV_DEBUG 10
|
||||
#define RLOG_LV_INFO 20
|
||||
#define RLOG_LV_FATAL 30
|
||||
|
||||
typedef struct RTLogInit2Data_ {
|
||||
int debug_switch;
|
||||
|
||||
int run_log_level;
|
||||
|
||||
char run_log_path[256];
|
||||
|
||||
void *run_log_handle;
|
||||
} RTLogInit2Data;
|
||||
|
||||
RTLogInit2Data logging_sc_lid;
|
||||
|
||||
/* The maximum length of the log message */
|
||||
#define RT_LOG_MAX_LOG_MSG_LEN 2048
|
||||
|
||||
extern void mesa_logging_print(int log_level, char *module, char *msg);
|
||||
|
||||
#define mesa_log(x, y, z, ...) do { \
|
||||
char _sc_log_msg[RT_LOG_MAX_LOG_MSG_LEN] = ""; \
|
||||
char *_sc_log_temp = _sc_log_msg; \
|
||||
if ( !x ) \
|
||||
{ } else { \
|
||||
snprintf(_sc_log_temp, \
|
||||
(RT_LOG_MAX_LOG_MSG_LEN - \
|
||||
(_sc_log_temp - _sc_log_msg)), \
|
||||
__VA_ARGS__); \
|
||||
mesa_logging_print(y, z, _sc_log_msg); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define mesa_runtime_log(level, module, ...) mesa_log(logging_sc_lid.debug_switch, level, module, __VA_ARGS__)
|
||||
|
||||
extern void cert_syslog_init(char *config);
|
||||
|
||||
#endif
|
||||
40
src/components/syslogd/syslog.mk
Normal file
40
src/components/syslogd/syslog.mk
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
|
||||
# standard component Makefile header
|
||||
sp := $(sp).x
|
||||
dirstack_$(sp) := $(d)
|
||||
d := $(dir)
|
||||
|
||||
# component specification
|
||||
|
||||
OBJS_$(d) :=\
|
||||
$(OBJ_DIR)/logging.o\
|
||||
|
||||
CFLAGS_LOCAL += -I$(d)
|
||||
$(OBJS_$(d)): CFLAGS_LOCAL := -std=gnu99 -W -Wall -Wunused-parameter -g -O3 \
|
||||
-I$(d)\
|
||||
-I$(d)/../../rt\
|
||||
-I$(d)/../../inc\
|
||||
|
||||
|
||||
# standard component Makefile rules
|
||||
|
||||
DEPS_$(d) := $(OBJS_$(d):.o=.d)
|
||||
|
||||
#LIBS_LIST := $(LIBS_LIST) $(LIBRARY)
|
||||
LIBS_LIST := $(LIBS_LIST)
|
||||
|
||||
CLEAN_LIST := $(CLEAN_LIST) $(OBJS_$(d)) $(DEPS_$(d))
|
||||
|
||||
-include $(DEPS_$(d))
|
||||
|
||||
#$(LIBRARY): $(OBJS)
|
||||
# $(MYARCHIVE)
|
||||
|
||||
$(OBJ_DIR)/%.o: $(d)/%.c
|
||||
$(COMPILE)
|
||||
|
||||
# standard component Makefile footer
|
||||
|
||||
d := $(dirstack_$(sp))
|
||||
sp := $(basename $(sp))
|
||||
Reference in New Issue
Block a user