Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,29 @@ jobs:
build/Testing/Temporary/LastTest.log
if-no-files-found: ignore

linux-mdbx:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: git submodule update --init --recursive
- name: Configure MDBX
run: cmake -S . -B build-mdbx -DLOGIT_CPP_BUILD_TESTS=ON -DLOGIT_CPP_BUILD_EXAMPLES=ON -DLOGIT_WITH_MDBX=ON -DLOGIT_USE_SUBMODULES=ON -DCMAKE_CXX_STANDARD=17
- name: Build MDBX
run: cmake --build build-mdbx
- name: Test MDBX
run: ctest --test-dir build-mdbx --output-on-failure -R mdbx_logger_test
- name: Upload logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: logs-mdbx
path: |
build-mdbx/CMakeFiles/CMakeOutput.log
build-mdbx/Testing/Temporary/LastTest.log
if-no-files-found: ignore

windows:
runs-on: windows-latest
strategy:
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
[submodule "external/zlib"]
path = external/zlib
url = https://github.com/madler/zlib
[submodule "external/mdbx-containers"]
path = external/mdbx-containers
url = https://github.com/NewYaroslav/mdbx-containers.git
[submodule "external/kurlyk"]
path = external/kurlyk
url = https://github.com/NewYaroslav/kurlyk.git
76 changes: 63 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ option(LOGIT_WITH_CONTEXT "Enable MDC/NDC diagnostic context support" OFF)
option(LOGIT_WITH_OTLP "Enable OTLP/HTTP log export via optional kurlyk dependency" OFF)
option(LOGIT_WITH_PROMETHEUS "Enable Prometheus text payload support" OFF)
option(LOGIT_WITH_PROMETHEUS_SERVER "Enable Prometheus HTTP server backend" OFF)
option(LOGIT_WITH_MDBX "Enable MDBX structured log storage backend" OFF)
option(LOGIT_USE_SUBMODULES "Allow bundled optional dependency fallback" OFF)
option(LOGIT_WITH_SYSLOG "Enable POSIX syslog backend" ON)
option(LOGIT_WITH_WIN_EVENT_LOG "Enable Windows Event Log backend" ON)
Expand All @@ -24,16 +25,20 @@ option(LOGIT_USE_MPSC_RING "Enable lock-free TaskExecutor queue" ON)
option(LOGIT_ENABLE_DROP_OLDEST_SLOWPATH "Enable TaskExecutor DropOldest slow-path" ON)

if(NOT DEFINED CMAKE_CXX_STANDARD)
if(LOGIT_WITH_OTLP OR LOGIT_WITH_PROMETHEUS_SERVER)
if(LOGIT_WITH_OTLP OR LOGIT_WITH_PROMETHEUS_SERVER OR LOGIT_WITH_MDBX)
set(CMAKE_CXX_STANDARD 17)
else()
set(CMAKE_CXX_STANDARD 11)
endif()
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(LOGIT_WITH_MDBX AND CMAKE_CXX_STANDARD LESS 17)
message(FATAL_ERROR "LOGIT_WITH_MDBX requires C++17 or newer.")
endif()

# Dependency: TimeShield
find_package(TimeShield 1.0.4 QUIET CONFIG)
find_package(TimeShield 1.0.6 QUIET CONFIG)
if(NOT TimeShield_FOUND)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/time-shield-cpp/CMakeLists.txt")
add_subdirectory(external/time-shield-cpp)
Expand Down Expand Up @@ -185,6 +190,40 @@ if(LOGIT_WITH_PROMETHEUS_SERVER)
endif()
endif()

# ---------- MDBX ----------
if(LOGIT_WITH_MDBX)
if(EMSCRIPTEN)
message(FATAL_ERROR "LOGIT_WITH_MDBX is not supported for Emscripten.")
endif()
if(MSVC)
message(FATAL_ERROR "LOGIT_WITH_MDBX is not supported with MSVC until mdbx-containers supports MSVC.")
endif()

if(NOT TARGET mdbx_containers::mdbx_containers)
find_package(mdbx_containers QUIET CONFIG)
endif()

if(NOT TARGET mdbx_containers::mdbx_containers AND LOGIT_USE_SUBMODULES)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/mdbx-containers/CMakeLists.txt")
set(MDBXC_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(MDBXC_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(MDBXC_USE_ASAN OFF CACHE BOOL "" FORCE)
set(MDBXC_DEPS_MODE BUNDLED CACHE STRING "Dependency mode for MDBX: AUTO|SYSTEM|BUNDLED" FORCE)
add_subdirectory(external/mdbx-containers EXCLUDE_FROM_ALL)
endif()
endif()

if(NOT TARGET mdbx_containers::mdbx_containers)
message(FATAL_ERROR "mdbx-containers not found. Install it or add it as external/mdbx-containers and enable LOGIT_USE_SUBMODULES.")
endif()

target_compile_definitions(log-it-cpp INTERFACE LOGIT_WITH_MDBX=1)
target_link_libraries(log-it-cpp INTERFACE
$<BUILD_INTERFACE:mdbx_containers::mdbx_containers>
$<INSTALL_INTERFACE:mdbx_containers::mdbx_containers>
)
endif()

# ---------- GZIP (zlib) ----------
if(LOGIT_WITH_GZIP)
if(NOT TARGET ZLIB::ZLIB)
Expand Down Expand Up @@ -248,27 +287,38 @@ install(DIRECTORY include/ DESTINATION include)

install(TARGETS log-it-cpp EXPORT log-it-cppTargets)

set(_logit_install_export_supported ON)

# install(EXPORT) requires all linked targets to be in an export set.
# When kurlyk is pre-installed (IMPORTED target) the export works.
# When kurlyk is a submodule (non-IMPORTED), packaging is unsupported.
# The FATAL_ERROR is deferred to install time so development builds with
# submodules still work; only `cmake --install` is blocked.
# When optional dependencies are pre-installed (IMPORTED targets), the
# export works. When they are submodules (non-IMPORTED), packaging is
# unsupported. The FATAL_ERROR is deferred to install time so development
# builds with submodules still work; only `cmake --install` is blocked.
if(LOGIT_WITH_OTLP AND TARGET kurlyk)
get_target_property(_kurlyk_imported kurlyk IMPORTED)
if(NOT _kurlyk_imported)
set(_logit_install_export_supported OFF)
install(CODE [[
message(FATAL_ERROR
"log-it-cpp: Installing with LOGIT_WITH_OTLP=ON and bundled kurlyk is not supported. "
"Install kurlyk separately and use find_package(kurlyk), or disable LOGIT_WITH_OTLP for install.")
]])
else()
install(EXPORT log-it-cppTargets
FILE log-it-cppTargets.cmake
NAMESPACE log-it-cpp::
DESTINATION lib/cmake/log-it-cpp
)
endif()
else()
endif()

if(LOGIT_WITH_MDBX AND TARGET mdbx_containers::mdbx_containers)
get_target_property(_mdbx_containers_imported mdbx_containers::mdbx_containers IMPORTED)
if(NOT _mdbx_containers_imported)
set(_logit_install_export_supported OFF)
install(CODE [[
message(FATAL_ERROR
"log-it-cpp: Installing with LOGIT_WITH_MDBX=ON and bundled mdbx-containers is not supported. "
"Install mdbx-containers separately and use find_package(mdbx_containers), or disable LOGIT_WITH_MDBX for install.")
]])
endif()
endif()

if(_logit_install_export_supported)
install(EXPORT log-it-cppTargets
FILE log-it-cppTargets.cmake
NAMESPACE log-it-cpp::
Expand Down
3 changes: 3 additions & 0 deletions cmake/log-it-cppConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@

include(CMakeFindDependencyMacro)
find_dependency(TimeShield)
if(@LOGIT_WITH_MDBX@)
find_dependency(mdbx_containers)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/log-it-cppTargets.cmake")
Loading