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

docs: Log level documentation on remaining package #3494

Open
wants to merge 35 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1010335
apply loglevel documentation
arng40 Dec 11, 2024
d87fee3
.
arng40 Dec 17, 2024
c45a391
Merge remote-tracking branch 'origin/develop' into feature/dudes/log-…
arng40 Dec 19, 2024
d532634
fix merge
arng40 Dec 19, 2024
fc7135d
code style
arng40 Dec 19, 2024
1c7408c
updating log level after merging with develop
arng40 Dec 19, 2024
c8875a3
Merge remote-tracking branch 'origin/develop' into feature/dudes/log-…
arng40 Jan 10, 2025
043c61f
missing hpp
arng40 Jan 10, 2025
db94d91
Merge remote-tracking branch 'origin/develop' into feature/dudes/log-…
arng40 Jan 13, 2025
6869ee8
1st review pass, (renaming, update logLevel, move struct)
arng40 Jan 17, 2025
ac55ebd
clean some hpp
arng40 Jan 17, 2025
7e9c55d
xsd
arng40 Jan 17, 2025
7f078ad
spelling
arng40 Jan 17, 2025
e08a804
Merge remote-tracking branch 'origin/develop' into feature/dudes/log-…
arng40 Jan 17, 2025
b1e5f2c
fix merge
arng40 Jan 17, 2025
a747eab
removed old macros
arng40 Jan 17, 2025
2c88cc0
remove last old macro
arng40 Jan 20, 2025
a3f0c85
missing logLevel
arng40 Jan 20, 2025
623ba07
remove loglevel from hpp
arng40 Jan 20, 2025
f797fa1
lr
arng40 Jan 20, 2025
ef00e8d
lr + uncrustify
arng40 Jan 20, 2025
511fee4
lr
arng40 Jan 20, 2025
5d54048
remove unused header
arng40 Jan 21, 2025
a902a35
centralize logLevel under package
arng40 Jan 22, 2025
1e58f54
update hpp
arng40 Jan 22, 2025
17c39ef
code style
arng40 Jan 22, 2025
e758442
set LogLevel to the corresponding folders
arng40 Jan 23, 2025
5280ea4
add log rst
arng40 Jan 23, 2025
d3fc9c1
spelling rst
arng40 Jan 23, 2025
3b9b3f9
add to toctree
arng40 Jan 23, 2025
e5b74bc
update rst
arng40 Jan 23, 2025
739d2d4
Merge remote-tracking branch 'origin/develop' into feature/dudes/log-…
arng40 Jan 23, 2025
745cfa8
missing log level after merge
arng40 Jan 23, 2025
5614b9a
xsd
arng40 Jan 30, 2025
6053fe2
remove old addLevelMechanics
arng40 Jan 30, 2025
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
38 changes: 0 additions & 38 deletions src/coreComponents/common/logger/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,44 +454,6 @@
*/
#define GEOS_ASSERT_GE( lhs, rhs ) GEOS_ASSERT_GE_MSG( lhs, rhs, "" )

/**
* @brief Macro used to turn on/off a function based on the log level.
* @param[in] minLevel Minimum log level
* @param[in] fn Function to filter
*/
#define GEOS_LOG_LEVEL_FN( minLevel, fn ) \
do { \
if( this->getLogLevel() >= minLevel ) \
{ \
fn; \
} \
} while( false )

/**
* @brief Output messages based on current Group's log level.
* @param[in] minLevel minimum log level
* @param[in] msg a message to log (any expression that can be stream inserted)
* @deprecated Will be replaced by GEOS_LOG_LEVEL_INFO
*/
#define GEOS_LOG_LEVEL( minLevel, msg ) GEOS_LOG_IF( this->getLogLevel() >= minLevel, msg );

/**
* @brief Output messages (only on rank 0) based on current Group's log level.
* @param[in] minLevel minimum log level
* @param[in] msg a message to log (any expression that can be stream inserted)
* @deprecated Will be replaced by GEOS_LOG_LEVEL_INFO_RANK_0
*/
#define GEOS_LOG_LEVEL_RANK_0( minLevel, msg ) GEOS_LOG_RANK_0_IF( this->getLogLevel() >= minLevel, msg )

/**
* @brief Output messages (with one line per rank) based on current Group's log level.
* @param[in] minLevel minimum log level
* @param[in] msg a message to log (any expression that can be stream inserted)
* @deprecated Will be replaced by GEOS_LOG_LEVEL_INFO_BY_RANK
*/
#define GEOS_LOG_LEVEL_BY_RANK( minLevel, msg ) GEOS_LOG_RANK_IF( this->getLogLevel() >= minLevel, msg )


namespace geos
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ PVTDriver::PVTDriver( const string & name,
Group * const parent ):
TaskBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::fluidNameString(), &m_fluidName ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ RelpermDriver::RelpermDriver( const geos::string & name,
:
TaskBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::relpermNameString(), &m_relpermName ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
setInputFlag( InputFlags::REQUIRED ).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ TriaxialDriver::TriaxialDriver( const string & name,
Group * const parent ):
TaskBase( name, parent )
{
enableLogLevelInput();

registerWrapper( viewKeyStruct::solidMaterialNameString(), &m_solidMaterialName ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
Expand Down
9 changes: 0 additions & 9 deletions src/coreComponents/dataRepository/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,15 +651,6 @@ void Group::postRestartInitializationRecursive()
postRestartInitialization();
}

void Group::enableLogLevelInput()
{
// TODO : Improve the Log Level description to clearly assign a usecase per log level (incoming PR).
registerWrapper( viewKeyStruct::logLevelString(), &m_logLevel ).
setApplyDefaultValue( 0 ).
setInputFlag( InputFlags::OPTIONAL ).
setDescription( "Log level" );
}

Group const & Group::getBaseGroupByPath( string const & path ) const
{
Group const * currentGroup = this;
Expand Down
5 changes: 0 additions & 5 deletions src/coreComponents/dataRepository/Group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,11 +1492,6 @@ class Group
*/
void loadFromConduit();

/**
* @deprecated will be remove and replace by addLogLevel
*/
void enableLogLevelInput();

/**
* @brief Set verbosity level
* @param logLevel new verbosity level value
Expand Down
2 changes: 1 addition & 1 deletion src/coreComponents/dataRepository/LogLevelsRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ string LogLevelsRegistry::buildLogLevelDescription() const
{
std::ostringstream description;
description << "Sets the level of information to write in the standard output (the console typically).\n"
"Level 0 outputs no specific information for this solver. Higher levels require more outputs.";
"Information output from lower logLevels is added with the desired log level";
for( auto const & [logLevel, logDescriptions] : m_logLevelsDescriptions )
{
description << GEOS_FMT( "\n{}\n", logLevel );
Expand Down
45 changes: 45 additions & 0 deletions src/coreComponents/dataRepository/docs/LogLevel.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.. _LogLevelDocumentation:

Log levels documentation
========================

Add a log level
---------------

To add a log level, you must respect the following structure and add it to the appropriate ``LogLevelsInfos.hpp`` :

.. code-block:: c++

struct MyMessage
{
static constexpr int getMinLogLevel() { return 2; }
static constexpr std::string_view getDescription() { return msg; }
};

If there is no ``LogLevelsInfos.hpp`` in the corresponding folder, you can create a ``LogLevelsInfos.hpp``

Example of usage
----------------

To log a message with a log level, 4 macros are defined in LogLevelsInfo.hpp located in dataRepository:

* ``GEOS_LOG_LEVEL_INFO( logInfoStruct, msg )``: Output messages based on current ``Group``'s log level.
* ``GEOS_LOG_LEVEL_INFO_RANK_0( logInfoStruct, msg )``: Output messages (only on rank 0) based on current ``Group``'s log level.
* ``GEOS_LOG_LEVEL_INFO_BY_RANK( logInfoStruct, msg )``: Output messages (with one line per rank) based on current ``Group``'s log level.
* ``GEOS_LOG_LEVEL_INFO_RANK_0_NLR( logInfoStruct, msg )``: Output messages (only on rank 0) based on current ``Group``'s log level without the line return.

An exemple of adding and using a log level in a ``group``:

.. code-block:: c++

MyGroup::MyGroup( string const & name );
{
// To use a log level, make sure it is declared in the constructor of the group
addLogLevel< logInfo::MyMessage >();
}

void MyGroup::outputMessage()
{
// effectively output the message taking into account the log level of the group instance
GEOS_LOG_LEVEL_INFO( logInfo::MyMessage, "output some message" );
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ The components/classes of the data structure that a developer should have some k
/coreComponents/dataRepository/docs/Wrapper
/coreComponents/dataRepository/docs/ObjectCatalog
/coreComponents/dataRepository/docs/MappedVector
/coreComponents/dataRepository/docs/LogLevel
1 change: 1 addition & 0 deletions src/coreComponents/events/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set( events_headers
HaltEvent.hpp
PeriodicEvent.hpp
SoloEvent.hpp
LogLevelsInfo.hpp
tasks/TaskBase.hpp
tasks/TasksManager.hpp
)
Expand Down
10 changes: 4 additions & 6 deletions src/coreComponents/events/EventBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "EventBase.hpp"
#include <cstring>

#include "events/LogLevelsInfo.hpp"
#include "common/DataTypes.hpp"
#include "common/TimingMacros.hpp"

Expand Down Expand Up @@ -53,9 +54,6 @@ EventBase::EventBase( const string & name,
{
setInputFlags( InputFlags::OPTIONAL_NONUNIQUE );

// This enables logLevel filtering
enableLogLevelInput();

registerWrapper( viewKeyStruct::eventTargetString(), &m_eventTarget ).
setRTTypeName( rtTypes::CustomTypes::groupNameRef ).
setInputFlag( InputFlags::OPTIONAL ).
Expand Down Expand Up @@ -244,9 +242,9 @@ bool EventBase::execute( real64 const time_n,
EventBase * subEvent = static_cast< EventBase * >( this->getSubGroups()[m_currentSubEvent] );

// Print debug information for logLevel >= 1
GEOS_LOG_LEVEL_RANK_0( 1,
" SubEvent: " << m_currentSubEvent << " (" << subEvent->getName() << "), dt_request=" << subEvent->getCurrentEventDtRequest() << ", forecast=" <<
subEvent->getForecast() );
GEOS_LOG_LEVEL_INFO_RANK_0( logInfo::EventExecution,
" SubEvent: " << m_currentSubEvent << " (" << subEvent->getName() << "), dt_request=" << subEvent->getCurrentEventDtRequest() << ", forecast=" <<
subEvent->getForecast() );

if( subEvent->isReadyForExec() )
{
Expand Down
9 changes: 4 additions & 5 deletions src/coreComponents/events/EventManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "events/EventBase.hpp"
#include "common/MpiWrapper.hpp"
#include "common/Units.hpp"
#include "events/LogLevelsInfo.hpp"

namespace geos
{
Expand All @@ -45,9 +46,6 @@ EventManager::EventManager( string const & name,
{
setInputFlags( InputFlags::REQUIRED );

// This enables logLevel filtering
enableLogLevelInput();

registerWrapper( viewKeyStruct::minTimeString(), &m_minTime ).
setApplyDefaultValue( 0 ).
setInputFlag( InputFlags::OPTIONAL ).
Expand Down Expand Up @@ -183,8 +181,9 @@ bool EventManager::run( DomainPartition & domain )
subEvent->checkEvents( m_time, m_dt, m_cycle, domain );

// Print debug information for logLevel >= 1
GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "Event: {} ({}), dt_request={}, forecast={}",
m_currentSubEvent, subEvent->getName(), subEvent->getCurrentEventDtRequest(), subEvent->getForecast() ) );
GEOS_LOG_LEVEL_INFO_RANK_0( logInfo::EventExecution,
GEOS_FMT( "Event: {} ({}), dt_request={}, forecast={}", m_currentSubEvent,
subEvent->getName(), subEvent->getCurrentEventDtRequest(), subEvent->getForecast() ) );

// Execute, signal events
bool earlyReturn = false;
Expand Down
51 changes: 51 additions & 0 deletions src/coreComponents/events/LogLevelsInfo.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* ------------------------------------------------------------------------------------------------------------
* SPDX-License-Identifier: LGPL-2.1-only
*
* Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
* Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
* Copyright (c) 2018-2020 TotalEnergies
* Copyright (c) 2019- GEOSX Contributors
Comment on lines +5 to +8
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
* Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
* Copyright (c) 2018-2020 TotalEnergies
* Copyright (c) 2019- GEOSX Contributors
* Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
* Copyright (c) 2018-2024 TotalEnergies
* Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
* Copyright (c) 2023-2024 Chevron
* Copyright (c) 2019- GEOS/GEOSX Contributors
* All rights reserved

* All rights reserved
*
* See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
* ------------------------------------------------------------------------------------------------------------
*/

/**
* @file LogLevelsInfo.hpp
* This file contains common log level informations for physics solvers
*/

#ifndef GEOS_EVENTS_LOGLEVELSINFO_HPP
#define GEOS_EVENTS_LOGLEVELSINFO_HPP

#include "common/DataTypes.hpp"

namespace geos
{

namespace logInfo
{

/**
* @name Common LogLevels info structures. They must comply with the `is_log_level_info` trait.
*/
///@{

/// @cond DO_NOT_DOCUMENT

struct EventExecution
{
static constexpr int getMinLogLevel() { return 1; }
MelReyCG marked this conversation as resolved.
Show resolved Hide resolved
static constexpr std::string_view getDescription() { return "Informations on events execution"; }
};

/// @endcond
///@}

}

}

#endif // GEOS_EVENTS_LOGLEVELSINFO_HPP
3 changes: 3 additions & 0 deletions src/coreComponents/events/tasks/TaskBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include "TaskBase.hpp"
#include "events/LogLevelsInfo.hpp"

namespace geos
{
Expand All @@ -29,6 +30,8 @@ TaskBase::TaskBase( string const & name,
ExecutableGroup( name, parent )
{
setInputFlags( InputFlags::OPTIONAL_NONUNIQUE );

addLogLevel< logInfo::EventExecution >();
}

TaskBase::~TaskBase()
Expand Down
1 change: 0 additions & 1 deletion src/coreComponents/events/tasks/TaskBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@


#include <limits>

#include "dataRepository/ExecutableGroup.hpp"
#include "common/DataTypes.hpp"
namespace geos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ FieldSpecificationBase::FieldSpecificationBase( string const & name, Group * par
setApplyDefaultValue( 1.0e99 ).
setInputFlag( InputFlags::OPTIONAL ).
setDescription( "Time at which the boundary condition will stop being applied." );

enableLogLevelInput();
}


Expand Down
1 change: 1 addition & 0 deletions src/coreComponents/fileIO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Contains:
# Specify all headers
#
set( fileIO_headers
LogLevelsInfo.hpp
Outputs/BlueprintOutput.hpp
Outputs/OutputBase.hpp
Outputs/OutputManager.hpp
Expand Down
Loading
Loading