diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6a045c4..f3ec368 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -77,12 +77,12 @@ release_build_release: BUILD_TYPE: RelWithDebInfo PACKAGE: 1 UPLOAD: 1 - SYMBOL_TARGET: certstore-install + SYMBOL_TARGET: certstore PULP3_REPO_NAME: tsg-stable-x86_64.el7 PULP3_DIST_NAME: tsg-stable-x86_64.el7 extends: .build_by_travis artifacts: - name: "certstore-install-$CI_COMMIT_REF_NAME-debug" + name: "certstore-$CI_COMMIT_REF_NAME-debug" paths: - build/*.rpm only: @@ -95,12 +95,12 @@ release_build_release_devel: ENABLE_DEVEL_SWITCH: "ON" PACKAGE: 1 UPLOAD: 1 - SYMBOL_TARGET: certstore-install + SYMBOL_TARGET: certstore PULP3_REPO_NAME: tsg-stable-x86_64.el7 PULP3_DIST_NAME: tsg-stable-x86_64.el7 extends: .build_by_travis artifacts: - name: "certstore-install-$CI_COMMIT_REF_NAME-release" + name: "certstore-$CI_COMMIT_REF_NAME-release" paths: - build/*.rpm only: diff --git a/ci/travis.sh b/ci/travis.sh index 2756f9a..79a796c 100644 --- a/ci/travis.sh +++ b/ci/travis.sh @@ -34,7 +34,7 @@ env | sort # Install dependency from YUM -yum install -y libcjson-devel libmaatframe-devel libMESA_field_stat2-devel libMESA_handle_logger-devel +yum install -y libcjson-devel libmaatframe-devel libMESA_field_stat2-devel libMESA_handle_logger-devel libbreakpad_mini-devel.x86_64 yum install -y libMESA_htable-devel libMESA_prof_load-devel librulescan-devel libwiredcfg-devel libWiredLB-devel sapp-devel mkdir build || true diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 30fc243..3047de0 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -5,4 +5,4 @@ add_library(common syslogd/src/logging.cpp json/src/arraylist.c json/src/debug.c rt/src/rt_file.cpp rt/src/rt_stdlib.cpp rt/src/rt_string.cpp rt/src/rt_tmr.cpp rt/src/rt_time.cpp) target_include_directories(common PUBLIC syslogd/include json/include rt/include) -target_link_libraries(common PUBLIC rt MESA_handle_logger) +target_link_libraries(common PUBLIC rt MESA_handle_logger breakpad_mini) diff --git a/common/syslogd/src/logging.cpp b/common/syslogd/src/logging.cpp index afbc29e..751d239 100644 --- a/common/syslogd/src/logging.cpp +++ b/common/syslogd/src/logging.cpp @@ -19,6 +19,7 @@ #include "rt_time.h" #include "rt_string.h" #include "logging.h" +#include #include #include @@ -32,24 +33,34 @@ void mesa_logging_print(int log_level, const char *module, const char *msg) void cert_syslog_init(const char *config) { - char run_log_path[256] = {0}; + struct breakpad_instance *breakpad; 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); + logging_sc_lid.run_log_path, 128, "conf/zlog.conf"); - snprintf(run_log_path, 255, "%s/%s", logging_sc_lid.run_log_path, "certstore.log"); + if (0 != MESA_handle_runtime_log_creation(logging_sc_lid.run_log_path)) + { + fprintf(stderr, "Create log runtime_log_handle error, init failed\n"); + goto finish; + } - logging_sc_lid.run_log_handle = MESA_create_runtime_log_handle(run_log_path, logging_sc_lid.run_log_level); - if(logging_sc_lid.run_log_handle == NULL){ + logging_sc_lid.run_log_handle = MESA_create_runtime_log_handle("./logs", RLOG_LV_DEBUG); + if(logging_sc_lid.run_log_handle == NULL) + { mesa_runtime_log(RLOG_LV_FATAL, MODULE_NAME, "Create log runtime_log_handle error, init failed!"); goto finish; - }else{ + }else + { mesa_runtime_log(RLOG_LV_INFO, MODULE_NAME, "Log module initialization"); } + + breakpad = breakpad_init(config, "breakpad", logging_sc_lid.run_log_handle); + if(breakpad == NULL) + { + mesa_runtime_log(RLOG_LV_FATAL, MODULE_NAME, "Failed at starting breakpad."); + } finish: return; } diff --git a/program/CMakeLists.txt b/program/CMakeLists.txt index 55f86a6..c9fbd9a 100644 --- a/program/CMakeLists.txt +++ b/program/CMakeLists.txt @@ -19,5 +19,4 @@ target_link_libraries(certstore dl common MESA_handle_logger hiredis-static MESA_field_stat - gperftools-static ${SYSTEMD_LIBRARIES}) diff --git a/program/src/cert_session.cpp b/program/src/cert_session.cpp index 9c2ff58..25c5540 100644 --- a/program/src/cert_session.cpp +++ b/program/src/cert_session.cpp @@ -2137,7 +2137,7 @@ static int mesa_fiel_stat_init() FS_set_para(fs, APP_NAME, pname, strlen(pname)+1); value=0; FS_set_para(fs, FLUSH_BY_DATE, &value, sizeof(value)); - snprintf(stat_path, 128, "%s/fs2_%s.status", logging_sc_lid.run_log_path, pname); + snprintf(stat_path, 128, "%s/fs2_%s.status", "./logs", pname); FS_set_para(fs, OUTPUT_DEVICE, stat_path, strlen(stat_path)+1); value=1; FS_set_para(fs, PRINT_MODE, &value, sizeof(value)); diff --git a/resource/conf/cert_store.ini b/resource/conf/cert_store.ini index cf49563..93661b5 100644 --- a/resource/conf/cert_store.ini +++ b/resource/conf/cert_store.ini @@ -1,9 +1,14 @@ [SYSTEM] #1:print on screen, 0:don't DEBUG_SWITCH = 1 -#10:DEBUG, 20:INFO, 30:FATAL -RUN_LOG_LEVEL = 10 -RUN_LOG_PATH = ./logs +RUN_LOG_PATH = "conf/zlog.conf" + +[breakpad] +disable_coredump=0 +enable_breakpad=1 +breakpad_minidump_dir=/tmp/certstore/crashreport +enable_breakpad_upload=0 +breakpad_upload_url=http://127.0.0.1/ [CONFIG] #Number of running threads diff --git a/resource/conf/zlog.conf b/resource/conf/zlog.conf new file mode 100644 index 0000000..32838a5 --- /dev/null +++ b/resource/conf/zlog.conf @@ -0,0 +1,11 @@ +[global] +default format = "%d(%c), %V, %F, %U, %m%n" +[levels] +DEBUG=10 +INFO=20 +FATAL=30 +[rules] +*.fatal "./logs/error.log.%d(%F)"; +*.debug "./logs/certstore.log.%d(%F)" +!*.info "./logs/certstore.log.%d(%F)" + diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index f23e99a..ff63aff 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -151,6 +151,9 @@ add_library(MESA_field_stat SHARED IMPORTED GLOBAL) set_property(TARGET MESA_field_stat PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/libMESA_field_stat2.so) set_property(TARGET MESA_field_stat PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR}) +add_library(breakpad_mini SHARED IMPORTED GLOBAL) +set_property(TARGET breakpad_mini PROPERTY IMPORTED_LOCATION ${MESA_FRAMEWORK_LIB_DIR}/lib/libbreakpad_mini.so) +set_property(TARGET breakpad_mini PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MESA_FRAMEWORK_INCLUDE_DIR})