diff --git a/.travis/cmake-freebsd-stage2 b/.travis/cmake-freebsd-stage2 index 92e681f0..cf09490c 100755 --- a/.travis/cmake-freebsd-stage2 +++ b/.travis/cmake-freebsd-stage2 @@ -56,7 +56,7 @@ travis_script() { -DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \ -DCMAKE_SHARED_LINKER_FLAGS="$LD_FLAGS" \ -DCMAKE_INSTALL_PREFIX:PATH="_install" \ - -DTRACE=ON \ + -DMIN_LOGGER_LEVEL=TRACE \ -DMUST_BUILD_TOXAV=ON \ -DSTRICT_ABI=ON \ -DTEST_TIMEOUT_SECONDS=120 \ diff --git a/.travis/cmake-linux b/.travis/cmake-linux index 541eb014..87df3b37 100755 --- a/.travis/cmake-linux +++ b/.travis/cmake-linux @@ -91,7 +91,7 @@ travis_script() { -DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \ -DCMAKE_SHARED_LINKER_FLAGS="$LD_FLAGS" \ -DCMAKE_INSTALL_PREFIX:PATH="$PWD/_install" \ - -DTRACE=ON \ + -DMIN_LOGGER_LEVEL=TRACE \ -DMUST_BUILD_TOXAV=ON \ -DSTRICT_ABI=ON \ -DTEST_TIMEOUT_SECONDS=120 \ diff --git a/.travis/cmake-osx b/.travis/cmake-osx index 524f7116..9c5b8e10 100755 --- a/.travis/cmake-osx +++ b/.travis/cmake-osx @@ -28,7 +28,7 @@ travis_script() { -DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \ -DCMAKE_SHARED_LINKER_FLAGS="$LD_FLAGS" \ -DCMAKE_INSTALL_PREFIX:PATH="$PWD/_install" \ - -DTRACE=ON \ + -DMIN_LOGGER_LEVEL=TRACE \ -DMUST_BUILD_TOXAV=ON \ -DTEST_TIMEOUT_SECONDS=120 \ -DUSE_IPV6=OFF diff --git a/.travis/cmake-windows.sh b/.travis/cmake-windows.sh index a7d1f7e1..80e37141 100644 --- a/.travis/cmake-windows.sh +++ b/.travis/cmake-windows.sh @@ -30,7 +30,7 @@ travis_script() { -e ENABLE_ARCH_i686=$i686 \ -e ENABLE_ARCH_x86_64=$x86_64 \ -e ENABLE_TEST=true \ - -e EXTRA_CMAKE_FLAGS="-DBOOTSTRAP_DAEMON=OFF -DDEBUG=ON -DTEST_TIMEOUT_SECONDS=90" \ + -e EXTRA_CMAKE_FLAGS="-DBOOTSTRAP_DAEMON=OFF -DMIN_LOGGER_LEVEL=DEBUG -DTEST_TIMEOUT_SECONDS=90" \ -e DCMAKE_C_FLAGS="$C_FLAGS" \ -e CMAKE_CXX_FLAGS="$CXX_FLAGS" \ -e CMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \ diff --git a/CMakeLists.txt b/CMakeLists.txt index d68eb801..435cdad3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,18 +93,17 @@ else() message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}") endif() -option(DEBUG "Enable DEBUG level logging (default)" ON) -if(DEBUG) - set(MIN_LOGGER_LEVEL DEBUG) -endif() - -option(TRACE "Enable TRACE level logging (expensive, for network debugging)" OFF) -if(TRACE) - set(MIN_LOGGER_LEVEL TRACE) -endif() - +set(MIN_LOGGER_LEVEL "" CACHE STRING "Logging level to use (TRACE, DEBUG, INFO, WARNING, ERROR)") if(MIN_LOGGER_LEVEL) - add_definitions(-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_${MIN_LOGGER_LEVEL}) + if(("${MIN_LOGGER_LEVEL}" STREQUAL "TRACE") OR + ("${MIN_LOGGER_LEVEL}" STREQUAL "DEBUG") OR + ("${MIN_LOGGER_LEVEL}" STREQUAL "INFO") OR + ("${MIN_LOGGER_LEVEL}" STREQUAL "WARNING") OR + ("${MIN_LOGGER_LEVEL}" STREQUAL "ERROR")) + add_definitions(-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_${MIN_LOGGER_LEVEL}) + else() + message(FATAL_ERROR "Unknown value provided for MIN_LOGGER_LEVEL: \"${MIN_LOGGER_LEVEL}\", must be one of TRACE, DEBUG, INFO, WARNING or ERROR") + endif() endif() option(USE_IPV6 "Use IPv6 in tests" ON) diff --git a/INSTALL.md b/INSTALL.md index 8b2f7f18..9ba73e33 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -81,20 +81,19 @@ There is some experimental accommodation for building natively on Windows, i.e. There are some options that are available to configure the build. -| Name | Description | Expected Value | Default Value | -|------------------------|-----------------------------------------------------------------------------------------------|--------------------------------------------|---------------------------------------------------| -| `BOOTSTRAP_DAEMON` | Enable building of tox-bootstrapd, the DHT bootstrap node daemon. For Unix-like systems only. | ON or OFF | ON | -| `BUILD_AV_TEST` | Build toxav test. | ON or OFF | ON | -| `BUILD_TOXAV` | Whether to build the tox AV library. | ON or OFF | ON | -| `CMAKE_INSTALL_PREFIX` | Path to where everything should be installed. | Directory path. | Platform-dependent. Refer to CMake documentation. | -| `DEBUG` | Enable assertions and other debugging facilities. | ON or OFF | OFF | -| `DHT_BOOTSTRAP` | Enable building of `DHT_bootstrap` | ON or OFF | ON | -| `ENABLE_SHARED` | Build shared (dynamic) libraries for all modules. | ON or OFF | ON | -| `ENABLE_STATIC` | Build static libraries for all modules. | ON or OFF | ON | -| `STRICT_ABI` | Enforce strict ABI export in dynamic libraries. | ON or OFF | OFF | -| `TEST_TIMEOUT_SECONDS` | Limit runtime of each test to the number of seconds specified. | Positive number or nothing (empty string). | Empty string. | -| `TRACE` | Enable TRACE level logging (expensive, for network debugging). | ON or OFF | OFF | -| `USE_IPV6` | Use IPv6 in tests. | ON or OFF | ON | +| Name | Description | Expected Value | Default Value | +|------------------------|-----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|---------------------------------------------------| +| `BOOTSTRAP_DAEMON` | Enable building of tox-bootstrapd, the DHT bootstrap node daemon. For Unix-like systems only. | ON or OFF | ON | +| `BUILD_AV_TEST` | Build toxav test. | ON or OFF | ON | +| `BUILD_TOXAV` | Whether to build the tox AV library. | ON or OFF | ON | +| `CMAKE_INSTALL_PREFIX` | Path to where everything should be installed. | Directory path. | Platform-dependent. Refer to CMake documentation. | +| `DHT_BOOTSTRAP` | Enable building of `DHT_bootstrap` | ON or OFF | ON | +| `ENABLE_SHARED` | Build shared (dynamic) libraries for all modules. | ON or OFF | ON | +| `ENABLE_STATIC` | Build static libraries for all modules. | ON or OFF | ON | +| `MIN_LOGGER_LEVEL` | Logging level to use. | TRACE, DEBUG, INFO, WARNING, ERROR or nothing (empty string) for default. | Empty string. | +| `STRICT_ABI` | Enforce strict ABI export in dynamic libraries. | ON or OFF | OFF | +| `TEST_TIMEOUT_SECONDS` | Limit runtime of each test to the number of seconds specified. | Positive number or nothing (empty string). | Empty string. | +| `USE_IPV6` | Use IPv6 in tests. | ON or OFF | ON | You can get this list of option using the following commands @@ -110,7 +109,7 @@ Example of calling cmake with options ```sh cmake \ -D ENABLE_STATIC=OFF \ - -D DEBUG=ON \ + -D MIN_LOGGER_LEVEL=DEBUG \ -D CMAKE_INSTALL_PREFIX=/opt \ -D TEST_TIMEOUT_SECONDS=120 \ .. diff --git a/configure.ac b/configure.ac index 13913622..0ad65de4 100644 --- a/configure.ac +++ b/configure.ac @@ -82,7 +82,7 @@ AC_ARG_WITH(log-level, elif test "x$withval" = "xERROR"; then AC_DEFINE([MIN_LOGGER_LEVEL], [LOGGER_LEVEL_ERROR], [Logger_Level value]) else - AC_MSG_WARN([Invalid logger level: $withval. Using default 'DEBUG']) + AC_MSG_WARN([Invalid logger level: $withval. Using default.]) fi ] )