Skip to content

Commit

Permalink
Add compile time option CONFIG_DEFAULT_LOGLEVEL
Browse files Browse the repository at this point in the history
With commit c1739cd we added the
possibility to adjust the default loglevel at runtime, but it seems this
is not enough:
Beckhoff#174

In the general usecase where AdsLib is integrated in a larger program it
might be a better option to configure the default loglevel at compile
time. This omit the call to Logger::logLevel at runtime, which might be
jus as annoying as WSAStartup()...

The original pull request disables dynamic behaviour completely, which
is not what we want.

Signed-off-by: Patrick Bruenn <[email protected]>
  • Loading branch information
pbruenn committed Jan 12, 2023
1 parent 3eee990 commit 1ec463c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion AdsLib/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define TIME_T_TO_STRING(DATE_TIME, TIME_T) std::strftime(DATE_TIME, sizeof(DATE_TIME), "%FT%T%z ", localtime(TIME_T));
#endif

size_t Logger::logLevel = 1;
size_t Logger::logLevel = CONFIG_DEFAULT_LOGLEVEL;

static const char* CATEGORY[] = {
"Verbose: ",
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Compiler flags and definitions for Visual Studio come here
endif()

add_definitions(-DCONFIG_DEFAULT_LOGLEVEL=1)
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)

add_subdirectory(AdsLib)
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ project('AdsLib', 'cpp',

# some hardening options
add_project_arguments('-D_FORTIFY_SOURCE=2', language: 'cpp')
add_project_arguments(get_option('default_loglevel'), language: 'cpp')

common_files = files([
'AdsLib/AdsDef.cpp',
Expand Down
3 changes: 3 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ option('tcadsdll_include', type: 'string', value: '')
# On TC/BSD the default path is:
# '/usr/local/lib'
option('tcadsdll_lib', type: 'string', value: '')

# Set this option to configure the default loglevel.
option('default_loglevel', type: 'string', value: '-DCONFIG_DEFAULT_LOGLEVEL=1')

0 comments on commit 1ec463c

Please sign in to comment.