Compare commits
8 Commits
shm_ring_q
...
CI-aarch64
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b9ac69ecc | ||
|
|
7ed1582309 | ||
|
|
67ed711088 | ||
|
|
1dd9e1e0f2 | ||
|
|
7fa29b1a00 | ||
|
|
8680c2f4f5 | ||
|
|
c0620c8d25 | ||
|
|
4d64f0cf06 |
278
.gitlab-ci.yml
278
.gitlab-ci.yml
@@ -1,12 +1,13 @@
|
||||
variables:
|
||||
GIT_STRATEGY: "clone"
|
||||
BUILD_IMAGE_CENTOS7: "git.mesalab.cn:7443/mesa_platform/build-env:master"
|
||||
BUILD_IMAGE_CENTOS8: "git.mesalab.cn:7443/mesa_platform/build-env:rockylinux"
|
||||
BUILD_IMAGE_X86_64_ROCKY8: "git.mesalab.cn:7443/mesa_platform/build-env:rockylinux"
|
||||
BUILD_IMAGE_AARCH64_ROCKY9: "git.mesalab.cn:7443/mesa_platform/build-env:rocky9-aarch64"
|
||||
BUILD_PADDING_PREFIX: /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX/
|
||||
INSTALL_DEPENDENCY_LIBRARY: libasan
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
|
||||
.build_before_script:
|
||||
before_script:
|
||||
@@ -14,36 +15,116 @@ stages:
|
||||
- ln -s $CI_PROJECT_DIR $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
|
||||
- cd $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
|
||||
- chmod +x ./ci/travis.sh
|
||||
- yum makecache
|
||||
- yum install -y elfutils-libelf-devel
|
||||
|
||||
|
||||
.build_by_travis_for_centos7:
|
||||
###############################################################################
|
||||
# build on x86_64 Rocky8
|
||||
###############################################################################
|
||||
|
||||
.build_by_travis_for_x86_64_rocky8:
|
||||
stage: build
|
||||
image: $BUILD_IMAGE_CENTOS7
|
||||
image: $BUILD_IMAGE_X86_64_ROCKY8
|
||||
extends: .build_before_script
|
||||
script:
|
||||
- yum install -y libmnl-devel
|
||||
- yum install -y libnfnetlink-devel
|
||||
- ./ci/travis.sh
|
||||
tags:
|
||||
- tsg-os-builder-el8
|
||||
|
||||
|
||||
run_test_for_x86_64_rocky8:
|
||||
stage: test
|
||||
image: $BUILD_IMAGE_X86_64_ROCKY8
|
||||
extends: .build_by_travis_for_x86_64_rocky8
|
||||
script:
|
||||
- ./ci/travis.sh
|
||||
- cd build
|
||||
tags:
|
||||
- share
|
||||
- ctest --verbose
|
||||
|
||||
.build_by_travis_for_centos8:
|
||||
|
||||
branch_build_debug_for_x86_64_rocky8:
|
||||
stage: build
|
||||
image: $BUILD_IMAGE_CENTOS8
|
||||
extends: .build_by_travis_for_x86_64_rocky8
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
except:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
- /^dev*.*$/i
|
||||
- /^rel*.*$/i
|
||||
- tags
|
||||
|
||||
branch_build_release_for_x86_64_rocky8:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
extends: .build_by_travis_for_x86_64_rocky8
|
||||
except:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
- /^dev*.*$/i
|
||||
- /^rel*.*$/i
|
||||
- tags
|
||||
|
||||
release_build_debug_for_x86_64_rocky88:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
PULP3_REPO_NAME: framework-stable-x86_64.el8
|
||||
PULP3_DIST_NAME: framework-stable-x86_64.el8
|
||||
extends: .build_by_travis_for_x86_64_rocky8
|
||||
artifacts:
|
||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-debug"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
only:
|
||||
- tags
|
||||
|
||||
release_build_release_for_x86_64_rocky8:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
SYMBOL_TARGET: libMESA_handle_logger
|
||||
PULP3_REPO_NAME: framework-stable-x86_64.el8
|
||||
PULP3_DIST_NAME: framework-stable-x86_64.el8
|
||||
extends: .build_by_travis_for_x86_64_rocky8
|
||||
artifacts:
|
||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
only:
|
||||
- tags
|
||||
|
||||
###############################################################################
|
||||
# build on aarch64 Rocky9
|
||||
###############################################################################
|
||||
|
||||
.build_by_travis_for_aarch64_rocky9:
|
||||
stage: build
|
||||
image: $BUILD_IMAGE_AARCH64_ROCKY9
|
||||
extends: .build_before_script
|
||||
script:
|
||||
- dnf --enablerepo=powertools install -y libmnl-devel
|
||||
- dnf --enablerepo=powertools install -y libnfnetlink-devel
|
||||
- ./ci/travis.sh
|
||||
tags:
|
||||
- share
|
||||
- tsg-os-builder-aarch64
|
||||
|
||||
branch_build_debug_for_centos7:
|
||||
|
||||
run_test_for_aarch64_rocky9:
|
||||
stage: test
|
||||
image: $BUILD_IMAGE_AARCH64_ROCKY9
|
||||
extends: .build_by_travis_for_aarch64_rocky9
|
||||
script:
|
||||
- ./ci/travis.sh
|
||||
- cd build
|
||||
- ctest --verbose
|
||||
|
||||
|
||||
branch_build_debug_for_aarch64_rocky9:
|
||||
stage: build
|
||||
extends: .build_by_travis_for_centos7
|
||||
extends: .build_by_travis_for_aarch64_rocky9
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
except:
|
||||
@@ -53,11 +134,11 @@ branch_build_debug_for_centos7:
|
||||
- /^rel*.*$/i
|
||||
- tags
|
||||
|
||||
branch_build_release_for_centos7:
|
||||
branch_build_release_for_aarch64_rocky9:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
extends: .build_by_travis_for_centos7
|
||||
extends: .build_by_travis_for_aarch64_rocky9
|
||||
except:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
@@ -65,56 +146,15 @@ branch_build_release_for_centos7:
|
||||
- /^rel*.*$/i
|
||||
- tags
|
||||
|
||||
develop_build_debug_for_centos7:
|
||||
stage: build
|
||||
extends: .build_by_travis_for_centos7
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
ASAN_OPTION: ADDRESS
|
||||
TESTING_VERSION_BUILD: 1
|
||||
PULP3_REPO_NAME: framework-testing-x86_64.el7
|
||||
PULP3_DIST_NAME: framework-testing-x86_64.el7
|
||||
artifacts:
|
||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-debug"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
only:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
- /^dev*.*$/i
|
||||
- /^rel*.*$/i
|
||||
|
||||
develop_build_release_for_centos7:
|
||||
stage: build
|
||||
extends: .build_by_travis_for_centos7
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
TESTING_VERSION_BUILD: 1
|
||||
PULP3_REPO_NAME: framework-testing-x86_64.el7
|
||||
PULP3_DIST_NAME: framework-testing-x86_64.el7
|
||||
artifacts:
|
||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
only:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
- /^dev*.*$/i
|
||||
- /^rel*.*$/i
|
||||
|
||||
release_build_debug_for_centos7:
|
||||
release_build_debug_for_aarch64_rocky9:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
PULP3_REPO_NAME: framework-stable-x86_64.el7
|
||||
PULP3_DIST_NAME: framework-stable-x86_64.el7
|
||||
extends: .build_by_travis_for_centos7
|
||||
PULP3_REPO_NAME: framework-stable-aarch64.el9
|
||||
PULP3_DIST_NAME: framework-stable-aarch64.el9
|
||||
extends: .build_by_travis_for_aarch64_rocky9
|
||||
artifacts:
|
||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-debug"
|
||||
paths:
|
||||
@@ -122,119 +162,19 @@ release_build_debug_for_centos7:
|
||||
only:
|
||||
- tags
|
||||
|
||||
release_build_release_for_centos7:
|
||||
release_build_release_for_aarch64_rocky9:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
UPLOAD_SYMBOL_FILES: 1
|
||||
SYMBOL_TARGET: libMESA_handle_logger
|
||||
PULP3_REPO_NAME: framework-stable-x86_64.el7
|
||||
PULP3_DIST_NAME: framework-stable-x86_64.el7
|
||||
extends: .build_by_travis_for_centos7
|
||||
PULP3_REPO_NAME: framework-stable-aarch64.el9
|
||||
PULP3_DIST_NAME: framework-stable-aarch64.el9
|
||||
extends: .build_by_travis_for_aarch64_rocky9
|
||||
artifacts:
|
||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
only:
|
||||
- tags
|
||||
|
||||
branch_build_debug_for_centos8:
|
||||
stage: build
|
||||
extends: .build_by_travis_for_centos8
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
except:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
- /^dev*.*$/i
|
||||
- /^rel*.*$/i
|
||||
- tags
|
||||
|
||||
branch_build_release_for_centos8:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
extends: .build_by_travis_for_centos8
|
||||
except:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
- /^dev*.*$/i
|
||||
- /^rel*.*$/i
|
||||
- tags
|
||||
|
||||
develop_build_debug_for_centos8:
|
||||
stage: build
|
||||
extends: .build_by_travis_for_centos8
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
ASAN_OPTION: ADDRESS
|
||||
TESTING_VERSION_BUILD: 1
|
||||
PULP3_REPO_NAME: framework-testing-x86_64.el8
|
||||
PULP3_DIST_NAME: framework-testing-x86_64.el8
|
||||
artifacts:
|
||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-debug"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
only:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
- /^dev*.*$/i
|
||||
- /^rel*.*$/i
|
||||
|
||||
develop_build_release_for_centos8:
|
||||
stage: build
|
||||
extends: .build_by_travis_for_centos8
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
TESTING_VERSION_BUILD: 1
|
||||
PULP3_REPO_NAME: framework-testing-x86_64.el8
|
||||
PULP3_DIST_NAME: framework-testing-x86_64.el8
|
||||
artifacts:
|
||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
only:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
- /^dev*.*$/i
|
||||
- /^rel*.*$/i
|
||||
|
||||
release_build_debug_for_centos8:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
PULP3_REPO_NAME: framework-stable-x86_64.el8
|
||||
PULP3_DIST_NAME: framework-stable-x86_64.el8
|
||||
extends: .build_by_travis_for_centos8
|
||||
artifacts:
|
||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-debug"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
only:
|
||||
- tags
|
||||
|
||||
release_build_release_for_centos8:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
UPLOAD_SYMBOL_FILES: 1
|
||||
SYMBOL_TARGET: libMESA_handle_logger
|
||||
PULP3_REPO_NAME: framework-stable-x86_64.el8
|
||||
PULP3_DIST_NAME: framework-stable-x86_64.el8
|
||||
extends: .build_by_travis_for_centos8
|
||||
artifacts:
|
||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
only:
|
||||
- tags
|
||||
- tags
|
||||
@@ -69,4 +69,9 @@ install(FILES conf/MESA_handle_logger.conf DESTINATION /usr/lib/tmpfiles.d/ COMP
|
||||
add_executable(${lib_name}_demo demo/test_handle_logger.c)
|
||||
target_link_libraries(${lib_name}_demo pthread ${lib_name}_shared)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_test(NAME test_compatible_mode COMMAND MESA_handle_logger_demo 1 ./demo_zlog.conf 1 100 0)
|
||||
add_test(NAME test_perf COMMAND MESA_handle_logger_demo 2 ./demo_zlog.conf 1 1000 0)
|
||||
|
||||
include(Package)
|
||||
|
||||
11
ci/travis.sh
11
ci/travis.sh
@@ -37,10 +37,6 @@ if [ -n "${INSTALL_DEPENDENCY_LIBRARY}" ]; then
|
||||
yum install -y $INSTALL_DEPENDENCY_LIBRARY
|
||||
fi
|
||||
|
||||
if [ $ASAN_OPTION ] && [ -f "/opt/rh/devtoolset-7/enable" ] ;then
|
||||
source /opt/rh/devtoolset-7/enable
|
||||
fi
|
||||
|
||||
mkdir build || true
|
||||
cd build
|
||||
|
||||
@@ -61,11 +57,4 @@ fi
|
||||
if [ -n "${UPLOAD_RPM}" ]; then
|
||||
cp ~/rpm_upload_tools.py ./
|
||||
python3 rpm_upload_tools.py ${PULP3_REPO_NAME} ${PULP3_DIST_NAME} *.rpm
|
||||
fi
|
||||
|
||||
if [ -n "${UPLOAD_SYMBOL_FILES}" ]; then
|
||||
rpm -i $SYMBOL_TARGET*debuginfo*.rpm
|
||||
_symbol_file=`find /usr/lib/debug/ -name "$SYMBOL_TARGET*.so*.debug"`
|
||||
cp $_symbol_file ${_symbol_file}info.${CI_COMMIT_SHORT_SHA}
|
||||
sentry-cli upload-dif -t elf ${_symbol_file}info.${CI_COMMIT_SHORT_SHA}
|
||||
fi
|
||||
@@ -16,6 +16,7 @@ void *test_handle = NULL;
|
||||
int g_mode = 0;
|
||||
int g_log_num = 0;
|
||||
int g_thread_num = 0;
|
||||
int g_sleep_interval = 0;
|
||||
const char *g_zlog_conf = NULL;
|
||||
volatile long g_start_time = 0;
|
||||
volatile long g_end_time = 0;
|
||||
@@ -44,7 +45,11 @@ void call_logger(int log_num, int thread_num)
|
||||
//sleep(1);
|
||||
MESA_handle_runtime_log(test_handle, RLOG_LV_INFO, "test", "test_handle MESA_handle_runtime_log, i = %d, thread_num = %d", i, thread_num);
|
||||
//MESA_HANDLE_RUNTIME_LOG(sample_handle, RLOG_LV_FATAL, "sample", "sample_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
||||
//sleep(1);
|
||||
if(g_sleep_interval > 0)
|
||||
{
|
||||
printf("MESA_handle_runtime_log_level_enabled(%d) return %d\n", RLOG_LV_DEBUG, MESA_handle_runtime_log_level_enabled(test_handle, RLOG_LV_DEBUG));
|
||||
sleep(g_sleep_interval);
|
||||
}
|
||||
//MESA_HANDLE_RUNTIME_LOG(test_handle, RLOG_LV_FATAL, "test", "test_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
@@ -60,8 +65,9 @@ void call_logger(int log_num, int thread_num)
|
||||
g_end_time = end_time;
|
||||
}
|
||||
}
|
||||
time_cost = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000 ;
|
||||
time_cost = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000 - g_sleep_interval * 1000000 ;
|
||||
printf("THREAD %d write %d log using %ld us, avg speed %f /s, %ld -> %ld\n", thread_num, log_num, time_cost, ((float)log_num/(float)time_cost)*1000000, start_time, end_time);
|
||||
printf("MESA_handle_runtime_log_level_enabled(%d) return %d\n", RLOG_LV_DEBUG, MESA_handle_runtime_log_level_enabled(test_handle, RLOG_LV_DEBUG));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -100,16 +106,18 @@ int main(int argc, char ** args)
|
||||
{
|
||||
pthread_t t[MAX_THREAD_NUM];
|
||||
int i = 0;
|
||||
int ret =0;
|
||||
|
||||
if (argc != 5)
|
||||
if (argc != 6)
|
||||
{
|
||||
printf("Usage: ./($app) $mode[1 or 2] $zlog_conf_path $thread_num $log_num \n");
|
||||
printf("Usage: ./($app) $version_mode[1 or 2] $zlog_conf_path $thread_num $log_num $sleep_interval\n");
|
||||
return -1;
|
||||
}
|
||||
g_mode = atoi(args[1]);
|
||||
g_zlog_conf = args[2];
|
||||
g_thread_num = atoi(args[3]);
|
||||
g_log_num = atoi(args[4]);
|
||||
g_sleep_interval = atoi(args[5]);
|
||||
|
||||
if(g_thread_num <= 0 || g_log_num <= 0)
|
||||
{
|
||||
@@ -129,26 +137,35 @@ int main(int argc, char ** args)
|
||||
{
|
||||
printf("get log sample_handle error\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
test_handle = MESA_create_runtime_log_handle("./log/test_log", RLOG_LV_DEBUG);
|
||||
if(test_handle == NULL)
|
||||
{
|
||||
printf("get log test_handle error\n");
|
||||
return -1;
|
||||
}
|
||||
test_handle = MESA_create_runtime_log_handle("./log/test_log", RLOG_LV_DEBUG);
|
||||
if (test_handle == NULL)
|
||||
{
|
||||
printf("get log test_handle error\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(i = 0; i < g_thread_num; i++)
|
||||
{
|
||||
pthread_create(&t[i], NULL, thread_logger, (void *)(unsigned long)(i));
|
||||
}
|
||||
signal(SIGINT, sig_int_handler);
|
||||
signal(SIGHUP, sig_hup_handler);
|
||||
while(1)
|
||||
;
|
||||
//MESA_destroy_runtime_log_handle(sample_handle);
|
||||
//MESA_destroy_runtime_log_handle(test_handle);
|
||||
//sample_handle = NULL;
|
||||
//test_handle = NULL;
|
||||
return 0;
|
||||
for (i = 0; i < g_thread_num; i++)
|
||||
{
|
||||
pthread_create(&t[i], NULL, thread_logger, (void *)(unsigned long)(i));
|
||||
}
|
||||
signal(SIGINT, sig_int_handler);
|
||||
signal(SIGHUP, sig_hup_handler);
|
||||
|
||||
// 等待所有线程结束并回收
|
||||
for (i = 0; i < g_thread_num; ++i) {
|
||||
ret = pthread_join(t[i], NULL);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Failed to join thread %d\n", i);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
printf("All threads finished\n");
|
||||
// MESA_destroy_runtime_log_handle(sample_handle);
|
||||
// MESA_destroy_runtime_log_handle(test_handle);
|
||||
// sample_handle = NULL;
|
||||
// test_handle = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,17 @@ int MESA_handle_runtime_log_creation(const char *conf_path);
|
||||
int MESA_handle_runtime_log_reconstruction(const char *conf_path);
|
||||
void MESA_handle_runtime_log_destruction();
|
||||
|
||||
#define MESA_HANDLE_RUNTIME_LOG(handle, lv, mod, fmt, args...) \
|
||||
MESA_handle_runtime_log((handle), (lv), (mod), "file %s, line %d, " fmt, \
|
||||
__FILE__, __LINE__, ##args)
|
||||
#define MESA_HANDLE_RUNTIME_LOG(handle, level, module, format, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (MESA_handle_runtime_log_level_enabled(handle, level)) \
|
||||
{ \
|
||||
MESA_handle_runtime_log(handle, level, module, "file %s, line %d, " format, \
|
||||
__FILE__, __LINE__, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
int MESA_handle_runtime_log_level_enabled(void *handle, const int level);
|
||||
/*
|
||||
* name: MESA_create_runtime_log_handle
|
||||
* functionality: get runtime_log handle;
|
||||
@@ -37,7 +44,7 @@ void MESA_handle_runtime_log_destruction();
|
||||
* not NULL, if succeeded;
|
||||
* NULL, if file is not absolute path, or failed to create log file;
|
||||
*/
|
||||
void *MESA_create_runtime_log_handle(const char *file_path, int level);
|
||||
void *MESA_create_runtime_log_handle(const char *file_path, int level);
|
||||
|
||||
/*
|
||||
* name: MESA_handle_runtime_log
|
||||
|
||||
@@ -14,13 +14,13 @@ static int g_zlog_conf_fp = -1;
|
||||
static char global_conf_filepath[MAX_HANDLE_LOG_PATH] = "";
|
||||
static char tmp_conf_filepath[MAX_HANDLE_LOG_PATH] = "";
|
||||
|
||||
typedef struct log_handle_t
|
||||
struct log_handle_t
|
||||
{
|
||||
int runtime_log_level;
|
||||
zlog_category_t *zc;
|
||||
const char *global_conf_path;
|
||||
char runtime_log_file[MAX_HANDLE_LOG_PATH];
|
||||
} log_handle_t;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -171,11 +171,11 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level)
|
||||
int rc = -1;
|
||||
zlog_category_t *zc = NULL;
|
||||
FILE *fp = NULL;
|
||||
log_handle_t *p_handle = NULL;
|
||||
struct log_handle_t *handle = NULL;
|
||||
|
||||
char handle_name[MAX_HANDLE_LOG_PATH];
|
||||
char *p_path_end = rindex(file_path, '/');
|
||||
char *p_name = p_path_end+1;
|
||||
char *p_name;
|
||||
|
||||
strcpy(handle_name, file_path);
|
||||
escape_for_zlog(handle_name, strlen(handle_name));
|
||||
@@ -195,11 +195,11 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level)
|
||||
{
|
||||
fprintf(stderr,"[MESA_create_runtime_log_handle], get zlog category (%s) in global_conf_filepath(%s) fail\n", p_name, global_conf_filepath);
|
||||
}
|
||||
p_handle = (log_handle_t *)calloc(sizeof(log_handle_t), 1);
|
||||
strncpy(p_handle->runtime_log_file, file_path, sizeof(p_handle->runtime_log_file) - 1);
|
||||
p_handle->runtime_log_level = level;
|
||||
p_handle->zc = zc;
|
||||
return (void *)p_handle;
|
||||
handle = (struct log_handle_t *)calloc(sizeof(struct log_handle_t), 1);
|
||||
strncpy(handle->runtime_log_file, file_path, sizeof(handle->runtime_log_file) - 1);
|
||||
handle->runtime_log_level = level;
|
||||
handle->zc = zc;
|
||||
return (void *)handle;
|
||||
}
|
||||
|
||||
void MESA_destroy_runtime_log_handle(void *handle)
|
||||
@@ -214,19 +214,28 @@ void MESA_destroy_runtime_log_handle(void *handle)
|
||||
}
|
||||
|
||||
|
||||
void MESA_handle_runtime_log(void *handle, int level, const char *module, const char *fmt, ...)
|
||||
int MESA_handle_runtime_log_level_enabled(void *v_handle, const int level)
|
||||
{
|
||||
|
||||
log_handle_t *p_handle = (log_handle_t *)handle;
|
||||
struct log_handle_t *handle = (struct log_handle_t *)v_handle;
|
||||
if(handle == NULL || handle->runtime_log_file == NULL)return;
|
||||
if(handle->zc == NULL) return;
|
||||
return zlog_level_enabled(handle->zc, level);
|
||||
}
|
||||
|
||||
if(p_handle == NULL || p_handle->runtime_log_file == NULL)return;
|
||||
void MESA_handle_runtime_log(void *v_handle, int level, const char *module, const char *fmt, ...)
|
||||
{
|
||||
struct log_handle_t *handle = (struct log_handle_t *)v_handle;
|
||||
if(handle == NULL || handle->runtime_log_file == NULL)return;
|
||||
|
||||
if(p_handle->zc == NULL)return;
|
||||
if(handle->zc == NULL)return;
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vzlog(p_handle->zc, p_handle->runtime_log_file, strlen(p_handle->runtime_log_file), module, strlen(module), __LINE__, level, fmt, ap);
|
||||
va_end(ap);
|
||||
if (zlog_level_enabled(handle->zc, level))
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vzlog(handle->zc, handle->runtime_log_file, strlen(handle->runtime_log_file), module, strlen(module), __LINE__, level, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
@@ -235,6 +244,14 @@ int MESA_handle_runtime_log_creation(const char *conf_path)
|
||||
{
|
||||
char *env = getenv("ZLOG_CONF_PATH");
|
||||
int rc = 0;
|
||||
|
||||
if(g_zlog_inited == 1)
|
||||
{
|
||||
rc = zlog_reload(conf_path);
|
||||
zlog_profile();
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (conf_path == NULL || (access(conf_path, R_OK) != 0))
|
||||
{
|
||||
fprintf(stderr,"[MESA_handle_runtime_log_creation], PATH (%s) unable to access, will output log to STDOUT or Using ZLOG_CONF_PATH (%s) !\n", conf_path, env);
|
||||
@@ -327,4 +344,5 @@ void MESA_handle_runtime_log_destruction()
|
||||
unlink(tmp_conf_filepath);
|
||||
close(g_zlog_conf_fp);
|
||||
}
|
||||
g_zlog_inited=0;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ cmake_minimum_required (VERSION 3.5)
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(zlog PREFIX zlog
|
||||
URL ${CMAKE_CURRENT_SOURCE_DIR}/zlog-1.2.15.tar.gz
|
||||
URL_MD5 5e79f8d08744c7fef8528dd55a3bcd2d
|
||||
URL ${CMAKE_CURRENT_SOURCE_DIR}/zlog-1.2.16.tar.gz
|
||||
URL_MD5 4dcfe75a1acbb5c4513bbe168f935993
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND make
|
||||
INSTALL_COMMAND ""
|
||||
|
||||
Binary file not shown.
BIN
zlog/zlog-1.2.16.tar.gz
Normal file
BIN
zlog/zlog-1.2.16.tar.gz
Normal file
Binary file not shown.
Reference in New Issue
Block a user