diff --git a/CMakeLists.txt b/CMakeLists.txt index 9198a0b..8d21319 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,8 @@ option( Scarab_BUILD_CLI "Flag to enable the building of the command-line interf option( Scarab_BUILD_PYTHON "Build python bindings" TRUE ) +set( Scarab_LOGGER_DEFAULT_THRESHOLD "eTrace" CACHE STRING "Default threshold for printing: eTrace, eDebug, eInfo, eProg, eWarn, eError, eFatal" ) + option( Scarab_ENABLE_LOGGER_DEBUG "Flag to enable debug printing for the logger itself" FALSE ) if( (Scarab_BUILD_CODEC_JSON OR Scarab_BUILD_CODEC_YAML OR Scarab_BUILD_AUTHENTICATION OR Scarab_BUILD_CLI) AND NOT Scarab_BUILD_PARAM ) @@ -58,6 +60,8 @@ if( Scarab_ENABLE_TESTING ) enable_testing() endif() +add_compile_definitions( SCARAB_LOGGER_DEFAULT_THRESHOLD=${Scarab_LOGGER_DEFAULT_THRESHOLD} ) + if( Scarab_ENABLE_LOGGER_DEBUG ) add_compile_definitions( SCARAB_LOGGER_DEBUG ) else( Scarab_ENABLE_LOGGER_DEBUG ) diff --git a/VERSION b/VERSION index 38bcc5e..3bb58a4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3 13 2 +3 13 3 diff --git a/changelog.md b/changelog.md index 44ca802..263d4ac 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,13 @@ Types of changes: Added, Changed, Deprecated, Removed, Fixed, Security ## [Unreleased] +## [3.13.3] - 2025-10-06 + +### Changed + +- Default threshold configurable with preprocessor macro and via CMake +- Splash screen callback added to main_app + ## [3.13.2] - 2025-09-17 diff --git a/library/cli/application.cc b/library/cli/application.cc index 1029800..ec241df 100644 --- a/library/cli/application.cc +++ b/library/cli/application.cc @@ -71,7 +71,8 @@ namespace scarab f_use_config( a_use_config ), f_auth_groups_key( "auth-groups" ), f_auth_file_key( "auth-file" ), - f_auth() + f_auth(), + f_splash( [](){} ) // empty function with signature void() { set_global_verbosity( logger::ELevel::eProg ); @@ -162,6 +163,9 @@ namespace scarab LPROG( applog, "Final configuration:\n" << f_primary_config ); LPROG( applog, "Ordered args:\n" << f_nonoption_ord_args ); } + + f_splash(); + return; } diff --git a/library/cli/application.hh b/library/cli/application.hh index 55ac905..a97bd46 100644 --- a/library/cli/application.hh +++ b/library/cli/application.hh @@ -347,6 +347,9 @@ namespace scarab /// Authentication object mv_referrable( authentication, auth ); + /// Splash text callback + mv_referrable( std::function< void() >, splash ); + //************************* // Verbosity //************************* diff --git a/library/logger/logger.cc b/library/logger/logger.cc index 3cdb814..ff64a21 100644 --- a/library/logger/logger.cc +++ b/library/logger/logger.cc @@ -26,6 +26,7 @@ namespace scarab { // see the comment in logger.hh about why the a_make_logger_fcn callback is used instead of the virtual function call t_logger = a_make_logger_fcn( a_name ); //this->make_logger( a_name ); + t_logger->set_level( spdlog::level::level_enum(unsigned(logger::ELevel::SCARAB_LOGGER_DEFAULT_THRESHOLD)) ); spdlog::register_logger( t_logger ); } return t_logger; diff --git a/library/logger/logger.hh b/library/logger/logger.hh index 0045885..d92f171 100644 --- a/library/logger/logger.hh +++ b/library/logger/logger.hh @@ -25,6 +25,10 @@ #include "scarab_api.hh" #include "typename.hh" +#ifndef SCARAB_LOGGER_DEFAULT_THRESHOLD +#define SCARAB_LOGGER_DEFAULT_THRESHOLD eInfo +#endif + /** * @file logger.hh * @brief Contains the logger class and macros diff --git a/testing/applications/test_basic_application.cc b/testing/applications/test_basic_application.cc index 4fac5e4..e4b6430 100644 --- a/testing/applications/test_basic_application.cc +++ b/testing/applications/test_basic_application.cc @@ -46,12 +46,17 @@ Usage: bin/test_basic_application [OPTIONS] using namespace scarab; +LOGGER( slog, "basic_application" ); + int main( int argc, char **argv ) { logger::set_global_threshold( logger::ELevel::eDebug ); main_app the_main( false ); + // this isn't strictly necessary, but tests the splash screen feature + the_main.splash() = [](){ LPROG( slog, "WELCOME TO BASIC APPLICATION!" ); }; + CLI11_PARSE( the_main, argc, argv ); return 0;