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 33 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
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
7 changes: 4 additions & 3 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 @@ -244,9 +245,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
6 changes: 4 additions & 2 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 Down Expand Up @@ -183,8 +184,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
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
71 changes: 71 additions & 0 deletions src/coreComponents/fileIO/LogLevelsInfo.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* ------------------------------------------------------------------------------------------------------------
* SPDX-License-Identifier: LGPL-2.1-only
*
* 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
*
* 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_FILEIO_LOGLEVELSINFO_HPP
#define GEOS_FILEIO_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 DataCollectorInitialization
{
static constexpr int getMinLogLevel() { return 3; }
static constexpr std::string_view getDescription() { return "Information on Time history Initialization"; }
};

struct ChomboIOInitialization
{
static constexpr int getMinLogLevel() { return 1; }
MelReyCG marked this conversation as resolved.
Show resolved Hide resolved
static constexpr std::string_view getDescription() { return "Information on chomboIO coupling Initialization"; }
};

struct OutputEvents
{
static constexpr int getMinLogLevel() { return 2; }
static constexpr std::string_view getDescription() { return "Information on output events (VTK/ChomboIO/HDF5)"; }
};


struct HDF5Writing
{
static constexpr int getMinLogLevel() { return 3; }
static constexpr std::string_view getDescription() { return "Information on buffered data in an HDF5 file "; }
};

/// @endcond
///@}

}

}

#endif // GEOS_FILEIO_LOGLEVELSINFO_HPP
5 changes: 4 additions & 1 deletion src/coreComponents/fileIO/Outputs/ChomboIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "ChomboIO.hpp"
#include "mesh/MeshLevel.hpp"
#include "mesh/DomainPartition.hpp"
#include "fileIO/LogLevelsInfo.hpp"
#include "fileIO/coupling/ChomboCoupler.hpp"

#include <fstream>
Expand Down Expand Up @@ -75,6 +76,8 @@ ChomboIO::ChomboIO( string const & name, Group * const parent ):
setInputFlag( InputFlags::OPTIONAL ).
setDefaultValue( 0 ).
setDescription( "True iff geos should use the pressures chombo writes out." );

addLogLevel< logInfo::ChomboIOInitialization >();
}

ChomboIO::~ChomboIO()
Expand All @@ -100,7 +103,7 @@ bool ChomboIO::execute( real64 const GEOS_UNUSED_PARAM( time_n ),
{
GEOS_ERROR_IF( m_waitForInput && m_inputPath == "/INVALID_INPUT_PATH", "Waiting for input but no input path was specified." );

GEOS_LOG_LEVEL_RANK_0( 1, "Initializing chombo coupling" );
GEOS_LOG_LEVEL_INFO( logInfo::ChomboIOInitialization, "Initializing chombo coupling" );

m_coupler = new ChomboCoupler( MPI_COMM_GEOS, m_outputPath, m_inputPath, domain.getMeshBody( 0 ).getBaseDiscretization() );

Expand Down
8 changes: 7 additions & 1 deletion src/coreComponents/fileIO/Outputs/TimeHistoryOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "TimeHistoryOutput.hpp"

#include "fileIO/timeHistory/HDFFile.hpp"
#include "fileIO/LogLevelsInfo.hpp"

#if defined(GEOS_USE_PYGEOSX)
#include "fileIO/python/PyHistoryOutputType.hpp"
Expand Down Expand Up @@ -71,6 +72,9 @@ TimeHistoryOutput::TimeHistoryOutput( string const & name,
setRestartFlags( RestartFlags::WRITE_AND_READ ).
setDescription( "The current history record to be written, on restart from an earlier time allows use to remove invalid future history." );

addLogLevel< logInfo::DataCollectorInitialization >();
addLogLevel< logInfo::OutputEvents >();
addLogLevel< logInfo::HDF5Writing >();
}

void TimeHistoryOutput::initCollectorParallel( DomainPartition const & domain, HistoryCollection & collector )
Expand Down Expand Up @@ -98,6 +102,7 @@ void TimeHistoryOutput::initCollectorParallel( DomainPartition const & domain, H
m_io[idx]->updateCollectingCount( count );
return m_io[idx]->getBufferHead();
} );

m_io.back()->init( !freshInit );
}
};
Expand Down Expand Up @@ -143,7 +148,8 @@ void TimeHistoryOutput::initializePostInitialConditionsPostSubGroups()
}

DomainPartition & domain = this->getGroupByPath< DomainPartition >( "/Problem/domain" );
GEOS_LOG_LEVEL_BY_RANK( 3, GEOS_FMT( "TimeHistory: '{}' initializing data collectors.", this->getName() ) );
GEOS_LOG_LEVEL_INFO_BY_RANK( logInfo::DataCollectorInitialization,
GEOS_FMT( "TimeHistory: '{}' initializing data collectors.", this->getName() ) );
for( auto collectorPath : m_collectorPaths )
{
try
Expand Down
10 changes: 6 additions & 4 deletions src/coreComponents/fileIO/Outputs/VTKOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include "VTKOutput.hpp"
#include "fileIO/LogLevelsInfo.hpp"
#include "common/MpiWrapper.hpp"

#if defined(GEOS_USE_PYGEOSX)
Expand Down Expand Up @@ -109,6 +110,8 @@ VTKOutput::VTKOutput( string const & name,
setApplyDefaultValue( m_outputRegionType ).
setInputFlag( InputFlags::OPTIONAL ).
setDescription( "Output region types. Valid options: ``" + EnumStrings< vtk::VTKRegionTypes >::concat( "``, ``" ) + "``" );

addLogLevel< logInfo::OutputEvents >();
}

VTKOutput::~VTKOutput()
Expand Down Expand Up @@ -173,11 +176,10 @@ bool VTKOutput::execute( real64 const time_n,
real64 const GEOS_UNUSED_PARAM ( eventProgress ),
DomainPartition & domain )
{
GEOS_MARK_FUNCTION;

GEOS_LOG_LEVEL_RANK_0( 2, GEOS_FMT( "{}: writing {} at time {} s (cycle number {})", getName(), m_fieldNames, time_n + dt, cycleNumber ));

{
GEOS_LOG_LEVEL_INFO( logInfo::OutputEvents,
GEOS_FMT( "{}: writing {} at time {} s (cycle number {})",
getName(), m_fieldNames, time_n + dt, cycleNumber ));
Timer timer( m_outputTimer );

m_writer.setWriteGhostCells( m_writeGhostCells );
Expand Down
Loading
Loading