Skip to content

Commit

Permalink
streamline CMake Option LOGGING_LEVEL
Browse files Browse the repository at this point in the history
instead of using descriptive numbers for setting the logging level, one now specifies it using natural language
  • Loading branch information
schuhmaj committed Sep 11, 2024
1 parent 4564291 commit 32d1211
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ option(USE_LOCAL_TBB "Uses the local tbb installation rather than on using the a
GitHub via CMake (Default: OFF)" OFF)

# Set the Logging Level
set(LOGGING_LEVEL "2" CACHE STRING "Set the Logging level, default (INFO=2), available options:
TRACE=0, DEBUG=1, INFO=2, WARN=3, ERROR=4, CRITICAL=5, OFF=6")
set_property(CACHE LOGGING_LEVEL PROPERTY STRINGS 0, 1, 2, 3, 4, 5, 6)
add_compile_definitions(SPDLOG_ACTIVE_LEVEL=${LOGGING_LEVEL})
set(LOGGING_LEVEL_LIST "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF")
set(LOGGING_LEVEL "INFO" CACHE STRING "Set the Logging level, default (INFO), available options: TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, OFF")
set_property(CACHE LOGGING_LEVEL PROPERTY STRINGS ${LOGGING_LEVEL_LIST})
# Convert the logging level string to its corresponding number
list(FIND LOGGING_LEVEL_LIST ${LOGGING_LEVEL} LOGGING_LEVEL_INDEX)
if (${LOGGING_LEVEL_INDEX} EQUAL -1)
message(FATAL_ERROR "Invalid logging level: ${LOGGING_LEVEL}")
endif ()
add_compile_definitions(SPDLOG_ACTIVE_LEVEL=${LOGGING_LEVEL_INDEX})
message(STATUS "Logging level set to ${LOGGING_LEVEL} (=${LOGGING_LEVEL_INDEX})")

###################################
# What actually to build? - Options
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,14 @@ cmake --build .

The following options are available:

| Name (Default) | Options |
|-------------------------------------------:|:-------------------------------------------------------------------------------------------|
| POLYHEDRAL_GRAVITY_PARALLELIZATION (`CPP`) | `CPP` = Serial Execution / `OMP` or `TBB` = Parallel Execution with OpenMP or Intel\'s TBB |
| LOGGING_LEVEL (`2`) | `0` = TRACE/ `1` = DEBUG/ `2` = INFO / `3` = WARN/ `4` = ERROR/ `5` = CRITICAL/ `6` = OFF |
| USE_LOCAL_TBB (`OFF`) | Use a local installation of `TBB` instead of setting it up via `CMake` |
| BUILD_POLYHEDRAL_GRAVITY_DOCS (`OFF`) | Build this documentation |
| BUILD_POLYHEDRAL_GRAVITY_TESTS (`ON`) | Build the Tests |
| BUILD_POLYHEDRAL_PYTHON_INTERFACE (`ON`) | Build the Python interface |
| Name (Default) | Options |
|-------------------------------------------:|:--------------------------------------------------------------------------------------------|
| POLYHEDRAL_GRAVITY_PARALLELIZATION (`CPP`) | `CPP` = Serial Execution / `OMP` or `TBB` = Parallel Execution with OpenMP or Intel\'s TBB |
| LOGGING_LEVEL (`INFO`) | `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL`, `OFF` |
| USE_LOCAL_TBB (`OFF`) | Use a local installation of `TBB` instead of setting it up via `CMake` |
| BUILD_POLYHEDRAL_GRAVITY_DOCS (`OFF`) | Build this documentation |
| BUILD_POLYHEDRAL_GRAVITY_TESTS (`ON`) | Build the Tests |
| BUILD_POLYHEDRAL_PYTHON_INTERFACE (`ON`) | Build the Python interface |

During testing POLYHEDRAL_GRAVITY_PARALLELIZATION=`TBB` has been the most performant.
It is further not recommend to change the LOGGING_LEVEL to something else than `INFO=2`.
Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ The available options are the following:
Name (Default) Options
================================================ ===================================================================================================================================
POLYHEDRAL_GRAVITY_PARALLELIZATION (:code:`CPP`) :code:`CPP` = Serial Execution / :code:`OMP` or :code:`TBB` = Parallel Execution with OpenMP or Intel's TBB
LOGGING_LEVEL (:code:`2`) :code:`0` = TRACE/ :code:`1` = DEBUG/ :code:`2` = INFO / :code:`3` = WARN/ :code:`4` = ERROR/ :code:`5` = CRITICAL/ :code:`6` = OFF
LOGGING_LEVEL (:code:`INFO`) :code:`TRACE`, :code:`DEBUG`, :code:`INFO`, :code:`WARN`, :code:`ERROR`, :code:`CRITICAL`, :code:`OFF`
USE_LOCAL_TBB (:code:`OFF`) Use a local installation of :code:`TBB` instead of setting it up via :code:`CMake`
BUILD_POLYHEDRAL_GRAVITY_DOCS (:code:`OFF`) Build this documentation
BUILD_POLYHEDRAL_GRAVITY_TESTS (:code:`ON`) Build the Tests
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Modify to change the parallelization (Default value: TBB)
"POLYHEDRAL_GRAVITY_PARALLELIZATION": "TBB",
# Default value (INFO=2)
"LOGGING_LEVEL": 2,
"LOGGING_LEVEL": "INFO",
# Default value (OFF)
"USE_LOCAL_TBB": "OFF",
# Not required for the python interface (--> OFF)
Expand Down

0 comments on commit 32d1211

Please sign in to comment.