Skip to content

Commit cdf917d

Browse files
committed
Change default log.level config when LSL_DEBUGLOG is ON. Change LSL_DEBUGLOG default when CMAKE_BUILD_TYPE is Debug.
1 parent dc96c6b commit cdf917d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

cmake/ProjectOptions.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
include(CMakeDependentOption)
22

33
# Project build options
4-
option(LSL_DEBUGLOG "Enable (lots of) additional debug messages" OFF)
4+
# Default LSL_DEBUGLOG to ON for Debug builds (single-config generators only)
5+
string(COMPARE EQUAL "${CMAKE_BUILD_TYPE}" "Debug" _LSL_DEBUGLOG_DEFAULT)
6+
option(LSL_DEBUGLOG "Enable (lots of) additional debug messages" ${_LSL_DEBUGLOG_DEFAULT})
57
option(LSL_UNIXFOLDERS "Use the unix folder layout for install targets" ON)
68
option(LSL_BUILD_STATIC "Build LSL as a static library." OFF)
79
option(LSL_FRAMEWORK "Build LSL as an Apple Framework (Mac only)" ON)

src/api_config.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ void api_config::load_from_file(const std::string &filename) {
9494
}
9595

9696
// read the [log] settings
97-
int log_level = pt.get("log.level", (int)loguru::Verbosity_INFO);
97+
#if LOGURU_DEBUG_LOGGING
98+
// When built with LSL_DEBUGLOG=ON, default to verbose logging
99+
int log_level = pt.get("log.level", 1);
100+
#else
101+
int log_level = pt.get("log.level", static_cast<int>(loguru::Verbosity_INFO));
102+
#endif
98103
if (log_level < -3 || log_level > 9)
99104
throw std::runtime_error("Invalid log.level (valid range: -3 to 9");
100105

0 commit comments

Comments
 (0)