|
ARTEMIS
|
#include <WarnManager.H>
Public Member Functions | |
| WarnManager (WarnManager &other)=delete | |
| void | operator= (const WarnManager &)=delete |
| void | RecordWarning (std::string topic, std::string text, WarnPriority priority=WarnPriority::medium) |
| This function records a warning message (recording a warning message is thread-safe) More... | |
| std::string | PrintLocalWarnings (const std::string &when) const |
| This function prints all the warning messages collected on the present MPI rank (i.e., this is not a collective call). This function is mainly intended for debug purposes. More... | |
| std::string | PrintGlobalWarnings (const std::string &when) const |
| This function prints all the warning messages collected by all the MPI ranks (i.e., this is a collective call). Only the I/O rank prints the message. More... | |
| void | SetAlwaysWarnImmediately (bool always_warn_immediately) |
| Setter for the m_always_warn_immediately. More... | |
| bool | GetAlwaysWarnImmediatelyFlag () const |
| Getter for the m_always_warn_immediately. More... | |
| void | SetAbortThreshold (std::optional< WarnPriority > abort_threshold) |
| Setter for the m_abort_on_warning_threshold flag (pass std::nullopt in order to never abort) More... | |
| std::optional< WarnPriority > | GetAbortThreshold () const |
| Getter for the m_abort_on_warning_threshold flag. More... | |
| void | debug_read_warnings_from_input (amrex::ParmParse ¶ms) |
| This function reads warning messages from the inputfile. It is intended for debug&testing purposes. More... | |
Static Public Member Functions | |
| static WarnManager & | GetInstance () |
Static Public Attributes | |
| static const int | warn_line_size = 80 |
| static const int | warn_tab_size = 5 |
Private Member Functions | |
| WarnManager () | |
| std::string | PrintWarnMsg (const ablastr::utils::msg_logger::MsgWithCounter &msg_with_counter) const |
| This function generates a string for a single entry of the warning list for a MessageWithCounter struct (i.e., a warning message paired with a counter storing how many times the warning has been raised) More... | |
| std::string | PrintWarnMsg (const ablastr::utils::msg_logger::MsgWithCounterAndRanks &msg_with_counter_and_ranks) const |
| This function generates a string for a single entry of the warning list for a MsgWithCounterAndRanks struct (i.e., a warning message paired with a counter storing how many times the warning has been raised and info on which ranks have raised the warning) More... | |
Static Private Member Functions | |
| static std::string | GetHeader (const std::string &when, const int line_size, const bool is_global) |
| This function generates the header of the warning messages list. More... | |
| static std::string | MsgFormatter (const std::string &msg, const int line_size, const int tab_size) |
| This function formats each line of a warning message text. More... | |
Private Attributes | |
| int | m_rank = 0 |
| std::unique_ptr< ablastr::utils::msg_logger::Logger > | m_p_logger |
| bool | m_always_warn_immediately = false |
| std::optional< WarnPriority > | m_abort_on_warning_threshold = std::nullopt |
The singleton class WarnManager manages warning messages, providing methods to record warnings, and print warning lists.
|
delete |
A singleton class should not be cloneable.
|
private |
The constructor.
| void WarnManager::debug_read_warnings_from_input | ( | amrex::ParmParse & | params | ) |
This function reads warning messages from the inputfile. It is intended for debug&testing purposes.
| [in,out] | params | the inputfile parser |
| std::optional< WarnPriority > WarnManager::GetAbortThreshold | ( | ) | const |
Getter for the m_abort_on_warning_threshold flag.
| bool WarnManager::GetAlwaysWarnImmediatelyFlag | ( | ) | const |
Getter for the m_always_warn_immediately.
|
staticprivate |
This function generates the header of the warning messages list.
| [in] | when | a string to mark when the warnings are printed out (it appears in the warning list) |
| [in] | line_size | maximum line length to be used in formatting warning list |
| [in] | is_global | flag: true if the header is for a global warning list, false otherwise |
|
static |
|
staticprivate |
This function formats each line of a warning message text.
| [in] | msg | the warning message text |
| [in] | line_size | maximum line length to be used in formatting warning list |
| [in] | tab_size | tabulation size to be used in formatting warning list |
|
delete |
A singleton class should not be assignable.
| std::string WarnManager::PrintGlobalWarnings | ( | const std::string & | when | ) | const |
This function prints all the warning messages collected by all the MPI ranks (i.e., this is a collective call). Only the I/O rank prints the message.
| [in] | when | a string to mark when the warnings are printed out (it appears in the warning list) |
| std::string WarnManager::PrintLocalWarnings | ( | const std::string & | when | ) | const |
This function prints all the warning messages collected on the present MPI rank (i.e., this is not a collective call). This function is mainly intended for debug purposes.
| [in] | when | a string to mark when the warnings are printed out (it appears in the warning list) |
|
private |
This function generates a string for a single entry of the warning list for a MessageWithCounter struct (i.e., a warning message paired with a counter storing how many times the warning has been raised)
| [in] | msg_with_counter | a MessageWithCounter |
|
private |
This function generates a string for a single entry of the warning list for a MsgWithCounterAndRanks struct (i.e., a warning message paired with a counter storing how many times the warning has been raised and info on which ranks have raised the warning)
| [in] | msg_with_counter_and_ranks | a MsgWithCounterAndRanks |
| void WarnManager::RecordWarning | ( | std::string | topic, |
| std::string | text, | ||
| WarnPriority | priority = WarnPriority::medium |
||
| ) |
This function records a warning message (recording a warning message is thread-safe)
| [in] | topic | a string to identify the topic of the warning (e.g., "parallelization", "pbc", "particles"...) |
| [in] | text | the text of the warning message |
| [in] | priority | priority of the warning message ("medium" by default) |
| void WarnManager::SetAbortThreshold | ( | std::optional< WarnPriority > | abort_threshold | ) |
Setter for the m_abort_on_warning_threshold flag (pass std::nullopt in order to never abort)
| [in] | abort_threshold | new value of the m_abort_on_warning_threshold flag |
| void WarnManager::SetAlwaysWarnImmediately | ( | bool | always_warn_immediately | ) |
Setter for the m_always_warn_immediately.
| [in] | always_warn_immediately | new value of the m_always_warn_immediately flag |
|
private |
|
private |
|
private |
The Logger stores all the warning messages
|
private |
|
static |
|
static |