diff options
author | Andrej Rode <andrej.rode@ettus.com> | 2017-02-07 16:37:25 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-02-20 17:13:15 -0800 |
commit | 21aad77c9ca07f4271136b9241f5adb00a6bb908 (patch) | |
tree | 636ffe3ab2296e9afa661d3a12eb359224cd3254 /host/cmake/Modules | |
parent | 2b33f2bb4c01d4306fd46f78edf6e355a03e2ed7 (diff) | |
download | uhd-21aad77c9ca07f4271136b9241f5adb00a6bb908.tar.gz uhd-21aad77c9ca07f4271136b9241f5adb00a6bb908.tar.bz2 uhd-21aad77c9ca07f4271136b9241f5adb00a6bb908.zip |
utils: introduce new logging API and remove msg API
Diffstat (limited to 'host/cmake/Modules')
-rw-r--r-- | host/cmake/Modules/UHDLog.cmake | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/host/cmake/Modules/UHDLog.cmake b/host/cmake/Modules/UHDLog.cmake new file mode 100644 index 000000000..d5612f1ed --- /dev/null +++ b/host/cmake/Modules/UHDLog.cmake @@ -0,0 +1,57 @@ +######################################################################## +# Logging Variables +######################################################################## +IF(CMAKE_BUILD_TYPE STREQUAL "Debug") + SET(UHD_LOG_MIN_LEVEL "debug" CACHE STRING "Set UHD log level to {trace, debug, info, warning, error, fatal}") + SET(UHD_LOG_CONSOLE_DISABLE "OFF" CACHE BOOL "Disable UHD logging to stderr") + SET(UHD_LOG_FILE_LEVEL "trace" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") + SET(UHD_LOG_CONSOLE_LEVEL "debug" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") +ELSE() + SET(UHD_LOG_MIN_LEVEL "debug" CACHE STRING "Set UHD log level to {trace, debug, info, warning, error, fatal}") + SET(UHD_LOG_CONSOLE_DISABLE "OFF" CACHE BOOL "Disable UHD logging to stderr") + SET(UHD_LOG_FILE_LEVEL "info" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") + SET(UHD_LOG_CONSOLE_LEVEL "info" CACHE STRING "SET UHD file logging level to {trace, debug, info, warning, error, fatal}") +ENDIF() + +FUNCTION(UHD_LOG_LEVEL_CONVERT ARG1 ARG2) + string(TOLOWER "${ARG1}" LOG_LEVEL_LOWER) + IF(LOG_LEVEL_LOWER STREQUAL "trace") + ADD_DEFINITIONS(-D${ARG2}=0) + ELSEIF(LOG_LEVEL_LOWER STREQUAL "debug") + ADD_DEFINITIONS(-D${ARG2}=1) + ELSEIF(LOG_LEVEL_LOWER STREQUAL "info") + ADD_DEFINITIONS(-D${ARG2}=2) + ELSEIF(LOG_LEVEL_LOWER STREQUAL "warning") + ADD_DEFINITIONS(-D${ARG2}=3) + ELSEIF(LOG_LEVEL_LOWER STREQUAL "error") + ADD_DEFINITIONS(-D${ARG2}=4) + ELSEIF(LOG_LEVEL_LOWER STREQUAL "fatal") + ADD_DEFINITIONS(-D${ARG2}=5) + ELSE() + ADD_DEFINITIONS(-D${ARG2}=${ARG1}) + ENDIF() +ENDFUNCTION() + +UHD_LOG_LEVEL_CONVERT(${UHD_LOG_MIN_LEVEL} "UHD_LOG_MIN_LEVEL") +UHD_LOG_LEVEL_CONVERT(${UHD_LOG_CONSOLE_LEVEL} "UHD_LOG_CONSOLE_LEVEL") +UHD_LOG_LEVEL_CONVERT(${UHD_LOG_FILE_LEVEL} "UHD_LOG_FILE_LEVEL") + +IF(UHD_LOG_CONSOLE_DISABLE) + ADD_DEFINITIONS(-DUHD_LOG_CONSOLE_DISABLE) +ELSE() + IF(UHD_LOG_CONSOLE_TIME) + ADD_DEFINITIONS(-DUHD_LOG_CONSOLE_TIME) + ENDIF() + IF(UHD_LOG_CONSOLE_THREAD) + ADD_DEFINITIONS(-DUHD_LOG_CONSOLE_THREAD) + ENDIF() + IF(UHD_LOG_CONSOLE_SRC) + ADD_DEFINITIONS(-DUHD_LOG_CONSOLE_SRC) + ENDIF() +ENDIF() + +SET(UHD_LOG_FILE "" CACHE FILE "Set UHD log file to a file in a existing directory") +IF(NOT UHD_LOG_FILE STREQUAL "") + ADD_DEFINITIONS(-DUHD_LOG_FILE=${UHD_LOG_FILE}) +ENDIF() + |