Compare commits
33 Commits
v2.0.2-tes
...
CI-aarch64
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b9ac69ecc | ||
|
|
7ed1582309 | ||
|
|
67ed711088 | ||
|
|
1dd9e1e0f2 | ||
|
|
7fa29b1a00 | ||
|
|
8680c2f4f5 | ||
|
|
c0620c8d25 | ||
|
|
4d64f0cf06 | ||
|
|
b677bb6c71 | ||
|
|
f76af2f036 | ||
|
|
31bd3fed9c | ||
|
|
9ecf746f0f | ||
|
|
040ce55a1b | ||
|
|
cb4ad71c50 | ||
|
|
02100e4232 | ||
|
|
63f5231e9f | ||
|
|
15fe685383 | ||
|
|
e1057e6d0c | ||
|
|
2e4e4dff17 | ||
|
|
150255033c | ||
|
|
0f0e55c877 | ||
|
|
8857f282b9 | ||
|
|
cc0912eed0 | ||
|
|
186571e823 | ||
|
|
e39e641103 | ||
|
|
f461cbbc3d | ||
|
|
05a8eded4b | ||
|
|
92815d2d1f | ||
|
|
ea4185727b | ||
|
|
7066b2b086 | ||
|
|
52db3f0001 | ||
|
|
7417fed852 | ||
|
|
0cb2236be0 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -11,7 +11,7 @@ build/
|
|||||||
core.*
|
core.*
|
||||||
version.txt
|
version.txt
|
||||||
demo/test_handle_logger
|
demo/test_handle_logger
|
||||||
cmake-build-debug
|
cmake-build-*
|
||||||
build-*/
|
build-*/
|
||||||
GPATH
|
GPATH
|
||||||
GRTAGS
|
GRTAGS
|
||||||
|
|||||||
170
.gitlab-ci.yml
170
.gitlab-ci.yml
@@ -1,108 +1,180 @@
|
|||||||
image: "git.mesalab.cn:7443/mesa_platform/build-env:master"
|
|
||||||
variables:
|
variables:
|
||||||
GIT_STRATEGY: "clone"
|
GIT_STRATEGY: "clone"
|
||||||
|
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/
|
BUILD_PADDING_PREFIX: /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX/
|
||||||
INSTALL_PREFIX: "/opt/MESA/lib/"
|
INSTALL_DEPENDENCY_LIBRARY: libasan
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
|
- test
|
||||||
|
|
||||||
.build_by_travis:
|
.build_before_script:
|
||||||
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
|
||||||
script:
|
|
||||||
- yum makecache
|
|
||||||
- ./ci/travis.sh
|
|
||||||
- cd build
|
|
||||||
tags:
|
|
||||||
- share
|
|
||||||
|
|
||||||
branch_build_debug:
|
|
||||||
|
###############################################################################
|
||||||
|
# build on x86_64 Rocky8
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
.build_by_travis_for_x86_64_rocky8:
|
||||||
stage: build
|
stage: build
|
||||||
extends: .build_by_travis
|
image: $BUILD_IMAGE_X86_64_ROCKY8
|
||||||
|
extends: .build_before_script
|
||||||
|
script:
|
||||||
|
- ./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
|
||||||
|
- ctest --verbose
|
||||||
|
|
||||||
|
|
||||||
|
branch_build_debug_for_x86_64_rocky8:
|
||||||
|
stage: build
|
||||||
|
extends: .build_by_travis_for_x86_64_rocky8
|
||||||
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:
|
branch_build_release_for_x86_64_rocky8:
|
||||||
stage: build
|
stage: build
|
||||||
variables:
|
variables:
|
||||||
BUILD_TYPE: RelWithDebInfo
|
BUILD_TYPE: RelWithDebInfo
|
||||||
extends: .build_by_travis
|
extends: .build_by_travis_for_x86_64_rocky8
|
||||||
except:
|
except:
|
||||||
|
- /^develop.*$/i
|
||||||
|
- /^master.*$/i
|
||||||
- /^dev*.*$/i
|
- /^dev*.*$/i
|
||||||
- /^rel*.*$/i
|
- /^rel*.*$/i
|
||||||
- /^master.*$/i
|
|
||||||
- tags
|
- tags
|
||||||
|
|
||||||
develop_build_debug:
|
release_build_debug_for_x86_64_rocky88:
|
||||||
stage: build
|
stage: build
|
||||||
extends: .build_by_travis
|
|
||||||
variables:
|
variables:
|
||||||
BUILD_TYPE: Debug
|
BUILD_TYPE: Debug
|
||||||
PACKAGE: 1
|
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:
|
artifacts:
|
||||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-debug"
|
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-debug"
|
||||||
paths:
|
paths:
|
||||||
- build/*.rpm
|
- build/*.rpm
|
||||||
only:
|
only:
|
||||||
- /^dev*.*$/i
|
- tags
|
||||||
- /^rel*.*$/i
|
|
||||||
- /^master.*$/i
|
|
||||||
|
|
||||||
develop_build_release:
|
release_build_release_for_x86_64_rocky8:
|
||||||
stage: build
|
|
||||||
extends: .build_by_travis
|
|
||||||
variables:
|
|
||||||
BUILD_TYPE: RelWithDebInfo
|
|
||||||
PACKAGE: 1
|
|
||||||
artifacts:
|
|
||||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
|
||||||
paths:
|
|
||||||
- build/*.rpm
|
|
||||||
only:
|
|
||||||
- /^dev*.*$/i
|
|
||||||
- /^rel*.*$/i
|
|
||||||
- /^master.*$/i
|
|
||||||
|
|
||||||
|
|
||||||
release_build_release:
|
|
||||||
stage: build
|
stage: build
|
||||||
variables:
|
variables:
|
||||||
BUILD_TYPE: RelWithDebInfo
|
BUILD_TYPE: RelWithDebInfo
|
||||||
PACKAGE: 1
|
PACKAGE: 1
|
||||||
UPLOAD: 1
|
UPLOAD_RPM: 1
|
||||||
PULP3_REPO_NAME: framework-stable-x86_64.el7
|
SYMBOL_TARGET: libMESA_handle_logger
|
||||||
PULP3_DIST_NAME: framework-stable-x86_64.el7
|
PULP3_REPO_NAME: framework-stable-x86_64.el8
|
||||||
extends: .build_by_travis
|
PULP3_DIST_NAME: framework-stable-x86_64.el8
|
||||||
|
extends: .build_by_travis_for_x86_64_rocky8
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
||||||
paths:
|
paths:
|
||||||
- build/*.rpm
|
- build/*.rpm
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
except:
|
|
||||||
- /^v[0-9].*-testing$/i
|
|
||||||
|
|
||||||
testing_build_release:
|
###############################################################################
|
||||||
|
# build on aarch64 Rocky9
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
.build_by_travis_for_aarch64_rocky9:
|
||||||
|
stage: build
|
||||||
|
image: $BUILD_IMAGE_AARCH64_ROCKY9
|
||||||
|
extends: .build_before_script
|
||||||
|
script:
|
||||||
|
- ./ci/travis.sh
|
||||||
|
tags:
|
||||||
|
- tsg-os-builder-aarch64
|
||||||
|
|
||||||
|
|
||||||
|
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_aarch64_rocky9
|
||||||
|
variables:
|
||||||
|
BUILD_TYPE: Debug
|
||||||
|
except:
|
||||||
|
- /^develop.*$/i
|
||||||
|
- /^master.*$/i
|
||||||
|
- /^dev*.*$/i
|
||||||
|
- /^rel*.*$/i
|
||||||
|
- tags
|
||||||
|
|
||||||
|
branch_build_release_for_aarch64_rocky9:
|
||||||
|
stage: build
|
||||||
|
variables:
|
||||||
|
BUILD_TYPE: RelWithDebInfo
|
||||||
|
extends: .build_by_travis_for_aarch64_rocky9
|
||||||
|
except:
|
||||||
|
- /^develop.*$/i
|
||||||
|
- /^master.*$/i
|
||||||
|
- /^dev*.*$/i
|
||||||
|
- /^rel*.*$/i
|
||||||
|
- tags
|
||||||
|
|
||||||
|
release_build_debug_for_aarch64_rocky9:
|
||||||
|
stage: build
|
||||||
|
variables:
|
||||||
|
BUILD_TYPE: Debug
|
||||||
|
PACKAGE: 1
|
||||||
|
UPLOAD_RPM: 1
|
||||||
|
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:
|
||||||
|
- build/*.rpm
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
|
||||||
|
release_build_release_for_aarch64_rocky9:
|
||||||
stage: build
|
stage: build
|
||||||
variables:
|
variables:
|
||||||
BUILD_TYPE: RelWithDebInfo
|
BUILD_TYPE: RelWithDebInfo
|
||||||
PACKAGE: 1
|
PACKAGE: 1
|
||||||
UPLOAD: 1
|
UPLOAD_RPM: 1
|
||||||
PULP3_REPO_NAME: framework-testing-x86_64.el7
|
SYMBOL_TARGET: libMESA_handle_logger
|
||||||
PULP3_DIST_NAME: framework-testing-x86_64.el7
|
PULP3_REPO_NAME: framework-stable-aarch64.el9
|
||||||
extends: .build_by_travis
|
PULP3_DIST_NAME: framework-stable-aarch64.el9
|
||||||
|
extends: .build_by_travis_for_aarch64_rocky9
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
name: "MESA_handle_logger-$CI_COMMIT_REF_NAME-release"
|
||||||
paths:
|
paths:
|
||||||
- build/*.rpm
|
- build/*.rpm
|
||||||
only:
|
only:
|
||||||
- /^v[0-9].*-testing$/i
|
- tags
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required (VERSION 2.8)
|
cmake_minimum_required (VERSION 2.8)
|
||||||
|
|
||||||
set(lib_name MESA_handle_logger2)
|
set(lib_name MESA_handle_logger)
|
||||||
|
|
||||||
project (${lib_name})
|
project (${lib_name})
|
||||||
|
|
||||||
@@ -37,9 +37,10 @@ add_subdirectory(zlog)
|
|||||||
|
|
||||||
# Shared Library Output
|
# Shared Library Output
|
||||||
add_library(${lib_name}_shared SHARED src/MESA_handle_logger.c)
|
add_library(${lib_name}_shared SHARED src/MESA_handle_logger.c)
|
||||||
target_link_libraries(${lib_name}_shared zlog_shared)
|
target_link_libraries(${lib_name}_shared zlog_static)
|
||||||
set_target_properties(${lib_name}_shared PROPERTIES LINK_FLAGS
|
set_target_properties(${lib_name}_shared PROPERTIES LINK_FLAGS
|
||||||
"-Wl,--version-script=${PROJECT_SOURCE_DIR}/src/version.map")
|
"-Wl,--version-script=${PROJECT_SOURCE_DIR}/src/version.map")
|
||||||
|
target_link_libraries(${lib_name}_shared pthread)
|
||||||
|
|
||||||
if(DEFINED MESA_SHARED_INSTALL_DIR)
|
if(DEFINED MESA_SHARED_INSTALL_DIR)
|
||||||
set_target_properties(${lib_name}_shared PROPERTIES OUTPUT_NAME ${lib_name} LIBRARY_OUTPUT_DIRECTORY ${MESA_SHARED_INSTALL_DIR})
|
set_target_properties(${lib_name}_shared PROPERTIES OUTPUT_NAME ${lib_name} LIBRARY_OUTPUT_DIRECTORY ${MESA_SHARED_INSTALL_DIR})
|
||||||
@@ -52,7 +53,7 @@ set_target_properties(${lib_name}_shared PROPERTIES SOVERSION ${LIB_MAJOR_VERSIO
|
|||||||
|
|
||||||
# static Library Output
|
# static Library Output
|
||||||
add_library(${lib_name}_static STATIC src/MESA_handle_logger.c)
|
add_library(${lib_name}_static STATIC src/MESA_handle_logger.c)
|
||||||
target_link_libraries(${lib_name}_static zlog_shared)
|
target_link_libraries(${lib_name}_static zlog_static)
|
||||||
set_target_properties(${lib_name}_static PROPERTIES OUTPUT_NAME ${lib_name})
|
set_target_properties(${lib_name}_static PROPERTIES OUTPUT_NAME ${lib_name})
|
||||||
|
|
||||||
set(CMAKE_INSTALL_PREFIX /opt/MESA)
|
set(CMAKE_INSTALL_PREFIX /opt/MESA)
|
||||||
@@ -61,18 +62,16 @@ install(FILES inc/MESA_handle_logger.h DESTINATION
|
|||||||
${CMAKE_INSTALL_PREFIX}/include/MESA COMPONENT devel)
|
${CMAKE_INSTALL_PREFIX}/include/MESA COMPONENT devel)
|
||||||
install(TARGETS ${lib_name}_shared LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib COMPONENT LIBRARIES)
|
install(TARGETS ${lib_name}_shared LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib COMPONENT LIBRARIES)
|
||||||
install(FILES inc/MESA_handle_logger.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MESA COMPONENT HEADER)
|
install(FILES inc/MESA_handle_logger.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MESA COMPONENT HEADER)
|
||||||
|
install(FILES conf/MESA_handle_logger.conf DESTINATION /usr/lib/tmpfiles.d/ COMPONENT PROFILE)
|
||||||
install(CODE "execute_process( \
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E create_symlink \
|
|
||||||
libMESA_handle_logger2.so \
|
|
||||||
${CMAKE_INSTALL_PREFIX}/lib/libMESA_handle_logger.so \
|
|
||||||
)"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
add_executable(${lib_name}_demo demo/test_handle_logger.c)
|
add_executable(${lib_name}_demo demo/test_handle_logger.c)
|
||||||
target_link_libraries(${lib_name}_demo rt pthread ${lib_name}_static)
|
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)
|
include(Package)
|
||||||
|
|||||||
17
ci/travis.sh
17
ci/travis.sh
@@ -33,7 +33,10 @@ env | sort
|
|||||||
: "${COMPILER_IS_GNUCXX:=OFF}"
|
: "${COMPILER_IS_GNUCXX:=OFF}"
|
||||||
|
|
||||||
# Install dependency from YUM
|
# Install dependency from YUM
|
||||||
#yum install -y mrzcpd framework numactl-devel zlib-devel librdkafka-devel systemd-devel
|
if [ -n "${INSTALL_DEPENDENCY_LIBRARY}" ]; then
|
||||||
|
yum install -y $INSTALL_DEPENDENCY_LIBRARY
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir build || true
|
mkdir build || true
|
||||||
cd build
|
cd build
|
||||||
|
|
||||||
@@ -41,6 +44,8 @@ cmake3 -DCMAKE_CXX_FLAGS=$CXX_FLAGS \
|
|||||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
||||||
-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
|
-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
|
||||||
-DENABLE_DEVEL=$ENABLE_DEVEL_SWITCH \
|
-DENABLE_DEVEL=$ENABLE_DEVEL_SWITCH \
|
||||||
|
-DASAN_OPTION=$ASAN_OPTION \
|
||||||
|
-DVERSION_DAILY_BUILD=$TESTING_VERSION_BUILD \
|
||||||
..
|
..
|
||||||
|
|
||||||
make
|
make
|
||||||
@@ -49,13 +54,7 @@ if [ -n "${PACKAGE}" ]; then
|
|||||||
make package
|
make package
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${UPLOAD}" ]; then
|
if [ -n "${UPLOAD_RPM}" ]; then
|
||||||
cp ~/rpm_upload_tools.py ./
|
cp ~/rpm_upload_tools.py ./
|
||||||
python3 rpm_upload_tools.py ${PULP3_REPO_NAME} ${PULP3_DIST_NAME} *.rpm
|
python3 rpm_upload_tools.py ${PULP3_REPO_NAME} ${PULP3_DIST_NAME} *.rpm
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#if [ -n "${UPLOAD_SYMBOL_FILES}" ]; then
|
|
||||||
# rpm -i tfe*debuginfo*.rpm
|
|
||||||
# cp /usr/lib/debug/opt/tsg/tfe/bin/tfe.debug /tmp/tfe.debuginfo.${CI_COMMIT_SHORT_SHA}
|
|
||||||
# sentry-cli upload-dif -t elf /tmp/tfe.debuginfo.${CI_COMMIT_SHORT_SHA}
|
|
||||||
#fi
|
|
||||||
@@ -12,38 +12,38 @@ 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)
|
||||||
|
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_LIBRARY "on")
|
set(CPACK_RPM_PACKAGE_RELEASE_DIST "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_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})
|
||||||
set(CPACK_RPM_HEADER_PACKAGE_CONFLICTS ${CPACK_RPM_HEADER_PACKAGE_NAME})
|
set(CPACK_RPM_HEADER_PACKAGE_CONFLICTS ${CPACK_RPM_HEADER_PACKAGE_NAME})
|
||||||
|
|
||||||
set(CPACK_COMPONENTS_ALL LIBRARIES HEADER EXECUTABLE)
|
set(CPACK_COMPONENTS_ALL LIBRARIES HEADER EXECUTABLE PROFILE)
|
||||||
|
|
||||||
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PostInstall.in)
|
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PostInstall.in)
|
||||||
set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PostInstall.in)
|
set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PostInstall.in)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
set(__SOURCE_AUTORESIVISION ${CMAKE_SOURCE_DIR}/autorevision.sh)
|
set(__SOURCE_AUTORESIVISION ${CMAKE_SOURCE_DIR}/autorevision.sh)
|
||||||
set(__AUTORESIVISION ${CMAKE_BINARY_DIR}/autorevision.sh)
|
set(__AUTORESIVISION ${CMAKE_BINARY_DIR}/autorevision.sh)
|
||||||
set(__VERSION_CACHE ${CMAKE_SOURCE_DIR}/version.txt)
|
set(__VERSION_CACHE ${CMAKE_BINARY_DIR}/version.txt)
|
||||||
set(__VERSION_CONFIG ${CMAKE_BINARY_DIR}/version.cmake)
|
set(__VERSION_CONFIG ${CMAKE_BINARY_DIR}/version.cmake)
|
||||||
|
|
||||||
file(COPY ${__SOURCE_AUTORESIVISION} DESTINATION ${CMAKE_BINARY_DIR}
|
file(COPY ${__SOURCE_AUTORESIVISION} DESTINATION ${CMAKE_BINARY_DIR}
|
||||||
@@ -38,16 +38,12 @@ set(VERSION_BUILD "${VCS_SHORT_HASH}")
|
|||||||
# print information
|
# print information
|
||||||
message(STATUS "Version: ${VERSION}-${VERSION_BUILD}")
|
message(STATUS "Version: ${VERSION}-${VERSION_BUILD}")
|
||||||
|
|
||||||
if(NOT DEFINE_GIT_VERSION)
|
option(DEFINE_GIT_VERSION "Set DEFINE_GIT_VERSION to TRUE or FALSE" TRUE)
|
||||||
option(DEFINE_GIT_VERSION "Set DEFINE_GIT_VERSION to OFF" OFF)
|
|
||||||
|
|
||||||
set(GIT_VERSION
|
|
||||||
"${VERSION}-${CMAKE_BUILD_TYPE}-${VERSION_BUILD}-${VCS_BRANCH}-${VCS_TAG}-${VCS_DATE}")
|
|
||||||
string(REGEX REPLACE "[-:+/\\.]" "_" GIT_VERSION ${GIT_VERSION})
|
|
||||||
|
|
||||||
if(DEFINE_GIT_VERSION)
|
if(DEFINE_GIT_VERSION)
|
||||||
add_definitions(-DGIT_VERSION=${GIT_VERSION})
|
set(GIT_VERSION
|
||||||
option(DEFINE_GIT_VERSION "Set DEFINE_GIT_VERSION to OFF" ON)
|
"${VERSION}-${CMAKE_BUILD_TYPE}-${VERSION_BUILD}-${VCS_BRANCH}-${VCS_TAG}-${VCS_DATE}")
|
||||||
endif()
|
string(REGEX REPLACE "[-:+/\\.]" "_" GIT_VERSION ${GIT_VERSION})
|
||||||
|
|
||||||
|
add_definitions(-DGIT_VERSION=${GIT_VERSION})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
4
cmake/changelog.sh
Normal file
4
cmake/changelog.sh
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
work_path=$1
|
||||||
|
branch=`git status | grep branch | awk '{print $NF}'`
|
||||||
|
git log --branches=$branch --no-merges --date=local --show-signature --pretty="* %ad %an %ae %nhash: %H%ncommit:%n%B" | awk -F"-" '{print "- "$0}' | sed 's/- \*/\*/g' | sed 's/- $//g' | sed 's/-/ -/g' | sed 's/[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}//g' > $work_path/changelog.txt
|
||||||
2
conf/MESA_handle_logger.conf
Normal file
2
conf/MESA_handle_logger.conf
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#Type Path Mode User Group Age Argument
|
||||||
|
d /tmp/MESA_handle_logger/ 0755 - - 1h -
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
#include "MESA_handle_logger.h"
|
#include "MESA_handle_logger.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
void *sample_handle = NULL;
|
void *sample_handle = NULL;
|
||||||
@@ -12,8 +13,10 @@ void *test_handle = NULL;
|
|||||||
#define LOG_NUM 100000
|
#define LOG_NUM 100000
|
||||||
#define MAX_THREAD_NUM 65535
|
#define MAX_THREAD_NUM 65535
|
||||||
|
|
||||||
|
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_sleep_interval = 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;
|
||||||
@@ -42,7 +45,11 @@ void call_logger(int log_num, int thread_num)
|
|||||||
//sleep(1);
|
//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(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);
|
//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);
|
//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);
|
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||||
@@ -58,8 +65,9 @@ void call_logger(int log_num, int thread_num)
|
|||||||
g_end_time = end_time;
|
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("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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +88,10 @@ void sig_int_handler(int sig)
|
|||||||
MESA_destroy_runtime_log_handle(test_handle);
|
MESA_destroy_runtime_log_handle(test_handle);
|
||||||
sample_handle = NULL;
|
sample_handle = NULL;
|
||||||
test_handle = NULL;
|
test_handle = NULL;
|
||||||
MESA_handle_runtime_log_destruction();
|
if (g_mode == 2)
|
||||||
|
{
|
||||||
|
MESA_handle_runtime_log_destruction();
|
||||||
|
}
|
||||||
printf("%d thread write %d log using %ld us, avg speed %f /s, %ld -> %ld\n", g_thread_num, g_thread_num * g_log_num, g_end_time - g_start_time, ((float)(g_thread_num * g_log_num) / (float)(g_end_time - g_start_time)) * 1000000, g_start_time, g_end_time);
|
printf("%d thread write %d log using %ld us, avg speed %f /s, %ld -> %ld\n", g_thread_num, g_thread_num * g_log_num, g_end_time - g_start_time, ((float)(g_thread_num * g_log_num) / (float)(g_end_time - g_start_time)) * 1000000, g_start_time, g_end_time);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -95,51 +106,66 @@ int main(int argc, char ** args)
|
|||||||
{
|
{
|
||||||
pthread_t t[MAX_THREAD_NUM];
|
pthread_t t[MAX_THREAD_NUM];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
int ret =0;
|
||||||
|
|
||||||
if(argc != 4)
|
if (argc != 6)
|
||||||
{
|
{
|
||||||
printf("Usage: ./($app) $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;
|
return -1;
|
||||||
}
|
}
|
||||||
g_zlog_conf = args[1];
|
g_mode = atoi(args[1]);
|
||||||
g_thread_num = atoi(args[2]);
|
g_zlog_conf = args[2];
|
||||||
g_log_num = atoi(args[3]);
|
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)
|
if(g_thread_num <= 0 || g_log_num <= 0)
|
||||||
{
|
{
|
||||||
printf("Error, wrong parameter!\n");
|
printf("Error, wrong parameter!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(0 != MESA_handle_runtime_log_creation(g_zlog_conf))
|
if (g_mode == 2)
|
||||||
{
|
{
|
||||||
printf("MESA_handle_runtime_log_creation return error\n");
|
if (0 != MESA_handle_runtime_log_creation(g_zlog_conf))
|
||||||
return -1;
|
{
|
||||||
|
printf("MESA_handle_runtime_log_creation return error\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sample_handle = MESA_create_runtime_log_handle("./log/sample_log", RLOG_LV_DEBUG);
|
sample_handle = MESA_create_runtime_log_handle("./log/sample_log", RLOG_LV_DEBUG);
|
||||||
if (sample_handle == NULL)
|
if (sample_handle == NULL)
|
||||||
{
|
{
|
||||||
printf("get log sample_handle error\n");
|
printf("get log sample_handle error\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
test_handle = MESA_create_runtime_log_handle("./log/test_log", RLOG_LV_DEBUG);
|
test_handle = MESA_create_runtime_log_handle("./log/test_log", RLOG_LV_DEBUG);
|
||||||
if(test_handle == NULL)
|
if (test_handle == NULL)
|
||||||
{
|
{
|
||||||
printf("get log test_handle error\n");
|
printf("get log test_handle error\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < g_thread_num; i++)
|
for (i = 0; i < g_thread_num; i++)
|
||||||
{
|
{
|
||||||
pthread_create(&t[i], NULL, thread_logger, (void *)(unsigned long)(i));
|
pthread_create(&t[i], NULL, thread_logger, (void *)(unsigned long)(i));
|
||||||
}
|
}
|
||||||
signal(SIGINT, sig_int_handler);
|
signal(SIGINT, sig_int_handler);
|
||||||
signal(SIGHUP, sig_hup_handler);
|
signal(SIGHUP, sig_hup_handler);
|
||||||
while(1)
|
|
||||||
;
|
// 等待所有线程结束并回收
|
||||||
//MESA_destroy_runtime_log_handle(sample_handle);
|
for (i = 0; i < g_thread_num; ++i) {
|
||||||
//MESA_destroy_runtime_log_handle(test_handle);
|
ret = pthread_join(t[i], NULL);
|
||||||
//sample_handle = NULL;
|
if (ret != 0) {
|
||||||
//test_handle = NULL;
|
fprintf(stderr, "Failed to join thread %d\n", i);
|
||||||
return 0;
|
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);
|
int MESA_handle_runtime_log_reconstruction(const char *conf_path);
|
||||||
void MESA_handle_runtime_log_destruction();
|
void MESA_handle_runtime_log_destruction();
|
||||||
|
|
||||||
#define MESA_HANDLE_RUNTIME_LOG(handle, lv, mod, fmt, args...) \
|
#define MESA_HANDLE_RUNTIME_LOG(handle, level, module, format, ...) \
|
||||||
MESA_handle_runtime_log((handle), (lv), (mod), "file %s, line %d, " fmt, \
|
do \
|
||||||
__FILE__, __LINE__, ##args)
|
{ \
|
||||||
|
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
|
* name: MESA_create_runtime_log_handle
|
||||||
* functionality: get runtime_log handle;
|
* functionality: get runtime_log handle;
|
||||||
@@ -37,7 +44,7 @@ void MESA_handle_runtime_log_destruction();
|
|||||||
* not NULL, if succeeded;
|
* not NULL, if succeeded;
|
||||||
* NULL, if file is not absolute path, or failed to create log file;
|
* 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
|
* name: MESA_handle_runtime_log
|
||||||
|
|||||||
@@ -9,17 +9,18 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#define MAX_HANDLE_LOG_PATH 4096
|
#define MAX_HANDLE_LOG_PATH 4096
|
||||||
|
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] = "";
|
||||||
static char tmp_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;
|
int runtime_log_level;
|
||||||
zlog_category_t *zc;
|
zlog_category_t *zc;
|
||||||
const char *global_conf_path;
|
const char *global_conf_path;
|
||||||
char runtime_log_file[MAX_HANDLE_LOG_PATH];
|
char runtime_log_file[MAX_HANDLE_LOG_PATH];
|
||||||
} log_handle_t;
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -93,14 +94,13 @@ static int get_filepath(int fp, char *buf, int buflen)
|
|||||||
{
|
{
|
||||||
if(buf == NULL || buflen <=0)return -1;
|
if(buf == NULL || buflen <=0)return -1;
|
||||||
char proclnk[0xFFF] = "";
|
char proclnk[0xFFF] = "";
|
||||||
//int fno = fileno(fp);
|
|
||||||
int fno = fp;
|
int fno = fp;
|
||||||
sprintf(proclnk, "/proc/self/fd/%d", fno);
|
sprintf(proclnk, "/proc/self/fd/%d", fno);
|
||||||
int r = readlink(proclnk, buf, buflen);
|
int r = readlink(proclnk, buf, buflen);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char tmp_template[] = "/tmp/handle_loggger.XXXXXX";
|
//static char tmp_template[] = "/tmp/MESA_handle_loggger/handle_loggger.XXXXXX";
|
||||||
|
|
||||||
static void escape_for_zlog(char *in_buf, int buflen)
|
static void escape_for_zlog(char *in_buf, int buflen)
|
||||||
{
|
{
|
||||||
@@ -116,13 +116,26 @@ static void escape_for_zlog(char *in_buf, int buflen)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *loglevel_to_name(int level)
|
||||||
|
{
|
||||||
|
if (level <= RLOG_LV_DEBUG)
|
||||||
|
return "DEBUG";
|
||||||
|
if (level > RLOG_LV_DEBUG && level <= RLOG_LV_INFO)
|
||||||
|
return "INFO";
|
||||||
|
return "FATAL";
|
||||||
|
}
|
||||||
|
|
||||||
static void snapshot_handle_info(const char *handle_name, const char *log_path, int level)
|
static void snapshot_handle_info(const char *handle_name, const char *log_path, int level)
|
||||||
{
|
{
|
||||||
char zlog_rule_conf_content[MAX_HANDLE_LOG_PATH + 1];
|
char zlog_rule_conf_content[MAX_HANDLE_LOG_PATH + 1] = "";
|
||||||
|
static char *tmp_prefix = "/tmp/MESA_handle_logger/";
|
||||||
|
static char *zlog_conf_init_buff = "[global]\ndefault format = \"%d(%c), %V, %F, %U, %m%n\" \n[levels]\nDEBUG=10\nINFO=20\nFATAL=30\n[rules]";
|
||||||
if (g_zlog_conf_fp == -1)
|
if (g_zlog_conf_fp == -1)
|
||||||
{
|
{
|
||||||
|
if (create_path("/tmp/MESA_handle_logger/", strlen(tmp_prefix)) < 0)
|
||||||
|
return;
|
||||||
char temp_filename[1024] = "";
|
char temp_filename[1024] = "";
|
||||||
sprintf(temp_filename, "/tmp/MESA_handle_logger_%d.XXXXXX", getpid());
|
sprintf(temp_filename, "/tmp/MESA_handle_logger/MESA_logger_snapshot_%d.XXXXXX", getpid());
|
||||||
g_zlog_conf_fp = mkstemp(temp_filename);
|
g_zlog_conf_fp = mkstemp(temp_filename);
|
||||||
if (g_zlog_conf_fp == -1)
|
if (g_zlog_conf_fp == -1)
|
||||||
{
|
{
|
||||||
@@ -132,16 +145,21 @@ static void snapshot_handle_info(const char *handle_name, const char *log_path,
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int len = snprintf(zlog_rule_conf_content, sizeof(zlog_rule_conf_content),
|
write(g_zlog_conf_fp, zlog_conf_init_buff, strlen(zlog_conf_init_buff));
|
||||||
"[global]\ndefault format = \"%%d(%%c), %%V, %F, %U, %%m%%n\" \n[levels]\nDEBUG=10\nINFO=20\nFATAL=30\n[rules]");
|
|
||||||
write(g_zlog_conf_fp, zlog_rule_conf_content, strlen(zlog_rule_conf_content));
|
|
||||||
fsync(g_zlog_conf_fp);
|
fsync(g_zlog_conf_fp);
|
||||||
}
|
}
|
||||||
snprintf(zlog_rule_conf_content, sizeof(zlog_rule_conf_content),
|
snprintf(zlog_rule_conf_content, sizeof(zlog_rule_conf_content),
|
||||||
"\n%s.%d \"%s.%%d(%%F)\"",
|
"\n%s.%s \"%s.%%d(%%F)\"",
|
||||||
handle_name, level, log_path);
|
handle_name, loglevel_to_name(level), log_path);
|
||||||
write(g_zlog_conf_fp, zlog_rule_conf_content, strlen(zlog_rule_conf_content));
|
write(g_zlog_conf_fp, zlog_rule_conf_content, strlen(zlog_rule_conf_content));
|
||||||
fsync(g_zlog_conf_fp);
|
fsync(g_zlog_conf_fp);
|
||||||
|
|
||||||
|
if(g_zlog_inited == 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"[snapshot_handle_info], Nobody call MESA_handle_runtime_log_creation before, Using (%s) to init zlog, handle_name(%s), log_path(%s), log_level(%d)!!!\n", tmp_conf_filepath, handle_name, log_path, level);
|
||||||
|
zlog_init(tmp_conf_filepath);
|
||||||
|
zlog_reload(NULL);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,33 +171,35 @@ void *MESA_create_runtime_log_handle(const char *file_path, int level)
|
|||||||
int rc = -1;
|
int rc = -1;
|
||||||
zlog_category_t *zc = NULL;
|
zlog_category_t *zc = NULL;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
log_handle_t *p_handle = NULL;
|
struct log_handle_t *handle = NULL;
|
||||||
|
|
||||||
char handle_name[MAX_HANDLE_LOG_PATH];
|
char handle_name[MAX_HANDLE_LOG_PATH];
|
||||||
char *p_path_end = rindex(file_path, '/');
|
char *p_path_end = rindex(file_path, '/');
|
||||||
|
char *p_name;
|
||||||
char *p_name = p_path_end+1;
|
|
||||||
|
|
||||||
strcpy(handle_name, file_path);
|
strcpy(handle_name, file_path);
|
||||||
escape_for_zlog(handle_name, strlen(handle_name));
|
escape_for_zlog(handle_name, strlen(handle_name));
|
||||||
p_name = handle_name;
|
p_name = handle_name;
|
||||||
|
|
||||||
|
|
||||||
//creating file_path failed, return NULL
|
if(p_path_end != NULL && p_path_end > file_path)
|
||||||
if (create_path(file_path, p_path_end - file_path) < 0)
|
{
|
||||||
return NULL;
|
//creating file_path failed, return NULL
|
||||||
|
if (create_path(file_path, p_path_end-file_path) < 0)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
snapshot_handle_info(p_name, file_path, level);
|
snapshot_handle_info(p_name, file_path, level);
|
||||||
|
zlog_reload(NULL);
|
||||||
zc = zlog_get_category(p_name);
|
zc = zlog_get_category(p_name);
|
||||||
if (!zc)
|
if (!zc)
|
||||||
{
|
{
|
||||||
printf("get zlog category %s in %s fail\n", p_name, tmp_conf_filepath);
|
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);
|
handle = (struct log_handle_t *)calloc(sizeof(struct log_handle_t), 1);
|
||||||
strncpy(p_handle->runtime_log_file, file_path, sizeof(p_handle->runtime_log_file) - 1);
|
strncpy(handle->runtime_log_file, file_path, sizeof(handle->runtime_log_file) - 1);
|
||||||
p_handle->runtime_log_level = level;
|
handle->runtime_log_level = level;
|
||||||
p_handle->zc = zc;
|
handle->zc = zc;
|
||||||
return (void *)p_handle;
|
return (void *)handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MESA_destroy_runtime_log_handle(void *handle)
|
void MESA_destroy_runtime_log_handle(void *handle)
|
||||||
@@ -194,52 +214,95 @@ 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)
|
||||||
{
|
{
|
||||||
|
struct log_handle_t *handle = (struct log_handle_t *)v_handle;
|
||||||
log_handle_t *p_handle = (log_handle_t *)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;
|
if (zlog_level_enabled(handle->zc, level))
|
||||||
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_list ap;
|
||||||
va_end(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 ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int MESA_handle_runtime_log_creation(const char *conf_path)
|
int MESA_handle_runtime_log_creation(const char *conf_path)
|
||||||
{
|
{
|
||||||
if(conf_path == NULL)
|
char *env = getenv("ZLOG_CONF_PATH");
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
if(g_zlog_inited == 1)
|
||||||
{
|
{
|
||||||
printf("MESA_handle_runtime_log_creationUsing NULL, will using ZLOG_CONF_PATH or strout as default profile\n");
|
rc = zlog_reload(conf_path);
|
||||||
return zlog_init(NULL);
|
zlog_profile();
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (access(conf_path, R_OK) != -1)
|
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);
|
||||||
int rc = zlog_init(conf_path);
|
rc = zlog_init(NULL);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
printf("init zlog by %s failed\n", conf_path);
|
fprintf(stderr,"[MESA_handle_runtime_log_creation], INIT zlog by (NULL) or (%s) failed !!! \n", env);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (env != NULL)
|
||||||
|
{
|
||||||
|
strcpy(global_conf_filepath, env);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rc = zlog_init(conf_path);
|
||||||
|
if (rc)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"[MESA_handle_runtime_log_creation], INIT zlog by (%s) failed , using [NULL] retry !\n", conf_path);
|
||||||
|
rc = zlog_init(NULL);
|
||||||
|
if (rc)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"[MESA_handle_runtime_log_creation], INIT zlog by (NULL) or (%s) failed \n", env);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(env != NULL)
|
||||||
|
{
|
||||||
|
strcpy(global_conf_filepath, env);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy(global_conf_filepath, conf_path);
|
strcpy(global_conf_filepath, conf_path);
|
||||||
zlog_profile();
|
|
||||||
}
|
}
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
return -1;
|
fprintf(stderr,"[MESA_handle_runtime_log_creation], INIT zlog finish, Using (%s). \n", global_conf_filepath);
|
||||||
|
g_zlog_inited = 1;
|
||||||
|
zlog_profile();
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int MESA_handle_runtime_log_reconstruction(const char *conf_path)
|
int MESA_handle_runtime_log_reconstruction(const char *conf_path)
|
||||||
{
|
{
|
||||||
int rc = zlog_reload(conf_path);
|
int rc = zlog_reload(conf_path);
|
||||||
@@ -281,4 +344,5 @@ void MESA_handle_runtime_log_destruction()
|
|||||||
unlink(tmp_conf_filepath);
|
unlink(tmp_conf_filepath);
|
||||||
close(g_zlog_conf_fp);
|
close(g_zlog_conf_fp);
|
||||||
}
|
}
|
||||||
|
g_zlog_inited=0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
global: MESA*runtime_log*;
|
global: MESA*runtime_log*;GIT_VERSION_*;
|
||||||
local: *;
|
local: *;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ cmake_minimum_required (VERSION 3.5)
|
|||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
|
|
||||||
ExternalProject_Add(zlog PREFIX zlog
|
ExternalProject_Add(zlog PREFIX zlog
|
||||||
URL ${CMAKE_CURRENT_SOURCE_DIR}/zlog-1.2.15.tar.gz
|
URL ${CMAKE_CURRENT_SOURCE_DIR}/zlog-1.2.16.tar.gz
|
||||||
URL_MD5 155f841543f947bf21112ae4328e7152
|
URL_MD5 4dcfe75a1acbb5c4513bbe168f935993
|
||||||
CONFIGURE_COMMAND ""
|
CONFIGURE_COMMAND ""
|
||||||
BUILD_COMMAND make
|
BUILD_COMMAND make
|
||||||
INSTALL_COMMAND ""
|
INSTALL_COMMAND ""
|
||||||
@@ -14,10 +14,15 @@ ExternalProject_Get_Property(zlog SOURCE_DIR)
|
|||||||
file(MAKE_DIRECTORY ${SOURCE_DIR}/src/)
|
file(MAKE_DIRECTORY ${SOURCE_DIR}/src/)
|
||||||
|
|
||||||
|
|
||||||
|
add_library(zlog_static STATIC IMPORTED GLOBAL)
|
||||||
|
add_dependencies(zlog_static zlog)
|
||||||
|
set_property(TARGET zlog_static PROPERTY IMPORTED_LOCATION ${SOURCE_DIR}/src/libzlog.a)
|
||||||
|
set_property(TARGET zlog_static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/src)
|
||||||
|
|
||||||
add_library(zlog_shared SHARED IMPORTED GLOBAL)
|
add_library(zlog_shared SHARED IMPORTED GLOBAL)
|
||||||
add_dependencies(zlog_shared zlog)
|
add_dependencies(zlog_shared zlog)
|
||||||
set_property(TARGET zlog_shared PROPERTY IMPORTED_LOCATION ${SOURCE_DIR}/src/libzlog.so)
|
set_property(TARGET zlog_shared PROPERTY IMPORTED_LOCATION ${SOURCE_DIR}/src/libzlog.so.1.2)
|
||||||
set_property(TARGET zlog_shared PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/src)
|
set_property(TARGET zlog_shared PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/src)
|
||||||
|
|
||||||
install(FILES ${SOURCE_DIR}/src/libzlog.so.1.2 DESTINATION lib COMPONENT LIBRARIES)
|
install(FILES ${SOURCE_DIR}/src/libzlog.so.1.2 DESTINATION lib COMPONENT LIBRARIES)
|
||||||
install(PROGRAMS ${SOURCE_DIR}/src/zlog-chk-conf DESTINATION bin COMPONENT EXECUTABLE)
|
install(FILES ${SOURCE_DIR}/src/zlog-chk-conf DESTINATION bin COMPONENT EXECUTABLE)
|
||||||
|
|||||||
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