Skip to content

Commit

Permalink
Set default log level depending on build type.
Browse files Browse the repository at this point in the history
Suggest a 'Release' build in the README.md
(because of the tyranny of the default...)
  • Loading branch information
kraiskil committed Aug 9, 2023
1 parent baa5e64 commit 94eda90
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ set (CMAKE_CXX_STANDARD 11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wfatal-errors")

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEFAULT_LOG_LEVEL=4")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDEFAULT_LOG_LEVEL=1")

add_subdirectory(cmake_timestamp)

find_package(Protobuf REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ then run a standard CMake build
```
mkdir build
cd build
cmake ..
cmake -DCMAKE_BUILD_TYPE=Release ..
make onnx2c
```

Expand Down
1 change: 0 additions & 1 deletion src/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ void parse_cmdline_options(int argc, const char *argv[])
}
if (input) { options.input_file = args::get(input); }
if (loglevel) {options.logging_level = args::get(loglevel); }
else options.logging_level = 2;
if (options.input_file == "" ) { std::cerr << "No input file given"; hint_at_help_and_exit(); }
}

2 changes: 1 addition & 1 deletion src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct onnx2c_opts
* 3 DEBUG Notes on generated nodes and tensors.
* 4 TRACE Detailed info on generated nodes and tensors.
*/
int logging_level=1;
int logging_level=DEFAULT_LOG_LEVEL; // Default level set by CMake. 1 in release, 4 in debug builds
std::string input_file;
std::map<std::string, uint32_t> dim_defines;
};
Expand Down

0 comments on commit 94eda90

Please sign in to comment.