Skip to content

Commit dc02f3d

Browse files
committed
CAP: added logging
1 parent 994bba3 commit dc02f3d

File tree

16 files changed

+117
-71
lines changed

16 files changed

+117
-71
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@
1111
[submodule "deps/boost"]
1212
path = deps/boost
1313
url = https://github.com/diffCheckOrg/submodule-boost.git
14+
[submodule "deps/loguru"]
15+
path = deps/loguru
16+
url = https://github.com/emilk/loguru.git

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"valarray": "cpp",
9797
"*.inc": "cpp",
9898
"coroutine": "cpp",
99-
"resumable": "cpp"
99+
"resumable": "cpp",
100+
"*.ipp": "cpp"
100101
}
101102
}

CMakeLists.txt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ set(CMAKE_CXX_STANDARD 17)
44

55
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
66

7-
# import the custom cmake utilities funcs
87
include(external_tools)
8+
include(options)
99

1010
# do a submodule init if not done already
1111
execute_process(COMMAND git submodule update --init --recursive
@@ -17,6 +17,13 @@ if(NOT GIT_SUBMOD_RESULT EQUAL "0")
1717
endif()
1818

1919

20+
#--------------------------------------------------------------------------
21+
# pre-compiled definitions
22+
#--------------------------------------------------------------------------
23+
if(SILENT_LOGGING)
24+
target_compile_definitions(${PROJECT_NAME} PRIVATE SILENT_LOGGING=true)
25+
endif()
26+
2027
#--------------------------------------------------------------------------
2128
# diffCheck dynamic lib
2229
#--------------------------------------------------------------------------
@@ -42,6 +49,9 @@ target_include_directories(${SHARED_LIB_NAME}
4249
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
4350
)
4451

52+
#set the MD_DynamicRelease flag for MSVC since we are compiling with /MD for py wrap
53+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
54+
4555

4656
#--------------------------------------------------------------------------
4757
# 3rd party
@@ -52,17 +62,7 @@ download_submodule_project(eigen)
5262
add_subdirectory(deps/eigen)
5363
target_link_libraries(${SHARED_LIB_NAME} PUBLIC Eigen3::Eigen)
5464

55-
# Open3D (pre-built binaries) -----------------------------------------------------
56-
# The options need to be the same as Open3D's default
57-
# If Open3D is configured and built with custom options, you'll also need to
58-
# specify the same custom options.
59-
option(STATIC_WINDOWS_RUNTIME "Use static (MT/MTd) Windows runtime" ON)
60-
if(STATIC_WINDOWS_RUNTIME)
61-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
62-
else()
63-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
64-
endif()
65-
65+
# Open3D (pre-built binaries) ---------------------------------------------
6666
download_submodule_project(open3d)
6767
set(Open3D_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/open3d/win/0_18/CMake)
6868
find_package(Open3D 0.18.0 REQUIRED)
@@ -91,14 +91,14 @@ endif()
9191
download_submodule_project(boost)
9292
target_link_directories(${SHARED_LIB_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/deps/boost/win/1_89/include/boost-1_85)
9393

94-
# print boost include dir
95-
message(STATUS "Boost include dir: ${Boost_INCLUDE_DIRS}")
96-
97-
target_include_directories(${SHARED_LIB_NAME} PUBLIC ${Boost_INCLUDE_DIRS})
98-
9994
# CGAL (header-only) ------------------------------------------------------
10095
target_include_directories(${SHARED_LIB_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/deps/cgal/include)
10196

97+
# loguru (header-only) ----------------------------------------------------
98+
download_submodule_project(loguru)
99+
add_subdirectory(deps/loguru)
100+
target_link_libraries(${SHARED_LIB_NAME} PUBLIC loguru::loguru)
101+
102102
#--------------------------------------------------------------------------
103103
# executable for prototyping
104104
#--------------------------------------------------------------------------

CONTRIBUTING.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,23 +157,25 @@ Follow [this guide for documenting the code](https://developer.lsst.io/cpp/api-d
157157
*/
158158
``` -->
159159

160-
<!-- ### Logging (TO BE UPDATED)
161-
To log use the following MACROS. All the code is contained in `Log.hpp` and `Log.cpp`.
160+
### Logging
161+
To log use the following MACROS. All the code is contained in `log.hh` and `log.cc`.
162162
```c++
163-
AIAC_INFO("test_core_info");
164-
AIAC_WARN("test_core_warn");
165-
AIAC_CRITICAL("test_core_critical");
166-
AIAC_DEBUG("test_core_debug");
167-
AIAC_ERROR("test_core_error");
163+
DIFFCHECK_INFO("test_core_info");
164+
DIFFCHECK_WARN("test_core_warn");
165+
DIFFCHECK_ERROR("test_core_error");
166+
DIFFCHECK_FATAL("test_core_critical");
168167
```
169168
The output is like so:
170169
```bash
171-
[source main.cpp] [function main] [line 32] [16:30:05] APP: test
170+
2024-03-30 12:53:29.971 ( 0.000s) [ ADF6D348] diffCheckApp.cc:24 INFO| test_core_info
171+
2024-03-30 12:53:29.972 ( 0.000s) [ ADF6D348] diffCheckApp.cc:25 WARN| test_core_warn
172+
2024-03-30 12:53:29.972 ( 0.000s) [ ADF6D348] diffCheckApp.cc:26 ERR| test_core_error
173+
2024-03-30 12:53:29.972 ( 0.000s) [ ADF6D348] diffCheckApp.cc:27 FATL| test_core_critical
172174
```
173-
The logging can be silenced by setting OFF the option in the main `CMakeLists.txt` and do clean reconfiguration.
175+
The logging can be silenced by setting ON the option in the main `CMakeLists.txt`.
174176
```cmake
175177
option(SILENT_LOGGING "Do not log messages in the terminal of on." ON)
176-
``` -->
178+
```
177179

178180
### I/O and basic datatypes
179181
Here's how you can import point cloud from file:

cmake/options.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# The options need to be the same as Open3D's default
2+
# If Open3D is configured and built with custom options, you'll also need to
3+
# specify the same custom options.
4+
option(STATIC_WINDOWS_RUNTIME "Use static (MT/MTd) Windows runtime" ON)
5+
6+
option(SILENT_LOGGING "Do not log messages in the terminal if on." OFF)

deps/boost

Submodule boost updated 1 file

deps/eigen

Submodule eigen updated from 77833f9 to e63d9f6

deps/loguru

Submodule loguru added at 4adaa18

deps/open3d

Submodule open3d updated 1 file

diffCheckErrors.log

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
arguments: loguru
2+
Current dir: F:\diffCheck
3+
File verbosity level: -2
4+
date time ( uptime ) [ thread name/id ] file:line v|

0 commit comments

Comments
 (0)