Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding logLevel documentation #3089

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ CO2BrineFluid< PHASE1, PHASE2, FLASH >::
CO2BrineFluid( string const & name, Group * const parent ):
MultiFluidBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::phasePVTParaFilesString(), &m_phasePVTParaFiles ).
setInputFlag( InputFlags::REQUIRED ).
setRestartFlags( RestartFlags::NO_WRITE ).
Expand All @@ -112,6 +110,8 @@ CO2BrineFluid( string const & name, Group * const parent ):
setPlotLevel( PlotLevel::LEVEL_0 ).
setRestartFlags( RestartFlags::WRITE_AND_READ );
}

appendLogLevel( { "logLevel >= 1", "Informations on PVT phase table" } );
}

template< typename PHASE1, typename PHASE2, typename FLASH >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ PVTDriver::PVTDriver( const string & name,
Group * const parent ):
TaskBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::fluidNameString(), &m_fluidName ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
setInputFlag( InputFlags::REQUIRED ).
Expand Down Expand Up @@ -85,6 +83,9 @@ PVTDriver::PVTDriver( const string & name,
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( "none" ).
setDescription( "Baseline file" );

appendLogLevel( { "logLevel >= 1", "Informations about test" } );
appendLogLevel( { "logLevel >= 1", "Indicate at the end if the internal results are consistent" } );
}

void PVTDriver::postProcessInput()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ ReactiveBrineFluid( string const & name, Group * const parent ):
setPlotLevel( PlotLevel::LEVEL_0 ).
setRestartFlags( RestartFlags::WRITE_AND_READ );
}

appendLogLevel( { "logLevel >= 1", "Infos about phase PVT Table" } );
}

template< typename PHASE >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ ReactiveFluidDriver::ReactiveFluidDriver( const string & name,
Group * const parent ):
TaskBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::fluidNameString(), &m_fluidName ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
setInputFlag( InputFlags::REQUIRED ).
Expand Down Expand Up @@ -66,6 +64,9 @@ ReactiveFluidDriver::ReactiveFluidDriver( const string & name,
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( "none" ).
setDescription( "Baseline file" );

appendLogLevel( { "logLevel >= 1", "Infos about ReactiveFluidDriver" } );
appendLogLevel( { "logLevel >= 1", "Indicate at the end if the internal results are consistent" } );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ RelpermDriver::RelpermDriver( const geos::string & name,
:
TaskBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::relpermNameString(), &m_relpermName ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
setInputFlag( InputFlags::REQUIRED ).
Expand All @@ -52,6 +50,9 @@ RelpermDriver::RelpermDriver( const geos::string & name,
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( "none" ).
setDescription( "Baseline file" );

appendLogLevel( { "logLevel >= 1", "Infos about RelpermDriver" } );
appendLogLevel( { "logLevel >= 1", "Indicate if the internal results are consistent" } );
MelReyCG marked this conversation as resolved.
Show resolved Hide resolved
}


Expand Down
5 changes: 3 additions & 2 deletions src/coreComponents/constitutive/solid/TriaxialDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ TriaxialDriver::TriaxialDriver( const string & name,
Group * const parent ):
TaskBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::solidMaterialNameString(), &m_solidMaterialName ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
setInputFlag( InputFlags::REQUIRED ).
Expand Down Expand Up @@ -67,6 +65,9 @@ TriaxialDriver::TriaxialDriver( const string & name,
setInputFlag( InputFlags::OPTIONAL ).
setApplyDefaultValue( "none" ).
setDescription( "Baseline file" );

appendLogLevel( { "logLevel >= 1", "Infos about TriaxialDriver" } );
appendLogLevel( { "logLevel >= 1", "Indicate if the internal results are consistent" } );
}


Expand Down
32 changes: 26 additions & 6 deletions src/coreComponents/dataRepository/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,29 @@ void Group::deregisterWrapper( string const & name )
m_conduitNode.remove( name );
}

void appendLogLevelToWrapper( WrapperBase & wrapper, std::pair< const std::string, const std::string > log )
{
std::string const levelToAppend = "\n" + log.first + " :\n";
std::string const descriptionToAppend = log.second;

wrapper.addEntrieLogLevel( levelToAppend, descriptionToAppend );
wrapper.buildLogLevelDescription();
}

void Group::appendLogLevel( std::pair< const std::string, const std::string > log )
{
string logLevelName = viewKeyStruct::logLevelString();
try
{
WrapperBase & wrapper = getWrapperBase( logLevelName );
appendLogLevelToWrapper( wrapper, log );
}catch( std::domain_error const & )
{
WrapperBase & wrapper = registerWrapper( logLevelName, &m_logLevel );
enableLogLevelInput();
appendLogLevelToWrapper( wrapper, log );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this project, try-catch is for adding more info to errors, not to recover from an erroneous state.
Use a if-else syntax.

}

void Group::resize( indexType const newSize )
{
Expand Down Expand Up @@ -644,12 +667,9 @@ void Group::postRestartInitializationRecursive()

void Group::enableLogLevelInput()
{
string const logLevelString = "logLevel";

registerWrapper( logLevelString, &m_logLevel ).
setApplyDefaultValue( 0 ).
setInputFlag( InputFlags::OPTIONAL ).
setDescription( "Log level" );
registerWrapper( viewKeyStruct::logLevelString(), &m_logLevel ).
setApplyDefaultValue( 1 ).
setInputFlag( InputFlags::OPTIONAL );
}

Group const & Group::getBaseGroupByPath( string const & path ) const
Expand Down
18 changes: 18 additions & 0 deletions src/coreComponents/dataRepository/Group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,12 @@ class Group
///@}
//END_SPHINX_INCLUDE_REGISTER_WRAPPER

/**
* @brief Append a log level/description to the description of the wrapped object
* @param log An entry (log level/ log Description) to append
*/
void appendLogLevel( std::pair< const std::string, const std::string > log );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appendLogLevelDescription( string_view loggingCondition, string_view caseDescription ) ?


/**
* @name Schema generation methods
*/
Expand Down Expand Up @@ -1414,6 +1420,15 @@ class Group
*/
void setInputFlags( InputFlags flags ) { m_input_flags = flags; }

/**
* @struct viewKeyStruct holds char strings and viewKeys for fast lookup
*/
struct viewKeyStruct
{
/// String for the logLevel wrapper
constexpr static char const * logLevelString() { return "logLevel"; }
};

///@}

/**
Expand Down Expand Up @@ -1597,6 +1612,9 @@ class Group

/// Verbosity flag for group logs
integer m_logLevel;

std::string m_logLevelDescription;

//END_SPHINX_INCLUDE_02

/// Restart flag for this group... and subsequently all wrappers in this group.
Expand Down
9 changes: 9 additions & 0 deletions src/coreComponents/dataRepository/Wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,15 @@ class Wrapper final : public WrapperBase
return *this;
}

/**
* @copydoc WrapperBase::appendDescription(string const &)
*/
Wrapper< T > & appendDescription( string const & description )
{
WrapperBase::appendDescription( description );
return *this;
}

/**
* @copydoc WrapperBase::setRegisteringObjects(string const &)
*/
Expand Down
58 changes: 57 additions & 1 deletion src/coreComponents/dataRepository/WrapperBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,40 @@ class WrapperBase
return *this;
}

/**
* @brief Add up more text to the existing description string of the wrapper.
* @param description the description to add to the end of the previous one.
* @return a pointer to this wrapper
*/
WrapperBase & appendDescription( string const & description )
{
m_description = description;
return *this;
}

/**
* @brief Construct the log level string description for a wrapper
*/
void buildLogLevelDescription()
{
string descriptionToBuild;
descriptionToBuild.append( "Sets the level of information to write in the standard output (the console typically).\n"
"A level of 0 outputs minimal information, higher levels require more." );
for( auto const & [logLevel, logDescriptions] : m_logLevelsDescriptions )
{
descriptionToBuild.append( logLevel );
size_t idxDescription = 0;
for( const auto & description : logDescriptions )
{
idxDescription == logDescriptions.size() - 1 ? descriptionToBuild.append( " - " + description ) :
descriptionToBuild.append( " - " + description + "\n" );
idxDescription++;
}
}
appendDescription( descriptionToBuild );
}


/**
* @brief Get the description string of the wrapper.
* @return this wrapper's description string
Expand All @@ -517,6 +551,24 @@ class WrapperBase
return m_description;
}

/**
* @return The map of logs levels description
*/
std::map< std::string, std::vector< std::string > > const & getlogLevelsDescriptions()
{
return m_logLevelsDescriptions;
}

/**
* @brief Add an entry to the description map
* @param levelToAppend The log level key
* @param descriptionToAppend The log description value
*/
void addEntrieLogLevel( std::string levelToAppend, std::string descriptionToAppend )
{
m_logLevelsDescriptions[levelToAppend].push_back( descriptionToAppend );
}

/**
* @brief @return a table formatted string containing the input options.
* @param outputHeader If true outputs the table header, otherwise just
Expand Down Expand Up @@ -695,6 +747,10 @@ class WrapperBase
/// A string description of the wrapped object
string m_description;

/// Map for building the log level string for each wrapper
/// key : logLevel, values : description(s) for a level
std::map< std::string, std::vector< std::string > > m_logLevelsDescriptions;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one logLevel per Group = only one map per Group
Every wrapper should not have logLevel functionnalities, Group should.
Those method & attributes you added in Wrapper are not at the right place.


/// A string regex to validate the input values string to parse for the wrapped object
string m_rtTypeName;

Expand Down Expand Up @@ -771,7 +827,7 @@ class WrapperBase
parallelDeviceEvents & events ) const = 0;
};

} /// namespace dataRepository
} /// namespace dataRepository
} /// namespace geos

#endif /* GEOS_DATAREPOSITORY_WRAPPERBASE_HPP_ */
1 change: 0 additions & 1 deletion src/coreComponents/events/EventBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ EventBase::EventBase( const string & name,
{
setInputFlags( InputFlags::OPTIONAL_NONUNIQUE );

// This enables logLevel filtering
enableLogLevelInput();

registerWrapper( viewKeyStruct::eventTargetString(), &m_eventTarget ).
Expand Down
1 change: 0 additions & 1 deletion src/coreComponents/events/EventManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ EventManager::EventManager( string const & name,
{
setInputFlags( InputFlags::REQUIRED );

// This enables logLevel filtering
enableLogLevelInput();

registerWrapper( viewKeyStruct::minTimeString(), &m_minTime ).
Expand Down
2 changes: 0 additions & 2 deletions src/coreComponents/fileIO/Outputs/VTKOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ VTKOutput::VTKOutput( string const & name,
m_levelNames(),
m_writer( getOutputDirectory() + '/' + m_plotFileRoot )
{
enableLogLevelInput();

registerWrapper( viewKeysStruct::plotFileRoot, &m_plotFileRoot ).
setDefaultValue( m_plotFileRoot ).
setInputFlag( InputFlags::OPTIONAL ).
Expand Down
3 changes: 3 additions & 0 deletions src/coreComponents/mesh/MeshManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ MeshManager::MeshManager( string const & name,
Group * const parent ):
Group( name, parent )
{

setInputFlags( InputFlags::REQUIRED );

appendLogLevel( { "logLevel >= 1", "Infos about imported field name on region/subRegion" } );
}

MeshManager::~MeshManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ ExternalMeshGeneratorBase::ExternalMeshGeneratorBase( string const & name,
dataRepository::Group * const parent )
: MeshGeneratorBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::filePathString(), &m_filePath ).
setInputFlag( InputFlags::REQUIRED ).
setRestartFlags( RestartFlags::NO_WRITE ).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ using namespace dataRepository;
InternalWellGenerator::InternalWellGenerator( string const & name, Group * const parent ):
WellGeneratorBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::polylineNodeCoordsString(), &m_polyNodeCoords ).
setInputFlag( InputFlags::REQUIRED ).
setSizedFromParent( 0 ).
Expand Down
4 changes: 4 additions & 0 deletions src/coreComponents/mesh/generators/VTKMeshGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ VTKMeshGenerator::VTKMeshGenerator( string const & name,
" If set to 0 (default value), the GlobalId arrays in the input mesh are used if available, and generated otherwise."
" If set to a negative value, the GlobalId arrays in the input mesh are not used, and generated global Ids are automatically generated."
" If set to a positive value, the GlobalId arrays in the input mesh are used and required, and the simulation aborts if they are not available" );

appendLogLevel( { "logLevel >= 1", "Infos about cell block names" } );
appendLogLevel( { "logLevel >= 2", "Infos about node sets names" } );
appendLogLevel( { "logLevel >= 5", "Infos about redistribution" } );
}

void VTKMeshGenerator::fillCellBlockManager( CellBlockManager & cellBlockManager, SpatialPartition & partition )
Expand Down
4 changes: 4 additions & 0 deletions src/coreComponents/mesh/generators/WellGeneratorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ WellGeneratorBase::WellGeneratorBase( string const & name, Group * const parent
, m_nDims( 3 )
, m_polylineHeadNodeId( -1 )
{


setInputFlags( InputFlags::OPTIONAL_NONUNIQUE );

registerWrapper( viewKeyStruct::radiusString(), &m_radius ).
Expand Down Expand Up @@ -70,6 +72,8 @@ WellGeneratorBase::WellGeneratorBase( string const & name, Group * const parent
setInputFlag( InputFlags::REQUIRED ).
setSizedFromParent( 0 ).
setDescription( "Name of the set of constraints associated with this well" );

appendLogLevel( { "logLevel >= 1", "Infos about Internal wells and their perforations" } );
}

Group * WellGeneratorBase::createChild( string const & childKey, string const & childName )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Rectangle::Rectangle( const string & name, Group * const parent ):
setDescription( "Tolerance to determine if a point sits on the plane or not. "
"It is relative to the maximum dimension of the plane." );

appendLogLevel( { "logLevel >= 2", "Infos about length and width of the bounded plane" } );

m_points.resize( 4, 3 );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ NonlinearSolverParameters::NonlinearSolverParameters( string const & name,
{
setInputFlags( InputFlags::OPTIONAL );

// This enables logLevel filtering
enableLogLevelInput();

registerWrapper( viewKeysStruct::lineSearchActionString(), &m_lineSearchAction ).
Expand Down Expand Up @@ -165,6 +164,8 @@ NonlinearSolverParameters::NonlinearSolverParameters( string const & name,
setInputFlag( dataRepository::InputFlags::OPTIONAL ).
setDescription( "Nonlinear acceleration type for sequential solver." );

appendLogLevel( { "logLevel >= 1", "Infos about NonLinearSolver parameters" } );

}

void NonlinearSolverParameters::postProcessInput()
Expand Down
Loading