Skip to content

Commit de0e690

Browse files
committed
Fix logging for tests and examples
Remove the use of the LCM_LOG_DEFAULT_ENABLED compile definition. LCM_LOG has to be enable always at runtime. Enable LCM_LOG at runtime for the tests and the example. This solves #24. Signed-off-by: Eduardo Gonzalez <eduardo.gonzalez@amarulasolutions.com>
1 parent 79c92d2 commit de0e690

5 files changed

Lines changed: 12 additions & 9 deletions

File tree

examples/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
add_compile_definitions(LCM_LOG_DEFAULT_ENABLED=1)
2-
31
if(BUILD_CONNMAN)
42
add_executable(connmanctl_dbus connmanctl.cpp)
53
target_link_libraries(connmanctl_dbus PRIVATE GConnmanDbus)

examples/connmanctl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ auto main() -> int {
1818
std::mutex cin_mutex;
1919
std::condition_variable cin_cv;
2020
bool connecting = false;
21+
Amarula::Log::enable(true);
2122
Connman connman;
2223
const auto manager = connman.manager();
2324
manager->onRequestInputPassphrase([&](const auto& service) -> auto {

include/amarula/log.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ class Log {
2424

2525
private:
2626
static auto state() -> std::atomic<bool>& {
27-
#ifdef LCM_LOG_DEFAULT_ENABLED
28-
static std::atomic<bool> flag{true};
29-
#else
3027
static std::atomic<bool> flag{false};
31-
#endif
3228
return flag;
3329
}
3430
};

tests/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
add_compile_definitions(LCM_LOG_DEFAULT_ENABLED=1)
2-
31
include(FetchContent)
42
FetchContent_Declare(
53
googletest
@@ -22,7 +20,8 @@ install(
2220
if(BUILD_CONNMAN)
2321
foreach(connman_test gconnman_clock_test gconnman_tech_test
2422
gconnman_serv_test)
25-
add_executable(${connman_test} ${connman_test}.cpp qt_thread_bundle.hpp)
23+
add_executable(${connman_test} ${connman_test}.cpp qt_thread_bundle.hpp
24+
logging_init.cpp)
2625
target_link_libraries(${connman_test} PRIVATE GConnmanDbus gtest_main)
2726

2827
target_include_directories(${connman_test}

tests/logging_init.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <amarula/log.hpp>
2+
3+
namespace {
4+
struct EnableLogging {
5+
EnableLogging() { Amarula::Log::enable(true); }
6+
};
7+
8+
[[maybe_unused]] EnableLogging enable_logging;
9+
} // namespace

0 commit comments

Comments
 (0)