Compare commits
7 Commits
v2.0.9
...
log_rateli
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2c9a8a704 | ||
|
|
3ecbc885fb | ||
|
|
4c9b58db56 | ||
|
|
74d3c95994 | ||
|
|
d5de7fa545 | ||
|
|
ff694442c0 | ||
|
|
174a57e01f |
172
.gitlab-ci.yml
172
.gitlab-ci.yml
@@ -1,79 +1,57 @@
|
|||||||
|
image: "git.mesalab.cn:7443/mesa_platform/build-env:master"
|
||||||
variables:
|
variables:
|
||||||
GIT_STRATEGY: "clone"
|
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_PADDING_PREFIX: /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX/
|
BUILD_PADDING_PREFIX: /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX/
|
||||||
INSTALL_DEPENDENCY_LIBRARY: libasan
|
INSTALL_PREFIX: "/opt/MESA/lib/"
|
||||||
|
INSTALL_DEPENDENCY_LIBRARY: ""
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
|
|
||||||
.build_before_script:
|
.build_by_travis:
|
||||||
before_script:
|
before_script:
|
||||||
- mkdir -p $BUILD_PADDING_PREFIX/$CI_PROJECT_NAMESPACE/
|
- mkdir -p $BUILD_PADDING_PREFIX/$CI_PROJECT_NAMESPACE/
|
||||||
- ln -s $CI_PROJECT_DIR $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
|
- ln -s $CI_PROJECT_DIR $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
|
||||||
- cd $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
|
- cd $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
|
||||||
- chmod +x ./ci/travis.sh
|
- chmod +x ./ci/travis.sh
|
||||||
- yum makecache
|
|
||||||
- yum install -y elfutils-libelf-devel
|
|
||||||
|
|
||||||
|
|
||||||
.build_by_travis_for_centos7:
|
|
||||||
stage: build
|
|
||||||
image: $BUILD_IMAGE_CENTOS7
|
|
||||||
extends: .build_before_script
|
|
||||||
script:
|
script:
|
||||||
- yum install -y libmnl-devel
|
- wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
|
||||||
- yum install -y libnfnetlink-devel
|
- yum makecache fast
|
||||||
- ./ci/travis.sh
|
- ./ci/travis.sh
|
||||||
- cd build
|
- cd build
|
||||||
tags:
|
tags:
|
||||||
- share
|
- share
|
||||||
|
|
||||||
.build_by_travis_for_centos8:
|
branch_build_debug:
|
||||||
stage: build
|
stage: build
|
||||||
image: $BUILD_IMAGE_CENTOS8
|
extends: .build_by_travis
|
||||||
extends: .build_before_script
|
|
||||||
script:
|
|
||||||
- dnf --enablerepo=powertools install -y libmnl-devel
|
|
||||||
- dnf --enablerepo=powertools install -y libnfnetlink-devel
|
|
||||||
- ./ci/travis.sh
|
|
||||||
tags:
|
|
||||||
- share
|
|
||||||
|
|
||||||
branch_build_debug_for_centos7:
|
|
||||||
stage: build
|
|
||||||
extends: .build_by_travis_for_centos7
|
|
||||||
variables:
|
variables:
|
||||||
BUILD_TYPE: Debug
|
BUILD_TYPE: Debug
|
||||||
except:
|
except:
|
||||||
- /^develop.*$/i
|
|
||||||
- /^master.*$/i
|
|
||||||
- /^dev*.*$/i
|
- /^dev*.*$/i
|
||||||
- /^rel*.*$/i
|
- /^rel*.*$/i
|
||||||
|
- /^master.*$/i
|
||||||
- tags
|
- tags
|
||||||
|
|
||||||
branch_build_release_for_centos7:
|
branch_build_release:
|
||||||
stage: build
|
stage: build
|
||||||
variables:
|
variables:
|
||||||
BUILD_TYPE: RelWithDebInfo
|
BUILD_TYPE: RelWithDebInfo
|
||||||
extends: .build_by_travis_for_centos7
|
extends: .build_by_travis
|
||||||
except:
|
except:
|
||||||
- /^develop.*$/i
|
|
||||||
- /^master.*$/i
|
|
||||||
- /^dev*.*$/i
|
- /^dev*.*$/i
|
||||||
- /^rel*.*$/i
|
- /^rel*.*$/i
|
||||||
|
- /^master.*$/i
|
||||||
- tags
|
- tags
|
||||||
|
|
||||||
develop_build_debug_for_centos7:
|
develop_build_debug:
|
||||||
stage: build
|
stage: build
|
||||||
extends: .build_by_travis_for_centos7
|
extends: .build_by_travis
|
||||||
variables:
|
variables:
|
||||||
BUILD_TYPE: Debug
|
BUILD_TYPE: Debug
|
||||||
PACKAGE: 1
|
PACKAGE: 1
|
||||||
UPLOAD_RPM: 1
|
UPLOAD_RPM: 1
|
||||||
ASAN_OPTION: ADDRESS
|
ASAN_OPTION: ADDRESS
|
||||||
TESTING_VERSION_BUILD: 1
|
|
||||||
PULP3_REPO_NAME: framework-testing-x86_64.el7
|
PULP3_REPO_NAME: framework-testing-x86_64.el7
|
||||||
PULP3_DIST_NAME: framework-testing-x86_64.el7
|
PULP3_DIST_NAME: framework-testing-x86_64.el7
|
||||||
artifacts:
|
artifacts:
|
||||||
@@ -81,19 +59,18 @@ develop_build_debug_for_centos7:
|
|||||||
paths:
|
paths:
|
||||||
- build/*.rpm
|
- build/*.rpm
|
||||||
only:
|
only:
|
||||||
- /^develop.*$/i
|
|
||||||
- /^master.*$/i
|
|
||||||
- /^dev*.*$/i
|
- /^dev*.*$/i
|
||||||
- /^rel*.*$/i
|
- /^rel*.*$/i
|
||||||
|
- /^master.*$/i
|
||||||
|
|
||||||
develop_build_release_for_centos7:
|
develop_build_release:
|
||||||
stage: build
|
stage: build
|
||||||
extends: .build_by_travis_for_centos7
|
extends: .build_by_travis
|
||||||
variables:
|
variables:
|
||||||
BUILD_TYPE: RelWithDebInfo
|
BUILD_TYPE: RelWithDebInfo
|
||||||
PACKAGE: 1
|
PACKAGE: 1
|
||||||
UPLOAD_RPM: 1
|
UPLOAD_RPM: 1
|
||||||
TESTING_VERSION_BUILD: 1
|
ASAN_OPTION: "OFF"
|
||||||
PULP3_REPO_NAME: framework-testing-x86_64.el7
|
PULP3_REPO_NAME: framework-testing-x86_64.el7
|
||||||
PULP3_DIST_NAME: framework-testing-x86_64.el7
|
PULP3_DIST_NAME: framework-testing-x86_64.el7
|
||||||
artifacts:
|
artifacts:
|
||||||
@@ -101,12 +78,12 @@ develop_build_release_for_centos7:
|
|||||||
paths:
|
paths:
|
||||||
- build/*.rpm
|
- build/*.rpm
|
||||||
only:
|
only:
|
||||||
- /^develop.*$/i
|
|
||||||
- /^master.*$/i
|
|
||||||
- /^dev*.*$/i
|
- /^dev*.*$/i
|
||||||
- /^rel*.*$/i
|
- /^rel*.*$/i
|
||||||
|
- /^master.*$/i
|
||||||
|
|
||||||
release_build_debug_for_centos7:
|
|
||||||
|
release_build_debug:
|
||||||
stage: build
|
stage: build
|
||||||
variables:
|
variables:
|
||||||
BUILD_TYPE: Debug
|
BUILD_TYPE: Debug
|
||||||
@@ -114,15 +91,15 @@ release_build_debug_for_centos7:
|
|||||||
UPLOAD_RPM: 1
|
UPLOAD_RPM: 1
|
||||||
PULP3_REPO_NAME: framework-stable-x86_64.el7
|
PULP3_REPO_NAME: framework-stable-x86_64.el7
|
||||||
PULP3_DIST_NAME: framework-stable-x86_64.el7
|
PULP3_DIST_NAME: framework-stable-x86_64.el7
|
||||||
extends: .build_by_travis_for_centos7
|
extends: .build_by_travis
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-debug"
|
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
||||||
paths:
|
paths:
|
||||||
- build/*.rpm
|
- build/*.rpm
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
|
|
||||||
release_build_release_for_centos7:
|
release_build_release:
|
||||||
stage: build
|
stage: build
|
||||||
variables:
|
variables:
|
||||||
BUILD_TYPE: RelWithDebInfo
|
BUILD_TYPE: RelWithDebInfo
|
||||||
@@ -132,106 +109,7 @@ release_build_release_for_centos7:
|
|||||||
SYMBOL_TARGET: libMESA_handle_logger
|
SYMBOL_TARGET: libMESA_handle_logger
|
||||||
PULP3_REPO_NAME: framework-stable-x86_64.el7
|
PULP3_REPO_NAME: framework-stable-x86_64.el7
|
||||||
PULP3_DIST_NAME: framework-stable-x86_64.el7
|
PULP3_DIST_NAME: framework-stable-x86_64.el7
|
||||||
extends: .build_by_travis_for_centos7
|
extends: .build_by_travis
|
||||||
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:
|
artifacts:
|
||||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
||||||
paths:
|
paths:
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ if [ -n "${INSTALL_DEPENDENCY_LIBRARY}" ]; then
|
|||||||
yum install -y $INSTALL_DEPENDENCY_LIBRARY
|
yum install -y $INSTALL_DEPENDENCY_LIBRARY
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $ASAN_OPTION ] && [ -f "/opt/rh/devtoolset-7/enable" ] ;then
|
if [ $ASAN_OPTION ];then
|
||||||
source /opt/rh/devtoolset-7/enable
|
source /opt/rh/devtoolset-7/enable
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -12,32 +12,36 @@ set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
|
|||||||
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}.${VERSION_BUILD}")
|
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}.${VERSION_BUILD}")
|
||||||
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
|
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||||
set(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_BUILD}")
|
set(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_BUILD}")
|
||||||
|
execute_process(COMMAND bash -c "echo -ne \"`uname -r | awk -F'.' '{print $5\".\"$6\".\"$7}'`\"" OUTPUT_VARIABLE SYSTEM_VERSION)
|
||||||
|
|
||||||
execute_process(COMMAND sh changelog.sh ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/cmake)
|
execute_process(COMMAND sh changelog.sh ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
SET(CPACK_RPM_CHANGELOG_FILE ${CMAKE_BINARY_DIR}/changelog.txt)
|
SET(CPACK_RPM_CHANGELOG_FILE ${CMAKE_BINARY_DIR}/changelog.txt)
|
||||||
|
|
||||||
# RPM Build
|
# RPM Build
|
||||||
set(CPACK_GENERATOR "RPM")
|
set(CPACK_GENERATOR "RPM")
|
||||||
set(CPACK_RPM_AUTO_GENERATED_FILE_NAME ON)
|
|
||||||
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
|
|
||||||
set(CPACK_RPM_PACKAGE_VENDOR "MESA")
|
set(CPACK_RPM_PACKAGE_VENDOR "MESA")
|
||||||
set(CPACK_RPM_PACKAGE_AUTOREQPROV "yes")
|
set(CPACK_RPM_PACKAGE_AUTOREQPROV "yes")
|
||||||
set(CPACK_RPM_PACKAGE_RELEASE_DIST "on")
|
set(CPACK_RPM_PACKAGE_RELEASE_LIBRARY "on")
|
||||||
set(CPACK_RPM_DEBUGINFO_PACKAGE "on")
|
set(CPACK_RPM_DEBUGINFO_PACKAGE "on")
|
||||||
|
set(CPACK_RPM_PACKAGE_DEBUG 1)
|
||||||
|
|
||||||
set(CPACK_RPM_COMPONENT_INSTALL ON)
|
set(CPACK_RPM_COMPONENT_INSTALL ON)
|
||||||
set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
|
set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
|
||||||
set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
|
set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
|
||||||
set(CPACK_COMPONENT_HEADER_DISPLAY_NAME "develop")
|
set(CPACK_COMPONENT_HEADER_DISPLAY_NAME "develop")
|
||||||
|
|
||||||
set(CPACK_COMPONENT_LIBRARIES_REQUIRED TRUE)
|
set(CPACK_COMPONENT_LIBRARIES_REQUIRED TRUE)
|
||||||
set(CPACK_RPM_LIBRARIES_PACKAGE_NAME ${MY_RPM_NAME_PREFIX})
|
|
||||||
set(CPACK_COMPONENT_LIBRARIES_GROUP "LIBRARIES")
|
|
||||||
set(CPACK_COMPONENT_EXECUTABLE_GROUP "LIBRARIES")
|
|
||||||
set(CPACK_COMPONENT_PROFILE_GROUP "LIBRARIES")
|
|
||||||
|
|
||||||
set(CPACK_COMPONENT_HEADER_REQUIRED TRUE)
|
set(CPACK_COMPONENT_HEADER_REQUIRED TRUE)
|
||||||
set(CPACK_RPM_HEADER_PACKAGE_NAME "${MY_RPM_NAME_PREFIX}-devel")
|
set(CPACK_RPM_HEADER_PACKAGE_NAME "${MY_RPM_NAME_PREFIX}-devel")
|
||||||
|
set(CPACK_RPM_LIBRARIES_PACKAGE_NAME ${MY_RPM_NAME_PREFIX})
|
||||||
|
|
||||||
|
set(CPACK_RPM_FILE_NAME "${CPACK_RPM_LIBRARIES_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||||
|
set(CPACK_RPM_LIBRARIES_DEBUGINFO_FILE_NAME "${CPACK_RPM_LIBRARIES_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||||
|
set(CPACK_COMPONENT_LIBRARIES_GROUP "libraries")
|
||||||
|
set(CPACK_COMPONENT_EXECUTABLE_GROUP "libraries")
|
||||||
|
set(CPACK_COMPONENT_PROFILE_GROUP "libraries")
|
||||||
|
|
||||||
|
set(CPACK_RPM_HEADER_FILE_NAME "${CPACK_RPM_HEADER_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||||
|
set(CPACK_RPM_HEADER_DEBUGINFO_FILE_NAME "${CPACK_RPM_HEADER_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||||
set(CPACK_COMPONENT_HEADER_GROUP "header")
|
set(CPACK_COMPONENT_HEADER_GROUP "header")
|
||||||
|
|
||||||
set(CPACK_RPM_HEADER_PACKAGE_REQUIRES_PRE ${CPACK_RPM_LIBRARIES_PACKAGE_NAME})
|
set(CPACK_RPM_HEADER_PACKAGE_REQUIRES_PRE ${CPACK_RPM_LIBRARIES_PACKAGE_NAME})
|
||||||
|
|||||||
@@ -16,11 +16,12 @@ void *test_handle = NULL;
|
|||||||
int g_mode = 0;
|
int g_mode = 0;
|
||||||
int g_log_num = 0;
|
int g_log_num = 0;
|
||||||
int g_thread_num = 0;
|
int g_thread_num = 0;
|
||||||
|
int g_log_print_way = 0;
|
||||||
const char *g_zlog_conf = NULL;
|
const char *g_zlog_conf = NULL;
|
||||||
volatile long g_start_time = 0;
|
volatile long g_start_time = 0;
|
||||||
volatile long g_end_time = 0;
|
volatile long g_end_time = 0;
|
||||||
|
|
||||||
void call_logger(int log_num, int thread_num)
|
void call_logger(int log_num, int thread_num, int way)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
struct timespec start, end;
|
struct timespec start, end;
|
||||||
@@ -40,12 +41,25 @@ void call_logger(int log_num, int thread_num)
|
|||||||
}
|
}
|
||||||
for(i = 0; i < log_num; i++)
|
for(i = 0; i < log_num; i++)
|
||||||
{
|
{
|
||||||
MESA_handle_runtime_log(sample_handle, RLOG_LV_DEBUG, "sample", "sample_handle MESA_handle_runtime_log, i = %d, thread_num = %d", i, thread_num);
|
switch (way)
|
||||||
//sleep(1);
|
{
|
||||||
|
case 1:
|
||||||
|
MESA_handle_runtime_log(sample_handle, RLOG_LV_DEBUG, "sample", "sample_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
||||||
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(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);
|
break;
|
||||||
//sleep(1);
|
case 2:
|
||||||
//MESA_HANDLE_RUNTIME_LOG(test_handle, RLOG_LV_FATAL, "test", "test_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
MESA_HANDLE_RUNTIME_LOG_RATELIMIT(sample_handle, RLOG_LV_DEBUG, "sample", "sample_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
||||||
|
MESA_HANDLE_RUNTIME_LOG_RATELIMIT(test_handle, RLOG_LV_INFO, "test", "test_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
MESA_HANDLE_RUNTIME_LOG(sample_handle, RLOG_LV_DEBUG, "sample", "sample_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
||||||
|
MESA_HANDLE_RUNTIME_LOG(test_handle, RLOG_LV_INFO, "test", "test_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// if (i % 10000 == 0)
|
||||||
|
// sleep(1);
|
||||||
}
|
}
|
||||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||||
end_time = end.tv_sec*1000000 + end.tv_nsec/1000;
|
end_time = end.tv_sec*1000000 + end.tv_nsec/1000;
|
||||||
@@ -70,7 +84,7 @@ void *thread_logger(void *arg)
|
|||||||
{
|
{
|
||||||
int thread_num = (int)(unsigned long long)arg;
|
int thread_num = (int)(unsigned long long)arg;
|
||||||
printf("thread %d created! \n", thread_num);
|
printf("thread %d created! \n", thread_num);
|
||||||
call_logger(g_log_num, thread_num);
|
call_logger(g_log_num, thread_num, g_log_print_way);
|
||||||
printf("thread %d finished! \n", thread_num);
|
printf("thread %d finished! \n", thread_num);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -96,20 +110,39 @@ void sig_hup_handler(int sig)
|
|||||||
MESA_handle_runtime_log_reconstruction(g_zlog_conf);
|
MESA_handle_runtime_log_reconstruction(g_zlog_conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sig_user1_handler(int sig)
|
||||||
|
{
|
||||||
|
printf("SIGUSR1 recviced! set interval:3 burst:5\n");
|
||||||
|
MESA_set_runtime_log_handle_ratelimit(sample_handle, 3, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sig_user2_handler(int sig)
|
||||||
|
{
|
||||||
|
printf("SIGUSR2 recviced! set interval:5 burst:3\n");
|
||||||
|
MESA_set_runtime_log_handle_ratelimit(sample_handle, 5, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sig_min_handler(int sig)
|
||||||
|
{
|
||||||
|
printf("SIGRTMIN recviced! unlimit\n");
|
||||||
|
MESA_set_runtime_log_handle_ratelimit(sample_handle, 0, 3);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char ** args)
|
int main(int argc, char ** args)
|
||||||
{
|
{
|
||||||
pthread_t t[MAX_THREAD_NUM];
|
pthread_t t[MAX_THREAD_NUM];
|
||||||
int i = 0;
|
int i = 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) $mode[1 or 2] $zlog_conf_path $thread_num $log_num $log_print_way[1 2 3]\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
g_mode = atoi(args[1]);
|
g_mode = atoi(args[1]);
|
||||||
g_zlog_conf = args[2];
|
g_zlog_conf = args[2];
|
||||||
g_thread_num = atoi(args[3]);
|
g_thread_num = atoi(args[3]);
|
||||||
g_log_num = atoi(args[4]);
|
g_log_num = atoi(args[4]);
|
||||||
|
g_log_print_way = atoi(args[5]);
|
||||||
|
|
||||||
if(g_thread_num <= 0 || g_log_num <= 0)
|
if(g_thread_num <= 0 || g_log_num <= 0)
|
||||||
{
|
{
|
||||||
@@ -144,6 +177,9 @@ int main(int argc, char ** args)
|
|||||||
}
|
}
|
||||||
signal(SIGINT, sig_int_handler);
|
signal(SIGINT, sig_int_handler);
|
||||||
signal(SIGHUP, sig_hup_handler);
|
signal(SIGHUP, sig_hup_handler);
|
||||||
|
signal(SIGUSR1, sig_user1_handler);
|
||||||
|
signal(SIGUSR2, sig_user2_handler);
|
||||||
|
signal(SIGRTMIN, sig_min_handler);
|
||||||
while(1)
|
while(1)
|
||||||
;
|
;
|
||||||
//MESA_destroy_runtime_log_handle(sample_handle);
|
//MESA_destroy_runtime_log_handle(sample_handle);
|
||||||
|
|||||||
@@ -14,10 +14,21 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#define RLOG_LV_DEBUG 10
|
#define RLOG_LV_DEBUG 10
|
||||||
#define RLOG_LV_INFO 20
|
#define RLOG_LV_INFO 20
|
||||||
#define RLOG_LV_FATAL 30
|
#define RLOG_LV_FATAL 30
|
||||||
|
|
||||||
|
typedef struct log_ratelimit_s
|
||||||
|
{
|
||||||
|
int interval;
|
||||||
|
int burst;
|
||||||
|
int printed;
|
||||||
|
int missed;
|
||||||
|
long begin;
|
||||||
|
pthread_mutex_t mutex;
|
||||||
|
}log_ratelimit_t;
|
||||||
|
|
||||||
int MESA_handle_runtime_log_creation(const char *conf_path);
|
int MESA_handle_runtime_log_creation(const char *conf_path);
|
||||||
int MESA_handle_runtime_log_reconstruction(const char *conf_path);
|
int MESA_handle_runtime_log_reconstruction(const char *conf_path);
|
||||||
@@ -27,6 +38,15 @@ void MESA_handle_runtime_log_destruction();
|
|||||||
MESA_handle_runtime_log((handle), (lv), (mod), "file %s, line %d, " fmt, \
|
MESA_handle_runtime_log((handle), (lv), (mod), "file %s, line %d, " fmt, \
|
||||||
__FILE__, __LINE__, ##args)
|
__FILE__, __LINE__, ##args)
|
||||||
|
|
||||||
|
#define MESA_HANDLE_RUNTIME_LOG_RATELIMIT(handle, lv, mod, fmt, args...) \
|
||||||
|
({ \
|
||||||
|
static log_ratelimit_t _rs = { \
|
||||||
|
.mutex = PTHREAD_MUTEX_INITIALIZER, \
|
||||||
|
}; \
|
||||||
|
if (MESA_runtime_log_ratelimit((handle), (&_rs), (lv), (mod), (__func__))) \
|
||||||
|
MESA_handle_runtime_log((handle), (lv), (mod), fmt, ##args); \
|
||||||
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* name: MESA_create_runtime_log_handle
|
* name: MESA_create_runtime_log_handle
|
||||||
* functionality: get runtime_log handle;
|
* functionality: get runtime_log handle;
|
||||||
@@ -63,6 +83,18 @@ void MESA_handle_runtime_log(void *handle, int level, const char *module, const
|
|||||||
*/
|
*/
|
||||||
void MESA_destroy_runtime_log_handle(void *handle);
|
void MESA_destroy_runtime_log_handle(void *handle);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* name: MESA_set_runtime_log_handle_ratelimit
|
||||||
|
* functionality: set not more than @burst in every @interval when appends log message
|
||||||
|
* params:
|
||||||
|
* handle: runtime log handle which is going to be released;
|
||||||
|
* interval: interval time(second). if set '0', it means unlimit.
|
||||||
|
* burst: in interval time max count
|
||||||
|
* returns:
|
||||||
|
* none;
|
||||||
|
*/
|
||||||
|
void MESA_set_runtime_log_handle_ratelimit(void *handle, int interval, int burst);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#define MAX_HANDLE_LOG_PATH 4096
|
#define MAX_HANDLE_LOG_PATH 4096
|
||||||
|
#define DEFAULT_BURST 10
|
||||||
|
#define DEFAULT_INTERVAL 5
|
||||||
|
|
||||||
static int g_zlog_inited = 0;
|
static int g_zlog_inited = 0;
|
||||||
static int g_zlog_conf_fp = -1;
|
static int g_zlog_conf_fp = -1;
|
||||||
static char global_conf_filepath[MAX_HANDLE_LOG_PATH] = "";
|
static char global_conf_filepath[MAX_HANDLE_LOG_PATH] = "";
|
||||||
@@ -16,6 +19,9 @@ static char tmp_conf_filepath[MAX_HANDLE_LOG_PATH] = "";
|
|||||||
|
|
||||||
typedef struct log_handle_t
|
typedef struct log_handle_t
|
||||||
{
|
{
|
||||||
|
int interval;
|
||||||
|
int burst;
|
||||||
|
pthread_mutex_t mutex;
|
||||||
int runtime_log_level;
|
int runtime_log_level;
|
||||||
zlog_category_t *zc;
|
zlog_category_t *zc;
|
||||||
const char *global_conf_path;
|
const char *global_conf_path;
|
||||||
@@ -47,7 +53,6 @@ static __attribute__((__used__)) const char * GIT_VERSION_UNKNOWN = NULL;
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int create_dir(const char *dir_path, int path_len)
|
static int create_dir(const char *dir_path, int path_len)
|
||||||
{
|
{
|
||||||
if(dir_path == NULL)
|
if(dir_path == NULL)
|
||||||
@@ -163,6 +168,60 @@ static void snapshot_handle_info(const char *handle_name, const char *log_path,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void log_update_time(log_handle_t *p_handle, log_ratelimit_t *rs, int level, const char *module, const char *func)
|
||||||
|
{
|
||||||
|
struct timespec current = {0, 0};
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, ¤t);
|
||||||
|
if (((long)(rs->begin + rs->interval - current.tv_sec)) < 0)
|
||||||
|
{
|
||||||
|
if (rs->missed)
|
||||||
|
{
|
||||||
|
zlog(p_handle->zc, p_handle->runtime_log_file, strlen(p_handle->runtime_log_file), module, strlen(module), __LINE__, level, "%s: %d callbacks suppressed\n", func, rs->missed);
|
||||||
|
rs->missed = 0;
|
||||||
|
}
|
||||||
|
rs->begin = current.tv_sec;
|
||||||
|
rs->printed = 0;
|
||||||
|
}
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MESA_runtime_log_ratelimit(void *handle, log_ratelimit_t *rs, int level, const char *module, const char *func)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
struct timespec timer = {0, 0};
|
||||||
|
log_handle_t *p_handle = (log_handle_t *)handle;
|
||||||
|
|
||||||
|
if (pthread_mutex_lock(&rs->mutex) != 0)return 0;
|
||||||
|
|
||||||
|
if (!rs->begin)
|
||||||
|
{
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &timer);
|
||||||
|
rs->begin = timer.tv_sec;
|
||||||
|
}
|
||||||
|
rs->burst = p_handle->burst;
|
||||||
|
rs->interval = p_handle->interval;
|
||||||
|
if (!rs->interval)
|
||||||
|
{
|
||||||
|
pthread_mutex_unlock(&rs->mutex);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
log_update_time(p_handle, rs, level, module, func);
|
||||||
|
|
||||||
|
if (rs->burst && rs->burst > rs->printed)
|
||||||
|
{
|
||||||
|
rs->printed++;
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rs->missed++;
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&rs->mutex);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void *MESA_create_runtime_log_handle(const char *file_path, int level)
|
void *MESA_create_runtime_log_handle(const char *file_path, int level)
|
||||||
{
|
{
|
||||||
if(file_path == NULL)
|
if(file_path == NULL)
|
||||||
@@ -199,13 +258,19 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level)
|
|||||||
strncpy(p_handle->runtime_log_file, file_path, sizeof(p_handle->runtime_log_file) - 1);
|
strncpy(p_handle->runtime_log_file, file_path, sizeof(p_handle->runtime_log_file) - 1);
|
||||||
p_handle->runtime_log_level = level;
|
p_handle->runtime_log_level = level;
|
||||||
p_handle->zc = zc;
|
p_handle->zc = zc;
|
||||||
|
p_handle->burst = DEFAULT_BURST;
|
||||||
|
p_handle->interval = DEFAULT_INTERVAL;
|
||||||
|
pthread_mutex_init(&p_handle->mutex, NULL);
|
||||||
|
|
||||||
return (void *)p_handle;
|
return (void *)p_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MESA_destroy_runtime_log_handle(void *handle)
|
void MESA_destroy_runtime_log_handle(void *handle)
|
||||||
{
|
{
|
||||||
|
log_handle_t *p_handle = (log_handle_t *)handle;
|
||||||
if(handle != NULL)
|
if(handle != NULL)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_destroy(&p_handle->mutex);
|
||||||
free(handle);
|
free(handle);
|
||||||
handle = NULL;
|
handle = NULL;
|
||||||
}
|
}
|
||||||
@@ -213,23 +278,34 @@ void MESA_destroy_runtime_log_handle(void *handle)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MESA_handle_runtime_log(void *handle, int level, const char *module, const char *fmt, ...)
|
void MESA_handle_runtime_log(void *handle, int level, const char *module, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
va_list ap;
|
||||||
log_handle_t *p_handle = (log_handle_t *)handle;
|
log_handle_t *p_handle = (log_handle_t *)handle;
|
||||||
|
|
||||||
if(p_handle == NULL || p_handle->runtime_log_file == NULL)return;
|
if(p_handle == NULL || p_handle->runtime_log_file == NULL)return;
|
||||||
|
|
||||||
if(p_handle->zc == NULL)return;
|
if(p_handle->zc == NULL)return;
|
||||||
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, fmt);
|
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);
|
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);
|
va_end(ap);
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MESA_set_runtime_log_handle_ratelimit(void *handle, int interval, int burst)
|
||||||
|
{
|
||||||
|
log_handle_t *p_handle = (log_handle_t *)handle;
|
||||||
|
|
||||||
|
if ((p_handle == NULL) || (interval < 0) || (burst < 0))return;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&p_handle->mutex);
|
||||||
|
p_handle->interval = interval;
|
||||||
|
p_handle->burst = burst;
|
||||||
|
pthread_mutex_unlock(&p_handle->mutex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int MESA_handle_runtime_log_creation(const char *conf_path)
|
int MESA_handle_runtime_log_creation(const char *conf_path)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user