Skip to content

Commit

Permalink
lib: introduce log library
Browse files Browse the repository at this point in the history
Introduce a new `log` library which provides bindings for syslog and,
if available, the OpenWrt libubox ulog functions.

Signed-off-by: Jo-Philipp Wich <[email protected]>
  • Loading branch information
jow- committed Oct 10, 2023
1 parent 8a3aefe commit 8f21cfa
Show file tree
Hide file tree
Showing 2 changed files with 1,088 additions and 0 deletions.
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ option(NL80211_SUPPORT "Wireless Netlink plugin support" ${DEFAULT_NL_SUPPORT})
option(RESOLV_SUPPORT "NS resolve plugin support" ON)
option(STRUCT_SUPPORT "Struct plugin support" ON)
option(ULOOP_SUPPORT "Uloop plugin support" ${DEFAULT_ULOOP_SUPPORT})
option(LOG_SUPPORT "Log plugin support" ON)

set(LIB_SEARCH_PATH "${CMAKE_INSTALL_PREFIX}/lib/ucode/*.so:${CMAKE_INSTALL_PREFIX}/share/ucode/*.uc:./*.so:./*.uc" CACHE STRING "Default library search path")
string(REPLACE ":" "\", \"" LIB_SEARCH_DEFINE "${LIB_SEARCH_PATH}")
Expand Down Expand Up @@ -239,6 +240,19 @@ if(ULOOP_SUPPORT)
target_link_libraries(uloop_lib ${libubox})
endif()

if(LOG_SUPPORT)
set(LIBRARIES ${LIBRARIES} log_lib)
add_library(log_lib MODULE lib/log.c)
set_target_properties(log_lib PROPERTIES OUTPUT_NAME log PREFIX "")
target_link_options(log_lib PRIVATE ${UCODE_MODULE_LINK_OPTIONS})
if(libubox)
find_path(ulog_include_dir NAMES libubox/ulog.h)
include_directories(${ulog_include_dir})
target_link_libraries(log_lib ${libubox})
set_target_properties(log_lib PROPERTIES COMPILE_DEFINITIONS HAVE_ULOG)
endif()
endif()

if(UNIT_TESTING)
enable_testing()
add_definitions(-DUNIT_TESTING)
Expand Down
Loading

0 comments on commit 8f21cfa

Please sign in to comment.