Skip to content

Commit 0cac9d1

Browse files
Add CMake option OLP_SDK_DISABLE_DEBUG_LOGGING (#850)
Users can use it to disable debug/trace log messages. Default is OFF which mean means that messages are enabled. Resolves: OLPEDGE-247 Signed-off-by: Mykhailo Kuchma <ext-mykhailo.kuchma@here.com>
1 parent e0be47f commit 0cac9d1

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ option(OLP_SDK_BOOST_THROW_EXCEPTION_EXTERNAL "The boost::throw_exception() is d
4141
option(OLP_SDK_BUILD_EXTERNAL_DEPS "Download and build external dependencies" ON)
4242
option(OLP_SDK_BUILD_EXAMPLES "Enable examples targets" OFF)
4343
option(OLP_SDK_MSVC_PARALLEL_BUILD_ENABLE "Enable parallel build on MSVC" ON)
44+
option(OLP_SDK_DISABLE_DEBUG_LOGGING "Disable debug and trace level logging" OFF)
4445

4546
# C++ standard version. Minimum supported version is 11.
4647
set(CMAKE_CXX_STANDARD 11)
@@ -68,7 +69,7 @@ include(common)
6869
# Include code coverage variables
6970
include(coverage)
7071

71-
if(OLP_SDK_BUILD_EXTERNAL_DEPS)
72+
if (OLP_SDK_BUILD_EXTERNAL_DEPS)
7273
# Add third-party dependencies
7374
set(EXTERNAL_BINARY_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install)
7475
add_subdirectory(external)

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,16 @@ cmake --build . --target docs
164164

165165
### CMake Flags
166166

167-
| Flag | Description |
168-
| :-------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
169-
| `BUILD_SHARED_LIBS` | Defaults to `OFF`. If enabled, all libraries are built as shared. |
170-
| `OLP_SDK_BUILD_DOC` | Defaults to `OFF`. If enabled, the API reference is generated in your build directory.<br> **Note:** Before you download the API reference, install <a href="http://www.doxygen.nl/" target="_blank">Doxygen</a>. |
171-
| `OLP_SDK_ENABLE_TESTING` | Defaults to `ON`. If enabled, unit tests are built for each library. |
172-
| `OLP_SDK_BUILD_EXTERNAL_DEPS` | Defaults to `ON`. If enabled, CMake downloads and compiles dependencies. |
173-
| `OLP_SDK_NO_EXCEPTION` | Defaults to `OFF`. If enabled, all libraries are built without exceptions. |
174-
| `OLP_SDK_BOOST_THROW_EXCEPTION_EXTERNAL` | Defaults to `OFF`. When `OLP_SDK_NO_EXCEPTION` is `ON`, `boost` requires `boost::throw_exception()` to be defined. If enabled, the external definition of `boost::throw_exception()` is used. Otherwise, the library uses own definition. |
175-
| `OLP_SDK_MSVC_PARALLEL_BUILD_ENABLE` (Windows Only) | Defaults to `ON`. If enabled, the `/MP` compilation flag is added to build the SDK using multiple cores. |
167+
| Flag | Description |
168+
| :- | :- |
169+
| `BUILD_SHARED_LIBS` | Defaults to `OFF`. If enabled, all libraries are built as shared. |
170+
| `OLP_SDK_BUILD_DOC` | Defaults to `OFF`. If enabled, the API reference is generated in your build directory.<br> **Note:** Before you download the API reference, install <a href="http://www.doxygen.nl/" target="_blank">Doxygen</a>. |
171+
| `OLP_SDK_ENABLE_TESTING` | Defaults to `ON`. If enabled, unit tests are built for each library. |
172+
| `OLP_SDK_BUILD_EXTERNAL_DEPS` | Defaults to `ON`. If enabled, CMake downloads and compiles dependencies. |
173+
| `OLP_SDK_NO_EXCEPTION` | Defaults to `OFF`. If enabled, all libraries are built without exceptions. |
174+
| `OLP_SDK_BOOST_THROW_EXCEPTION_EXTERNAL` | Defaults to `OFF`. When `OLP_SDK_NO_EXCEPTION` is `ON`, `boost` requires `boost::throw_exception()` to be defined. If enabled, the external definition of `boost::throw_exception()` is used. Otherwise, the library uses own definition. |
175+
| `OLP_SDK_MSVC_PARALLEL_BUILD_ENABLE` (Windows Only) | Defaults to `ON`. If enabled, the `/MP` compilation flag is added to build the SDK using multiple cores. |
176+
| `OLP_SDK_DISABLE_DEBUG_LOGGING`| Defaults to `OFF`. If enabled, The debug and trace level log messages will not be printed. |
176177

177178
## SDK Usage
178179

olp-cpp-sdk-core/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
328328

329329
add_library(${PROJECT_NAME} ${OLP_SDK_CORE_SOURCES} ${OLP_SDK_CORE_HEADERS})
330330

331+
332+
if (OLP_SDK_DISABLE_DEBUG_LOGGING)
333+
target_compile_definitions(${PROJECT_NAME}
334+
PUBLIC LOGGING_DISABLE_DEBUG_LEVEL)
335+
endif()
336+
331337
target_compile_definitions(${PROJECT_NAME}
332338
PRIVATE ${OLP_SDK_DEFAULT_NETWORK_DEFINITION})
333339

0 commit comments

Comments
 (0)