diff --git a/ApplicationLibCode/Application/RiaPreferencesSystem.cpp b/ApplicationLibCode/Application/RiaPreferencesSystem.cpp index 65f1d9063d..1efc872e78 100644 --- a/ApplicationLibCode/Application/RiaPreferencesSystem.cpp +++ b/ApplicationLibCode/Application/RiaPreferencesSystem.cpp @@ -230,6 +230,8 @@ RiaPreferencesSystem::EclipseTextFileReaderMode RiaPreferencesSystem::eclipseTex //-------------------------------------------------------------------------------------------------- bool RiaPreferencesSystem::isLoggingActivatedForKeyword( const QString& keyword ) const { + if ( keyword.isEmpty() ) return true; + QStringList keywords = m_keywordsForLogging().split( ";" ); if ( keywords.contains( "enable-all" ) ) return true; diff --git a/ApplicationLibCode/Application/Tools/RiaLogging.cpp b/ApplicationLibCode/Application/Tools/RiaLogging.cpp index 87e28e7932..e07bb9e21d 100644 --- a/ApplicationLibCode/Application/Tools/RiaLogging.cpp +++ b/ApplicationLibCode/Application/Tools/RiaLogging.cpp @@ -18,6 +18,7 @@ #include "RiaLogging.h" #include "RiaGuiApplication.h" +#include "RiaPreferencesSystem.h" #include "RiaRegressionTestRunner.h" #include @@ -245,8 +246,10 @@ RILogLevel RiaLogging::logLevelBasedOnPreferences() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaLogging::error( const QString& message ) +void RiaLogging::error( const QString& message, const QString logKeyword ) { + if ( !RiaPreferencesSystem::current()->isLoggingActivatedForKeyword( logKeyword ) ) return; + if ( isSameMessage( message ) ) return; for ( const auto& logger : sm_logger ) @@ -264,8 +267,10 @@ void RiaLogging::error( const QString& message ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaLogging::warning( const QString& message ) +void RiaLogging::warning( const QString& message, const QString logKeyword ) { + if ( !RiaPreferencesSystem::current()->isLoggingActivatedForKeyword( logKeyword ) ) return; + if ( isSameMessage( message ) ) return; for ( const auto& logger : sm_logger ) @@ -283,8 +288,10 @@ void RiaLogging::warning( const QString& message ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaLogging::info( const QString& message ) +void RiaLogging::info( const QString& message, const QString logKeyword ) { + if ( !RiaPreferencesSystem::current()->isLoggingActivatedForKeyword( logKeyword ) ) return; + if ( isSameMessage( message ) ) return; for ( const auto& logger : sm_logger ) @@ -302,8 +309,10 @@ void RiaLogging::info( const QString& message ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaLogging::debug( const QString& message ) +void RiaLogging::debug( const QString& message, const QString logKeyword ) { + if ( !RiaPreferencesSystem::current()->isLoggingActivatedForKeyword( logKeyword ) ) return; + if ( isSameMessage( message ) ) return; for ( const auto& logger : sm_logger ) diff --git a/ApplicationLibCode/Application/Tools/RiaLogging.h b/ApplicationLibCode/Application/Tools/RiaLogging.h index 2338bc19af..d4f9ffd597 100644 --- a/ApplicationLibCode/Application/Tools/RiaLogging.h +++ b/ApplicationLibCode/Application/Tools/RiaLogging.h @@ -23,7 +23,8 @@ #include #include -class QString; +#include + class QWidget; enum class RILogLevel @@ -66,10 +67,10 @@ public: static RILogLevel logLevelBasedOnPreferences(); - static void error( const QString& message ); - static void warning( const QString& message ); - static void info( const QString& message ); - static void debug( const QString& message ); + static void error( const QString& message, const QString logKeyword = "" ); + static void warning( const QString& message, const QString logKeyword = "" ); + static void info( const QString& message, const QString logKeyword = "" ); + static void debug( const QString& message, const QString logKeyword = "" ); static void errorInMessageBox( QWidget* parent, const QString& title, const QString& text ); diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp index bfce5ede20..7f32fec588 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmCommonActive.cpp @@ -19,7 +19,6 @@ #include "RifReaderOpmCommonActive.h" #include "RiaLogging.h" -#include "RiaPreferencesSystem.h" #include "RiaStdStringTools.h" #include "RifOpmRadialGridTools.h" @@ -160,14 +159,10 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips // grid geometry { - const bool isLoggingEnabled = RiaPreferencesSystem::current()->isLoggingActivatedForKeyword( "RifReaderOpmCommonActive" ); - - if ( isLoggingEnabled ) - { - RiaLogging::info( QString( "Loading %0 active of %1 total cells in main grid." ) - .arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( opmGrid.totalActiveCells() ) ) ) - .arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( opmGrid.totalNumberOfCells() ) ) ) ); - } + RiaLogging::info( QString( "Loading %0 active of %1 total cells in main grid." ) + .arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( opmGrid.totalActiveCells() ) ) ) + .arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( opmGrid.totalNumberOfCells() ) ) ), + "RifReaderOpmCommonActive" ); auto task = progInfo.task( "Loading Active Cell Main Grid Geometry" ); transferActiveGeometry( opmGrid, opmGrid, activeGrid, activeGrid, eclipseCaseData ); @@ -178,14 +173,12 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips for ( int lgrIdx = 0; lgrIdx < numLGRs; lgrIdx++ ) { - if ( isLoggingEnabled ) - { - RiaLogging::info( - QString( "Loading %0 active of %1 total cells in LGR grid %2." ) - .arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( lgrGrids[lgrIdx].totalActiveCells() ) ) ) - .arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( lgrGrids[lgrIdx].totalNumberOfCells() ) ) ) - .arg( lgrIdx + 1 ) ); - } + RiaLogging::info( QString( "Loading %0 active of %1 total cells in LGR grid %2." ) + .arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( lgrGrids[lgrIdx].totalActiveCells() ) ) ) + .arg( QString::fromStdString( + RiaStdStringTools::formatThousandGrouping( lgrGrids[lgrIdx].totalNumberOfCells() ) ) ) + .arg( lgrIdx + 1 ), + "RifReaderOpmCommonActive" ); RigGridBase* parentGrid = hasParentInfo ? activeGrid->gridByName( lgr_parent_names[lgrIdx] ) : activeGrid; diff --git a/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp b/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp index 9ba69214bb..4fc5450221 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp @@ -19,7 +19,6 @@ #include "RigCellFaceGeometryTools.h" #include "RiaLogging.h" -#include "RiaPreferencesSystem.h" #include "RigActiveCellInfo.h" #include "RigCell.h" @@ -134,8 +133,6 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain // by Eclipse. Use faults as basis for subset of cells to find NNC connection for. The imported connections from // Eclipse are located at the beginning of the connections vector. - const bool isLoggingEnabled = RiaPreferencesSystem::current()->isLoggingActivatedForKeyword( "RigCellFaceGeometryTools" ); - std::set> nativeCellPairs; for ( size_t i = 0; i < nativeConnections.size(); ++i ) @@ -149,7 +146,7 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain QString message = QString( "Nnc connection imported from Eclipse are not unique\nNNC count : %1\nUnique : %2" ) .arg( nativeConnections.size() ) .arg( nativeCellPairs.size() ); - if ( isLoggingEnabled ) RiaLogging::warning( message ); + RiaLogging::warning( message, "RigCellFaceGeometryTools" ); } const cvf::Collection& faults = mainGrid->faults(); @@ -205,7 +202,7 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain "inactive cells can be managed from Preferences->Eclipse Grid->Include Inactive Cells" ) .arg( otherConnections.size() ) .arg( nncCountWarningThreshold ); - if ( isLoggingEnabled ) RiaLogging::warning( txt ); + RiaLogging::warning( txt, "RigCellFaceGeometryTools" ); } otherConnections.remove_duplicates(); diff --git a/ApplicationLibCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationLibCode/ReservoirDataModel/RigNNCData.cpp index 6433d74238..cb2f946ff3 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigNNCData.cpp @@ -199,8 +199,8 @@ bool RigNNCData::ensureAllConnectionDataIsProcessed() { caf::ProgressInfo progressInfo( 3, "Computing NNC Data" ); - bool isLoggingEnabled = RiaPreferencesSystem::current()->isLoggingActivatedForKeyword( "RigNNCData" ); - if ( isLoggingEnabled ) RiaLogging::info( "NNC geometry computation - starting process" ); + const QString logKeyword = "RigNNCData"; + RiaLogging::info( "NNC geometry computation - starting process", logKeyword ); buildPolygonsForEclipseConnections(); progressInfo.incrementProgress(); @@ -212,28 +212,25 @@ bool RigNNCData::ensureAllConnectionDataIsProcessed() m_mainGrid->distributeNNCsToFaults(); - if ( isLoggingEnabled ) + QStringList noCommonAreaText; + const size_t maxItemCount = 20; + + size_t noCommonAreaCount = connectionsWithNoCommonArea( noCommonAreaText, maxItemCount ); + + RiaLogging::info( "NNC geometry computation - completed process", logKeyword ); + + RiaLogging::info( QString( "Native NNC count : %1" ).arg( eclipseConnectionCount() ), logKeyword ); + RiaLogging::info( QString( "Computed NNC count : %1" ).arg( m_connections.size() ), logKeyword ); + + RiaLogging::info( QString( "NNCs with no common area count : %1" ).arg( noCommonAreaCount ), logKeyword ); + + if ( !noCommonAreaText.isEmpty() ) { - QStringList noCommonAreaText; - const size_t maxItemCount = 20; + RiaLogging::info( QString( "Listing first %1 NNCs with no common area " ).arg( noCommonAreaText.size() ), logKeyword ); - size_t noCommonAreaCount = connectionsWithNoCommonArea( noCommonAreaText, maxItemCount ); - - RiaLogging::info( "NNC geometry computation - completed process" ); - - RiaLogging::info( QString( "Native NNC count : %1" ).arg( eclipseConnectionCount() ) ); - RiaLogging::info( QString( "Computed NNC count : %1" ).arg( m_connections.size() ) ); - - RiaLogging::info( QString( "NNCs with no common area count : %1" ).arg( noCommonAreaCount ) ); - - if ( !noCommonAreaText.isEmpty() ) + for ( const auto& s : noCommonAreaText ) { - RiaLogging::info( QString( "Listing first %1 NNCs with no common area " ).arg( noCommonAreaText.size() ) ); - - for ( const auto& s : noCommonAreaText ) - { - RiaLogging::info( s ); - } + RiaLogging::info( s, logKeyword ); } } } diff --git a/ApplicationLibCode/ReservoirDataModel/Well/RigWellTargetMapping.cpp b/ApplicationLibCode/ReservoirDataModel/Well/RigWellTargetMapping.cpp index 5c584a1d5e..9faec09ce9 100644 --- a/ApplicationLibCode/ReservoirDataModel/Well/RigWellTargetMapping.cpp +++ b/ApplicationLibCode/ReservoirDataModel/Well/RigWellTargetMapping.cpp @@ -22,7 +22,6 @@ #include "RiaEclipseUnitTools.h" #include "RiaLogging.h" #include "RiaPorosityModel.h" -#include "RiaPreferencesSystem.h" #include "RiaResultNames.h" #include "RiaWeightedMeanCalculator.h" @@ -68,8 +67,6 @@ void RigWellTargetMapping::generateCandidates( RimEclipseCase* eclips { if ( !eclipseCase->ensureReservoirCaseIsOpen() ) return; - bool isLoggingEnabled = RiaPreferencesSystem::current()->isLoggingActivatedForKeyword( "RigWellTargetMapping" ); - auto activeCellCount = getActiveCellCount( eclipseCase ); if ( !activeCellCount ) { @@ -161,6 +158,8 @@ void RigWellTargetMapping::generateCandidates( RimEclipseCase* eclips filterVector = std::vector( data.pressure.size(), 1.0 ); } + const QString logKeyword = "RigWellTargetMapping"; + std::vector clusters( activeCellCount.value(), 0 ); auto start = std::chrono::high_resolution_clock::now(); int numClusters = limits.maxNumTargets; @@ -172,12 +171,12 @@ void RigWellTargetMapping::generateCandidates( RimEclipseCase* eclips if ( startCell.has_value() ) { - if ( isLoggingEnabled ) - RiaLogging::info( QString( "Cluster %1 start cell: [%2 %3 %4] " ) - .arg( clusterId ) - .arg( startCell->i() + 1 ) - .arg( startCell->j() + 1 ) - .arg( startCell->k() + 1 ) ); + RiaLogging::info( QString( "Cluster %1 start cell: [%2 %3 %4] " ) + .arg( clusterId ) + .arg( startCell->i() + 1 ) + .arg( startCell->j() + 1 ) + .arg( startCell->k() + 1 ), + logKeyword ); growCluster( eclipseCase, startCell.value(), volumeType, limits, data, filterVector, clusters, clusterId, timeStepIdx, maxIterations ); numClustersFound++; @@ -194,7 +193,7 @@ void RigWellTargetMapping::generateCandidates( RimEclipseCase* eclips auto finish = std::chrono::high_resolution_clock::now(); auto milliseconds = std::chrono::duration_cast( finish - start ); - RiaLogging::info( QString( "Time spent: %1 ms" ).arg( milliseconds.count() ) ); + RiaLogging::info( QString( "Time spent: %1 ms" ).arg( milliseconds.count() ), logKeyword ); QString resultName = RigWellTargetMapping::wellTargetResultName(); createResultVector( *eclipseCase, resultName, clusters ); @@ -235,28 +234,25 @@ void RigWellTargetMapping::generateCandidates( RimEclipseCase* eclips int clusterId = 1; for ( const auto& s : statistics ) { - if ( isLoggingEnabled ) + auto logIfValid = [&logKeyword]( const QString& pattern, double value ) { - auto logIfValid = []( const QString& pattern, double value ) - { - if ( !std::isinf( value ) && !std::isnan( value ) ) RiaLogging::info( pattern.arg( value ) ); - }; + if ( !std::isinf( value ) && !std::isnan( value ) ) RiaLogging::info( pattern.arg( value ), logKeyword ); + }; - RiaLogging::info( QString( "Cluster #%1 Statistics" ).arg( s.id ) ); - RiaLogging::info( QString( "Number of cells: %1" ).arg( s.numCells ) ); - logIfValid( "Total PORV*SOIL: %1", s.totalPorvSoil ); - logIfValid( "Total PORV*SOIL: %1", s.totalPorvSoil ); - logIfValid( "Total PORV*SGAS: %1", s.totalPorvSgas ); - logIfValid( "Total PORV*(SOIL+SGAS): %1", s.totalPorvSoilAndSgas ); - logIfValid( "Total FIPOIL: %1", s.totalFipOil ); - logIfValid( "Total FIPGAS: %1", s.totalFipGas ); - logIfValid( "Total RFIPOIL: %1", s.totalRfipOil ); - logIfValid( "Total RFIPGAS: %1", s.totalRfipGas ); - logIfValid( "Total SFIPOIL: %1", s.totalSfipOil ); - logIfValid( "Total SFIPGAS: %1", s.totalSfipGas ); - logIfValid( "Average Permeability: %1", s.permeability ); - logIfValid( "Average Pressure: %1", s.pressure ); - } + RiaLogging::info( QString( "Cluster #%1 Statistics" ).arg( s.id ), logKeyword ); + RiaLogging::info( QString( "Number of cells: %1" ).arg( s.numCells ), logKeyword ); + logIfValid( "Total PORV*SOIL: %1", s.totalPorvSoil ); + logIfValid( "Total PORV*SOIL: %1", s.totalPorvSoil ); + logIfValid( "Total PORV*SGAS: %1", s.totalPorvSgas ); + logIfValid( "Total PORV*(SOIL+SGAS): %1", s.totalPorvSoilAndSgas ); + logIfValid( "Total FIPOIL: %1", s.totalFipOil ); + logIfValid( "Total FIPGAS: %1", s.totalFipGas ); + logIfValid( "Total RFIPOIL: %1", s.totalRfipOil ); + logIfValid( "Total RFIPGAS: %1", s.totalRfipGas ); + logIfValid( "Total SFIPOIL: %1", s.totalSfipOil ); + logIfValid( "Total SFIPGAS: %1", s.totalSfipGas ); + logIfValid( "Average Permeability: %1", s.permeability ); + logIfValid( "Average Pressure: %1", s.pressure ); addValuesForClusterId( totalPorvSoil, clusters, clusterId, s.totalPorvSoil ); addValuesForClusterId( totalPorvSgas, clusters, clusterId, s.totalPorvSgas );