diff --git a/src/core/logging/CMakeDefs.in.h b/src/core/logging/CMakeDefs.in.h index 05abf9750a6219235a69fc76549cdf2139f8dcb9..b0c8d115464299dbed548ccb3911f0362e193c7c 100644 --- a/src/core/logging/CMakeDefs.in.h +++ b/src/core/logging/CMakeDefs.in.h @@ -12,3 +12,6 @@ #cmakedefine WALBERLA_LOGLEVEL_PROGRESS #cmakedefine WALBERLA_LOGLEVEL_DETAIL #cmakedefine WALBERLA_LOGLEVEL_TRACING + +#define WALBERLA_LOGLEVEL ${WALBERLA_LOGLEVEL} +#define WALBERLA_LOGLEVEL_STRING "${WALBERLA_LOGLEVEL}" \ No newline at end of file diff --git a/src/core/logging/Logging.cpp b/src/core/logging/Logging.cpp index 0c3718d0f37ad16ae845828d22349b6bbc595ec8..bd2dfa403b03b16f7aa619cf3ee6cc12ab5972bc 100644 --- a/src/core/logging/Logging.cpp +++ b/src/core/logging/Logging.cpp @@ -43,25 +43,35 @@ const std::string Logging::TRACING_TAG = std::string( "[TRACING ]" ); const uint_t Logging::TAG_WIDTH = uint_t(10); const uint_t Logging::TIMESTAMP_WIDTH = uint_t(17); - - void Logging::setStreamLogLevel( LogLevel logLevel ) { #ifndef WALBERLA_LOGLEVEL_INFO if( logLevel == INFO ) - logWarning( "You are trying to set the stream log level to INFO, but INFO logs are deactivated by CMake!", "Logging::setStreamLogLevel", -1 ); + logWarning( "You are trying to set the stream log level to INFO, but INFO logs are deactivated by CMake!" + "The current WALBERLA_LOGLEVEL is: " WALBERLA_LOGLEVEL_STRING "!" + "Set WALBERLA_LOGLEVEL=INFO to activate INFO logs.", + "Logging::setStreamLogLevel", -1 ); #endif #ifndef WALBERLA_LOGLEVEL_PROGRESS if( logLevel == PROGRESS ) - logWarning( "You are trying to set the stream log level to PROGRESS, but PROGRESS logs are deactivated by CMake!", "Logging::setStreamLogLevel", -1 ); + logWarning( "You are trying to set the stream log level to PROGRESS, but PROGRESS logs are deactivated by CMake!" + "The current WALBERLA_LOGLEVEL is: " WALBERLA_LOGLEVEL_STRING "!" + "Set WALBERLA_LOGLEVEL=PROGRESS to activate PROGRESS logs.", + "Logging::setStreamLogLevel", -1 ); #endif #ifndef WALBERLA_LOGLEVEL_DETAIL if( logLevel == DETAIL ) - logWarning( "You are trying to set the stream log level to DETAIL, but DETAIL logs are deactivated by CMake!", "Logging::setStreamLogLevel", -1 ); + logWarning( "You are trying to set the stream log level to DETAIL, but DETAIL logs are deactivated by CMake!" + "The current WALBERLA_LOGLEVEL is: " WALBERLA_LOGLEVEL_STRING "!" + "Set WALBERLA_LOGLEVEL=DETAIL to activate DETAIL logs.", + "Logging::setStreamLogLevel", -1 ); #endif #ifndef WALBERLA_LOGLEVEL_TRACING if( logLevel == TRACING ) - logWarning( "You are trying to set the stream log level to TRACING, but TRACING logs are deactivated by CMake!", "Logging::setStreamLogLevel", -1 ); + logWarning( "You are trying to set the stream log level to TRACING, but TRACING logs are deactivated by CMake!" + "The current WALBERLA_LOGLEVEL is: " WALBERLA_LOGLEVEL_STRING "!" + "Set WALBERLA_LOGLEVEL=TRACING to activate TRACING logs.", + "Logging::setStreamLogLevel", -1 ); #endif streamLogLevel_ = logLevel; } @@ -72,19 +82,31 @@ void Logging::setFileLogLevel( LogLevel logLevel ) { #ifndef WALBERLA_LOGLEVEL_INFO if( logLevel == INFO ) - logWarning( "You are trying to set the file log level to INFO, but INFO logs are deactivated by CMake!", "Logging::setFileLogLevel", -1 ); + logWarning( "You are trying to set the file log level to INFO, but INFO logs are deactivated by CMake!" + "The current WALBERLA_LOGLEVEL is: " WALBERLA_LOGLEVEL_STRING "!" + "Set WALBERLA_LOGLEVEL=INFO to activate INFO logs.", + "Logging::setFileLogLevel", -1 ); #endif #ifndef WALBERLA_LOGLEVEL_PROGRESS if( logLevel == PROGRESS ) - logWarning( "You are trying to set the file log level to PROGRESS, but PROGRESS logs are deactivated by CMake!", "Logging::setFileLogLevel", -1 ); + logWarning( "You are trying to set the file log level to PROGRESS, but PROGRESS logs are deactivated by CMake!" + "The current WALBERLA_LOGLEVEL is: " WALBERLA_LOGLEVEL_STRING "!" + "Set WALBERLA_LOGLEVEL=PROGRESS to activate PROGRESS logs.", + "Logging::setFileLogLevel", -1 ); #endif #ifndef WALBERLA_LOGLEVEL_DETAIL if( logLevel == DETAIL ) - logWarning( "You are trying to set the file log level to DETAIL, but DETAIL logs are deactivated by CMake!", "Logging::setFileLogLevel", -1 ); + logWarning( "You are trying to set the file log level to DETAIL, but DETAIL logs are deactivated by CMake!" + "The current WALBERLA_LOGLEVEL is: " WALBERLA_LOGLEVEL_STRING "!" + "Set WALBERLA_LOGLEVEL=DETAIL to activate DETAIL logs.", + "Logging::setFileLogLevel", -1 ); #endif #ifndef WALBERLA_LOGLEVEL_TRACING if( logLevel == TRACING ) - logWarning( "You are trying to set the file log level to TRACING, but TRACING logs are deactivated by CMake!", "Logging::setFileLogLevel", -1 ); + logWarning( "You are trying to set the file log level to TRACING, but TRACING logs are deactivated by CMake!" + "The current WALBERLA_LOGLEVEL is: " WALBERLA_LOGLEVEL_STRING "!" + "Set WALBERLA_LOGLEVEL=TRACING to activate TRACING logs.", + "Logging::setFileLogLevel", -1 ); #endif fileLogLevel_ = logLevel; } @@ -215,4 +237,4 @@ bool Logging::isInIgnoreCallerPaths( const std::vector< walberla::regex > & rege } // namespace logging -} // namespace walberla +} // namespace walberla \ No newline at end of file diff --git a/src/core/logging/Logging.h b/src/core/logging/Logging.h index 8d174df51acee3b451cf17a211b1f29c5325ca78..de8aa91d86feefcdab648d5a42f0a563d9704f3c 100644 --- a/src/core/logging/Logging.h +++ b/src/core/logging/Logging.h @@ -186,7 +186,7 @@ private: inline Logging::Logging() : singleton::Singleton<Logging>(), - streamLogLevel_( INFO ), fileLogLevel_( INFO ), + streamLogLevel_( WALBERLA_LOGLEVEL ), fileLogLevel_( WALBERLA_LOGLEVEL ), processId_( uint_c( mpi::MPIManager::instance()->worldRank() ) ), numberOfProcesses_( uint_c( mpi::MPIManager::instance()->numProcesses() ) ), startTime_( timing::WcPolicy::getTimestamp() ), showTimeStamp_( true ), logCallerPath_( false )