From e173be3d1788f041048a3cb8b35ce7f00f7e45c0 Mon Sep 17 00:00:00 2001
From: Christoph Alt <christoph.alt@fau.de>
Date: Thu, 4 May 2023 16:24:14 +0200
Subject: [PATCH] document logging

---
 src/core/logging/CMakeDefs.in.h |  3 +++
 src/core/logging/Logging.cpp    | 44 ++++++++++++++++++++++++---------
 src/core/logging/Logging.h      |  2 +-
 3 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/src/core/logging/CMakeDefs.in.h b/src/core/logging/CMakeDefs.in.h
index 05abf9750..b0c8d1154 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 0c3718d0f..bd2dfa403 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 8d174df51..de8aa91d8 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 )
-- 
GitLab