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 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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
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
* 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; }
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
70 changes: 70 additions & 0 deletions src/coreComponents/fileIO/LogLevelsInfo.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* ------------------------------------------------------------------------------------------------------------
* 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
* 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