https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
Logger Class Reference

Keeps the error and warning messages. More...

#include <Logger.h>

Classes

class  Message
 Simple data structure to hold the messages. More...
 

Public Types

enum  EMessageType { ERROR = 0 , WARNING = 1 }
 

Public Member Functions

 Logger ()
 
virtual ~Logger ()
 
template<typename... Args>
void add (EMessageType type, Args &&... args)
 Add a message to the log.
 
void emitLoggedErrors () const
 Calls mooseError if there are any logged errors.
 
void emitLoggedWarnings () const
 Calls mooseWarning if there are any logged warnings.
 
unsigned int getNumberOfErrors () const
 Return the number of errors.
 
unsigned int getNumberOfWarnings () const
 Return the number of warnings.
 

Protected Attributes

unsigned int _n_errors
 The number of errors.
 
unsigned int _n_warnings
 The number of warnings.
 
std::vector< Message * > _msgs
 The list of logged messages.
 

Detailed Description

Keeps the error and warning messages.

Definition at line 17 of file Logger.h.

Member Enumeration Documentation

◆ EMessageType

Enumerator
ERROR 
WARNING 

Definition at line 23 of file Logger.h.

24 {
25 ERROR = 0,
26 WARNING = 1
27 };
@ ERROR
Definition Logger.h:25
@ WARNING
Definition Logger.h:26

Constructor & Destructor Documentation

◆ Logger()

Logger::Logger ( )

Definition at line 12 of file Logger.C.

12: _n_errors(0), _n_warnings(0) {}
unsigned int _n_warnings
The number of warnings.
Definition Logger.h:100
unsigned int _n_errors
The number of errors.
Definition Logger.h:98

◆ ~Logger()

Logger::~Logger ( )
virtual

Definition at line 14 of file Logger.C.

15{
16 for (auto && it : _msgs)
17 delete it;
18}
std::vector< Message * > _msgs
The list of logged messages.
Definition Logger.h:102

Member Function Documentation

◆ add()

template<typename... Args>
void Logger::add ( EMessageType  type,
Args &&...  args 
)
inline

Add a message to the log.

Parameters
typeThe type of the message

Definition at line 35 of file Logger.h.

36 {
37 std::ostringstream oss;
39
40 Logger::Message * msg = new Logger::Message(type, oss.str());
41 _msgs.push_back(msg);
42
43 switch (type)
44 {
45 case ERROR:
46 _n_errors++;
47 break;
48 case WARNING:
50 break;
51 }
52 }
Simple data structure to hold the messages.
Definition Logger.h:83
void mooseStreamAll(std::ostringstream &ss)

Referenced by LoggingInterface::logComponentError(), LoggingInterface::logComponentWarning(), LoggingInterface::logError(), and LoggingInterface::logWarning().

◆ emitLoggedErrors()

void Logger::emitLoggedErrors ( ) const

Calls mooseError if there are any logged errors.

Definition at line 21 of file Logger.C.

22{
23 if (_n_errors > 0)
24 {
25 std::ostringstream oss;
26 oss << "The following errors were encountered:\n";
27 for (const auto & msg_it : _msgs)
28 if (msg_it->_type == ERROR)
29 oss << " - " << msg_it->_msg << "\n";
30 mooseError(oss.str());
31 }
32}
void mooseError(Args &&... args)
if(subdm)

Referenced by Simulation::controlDataIntegrityCheck(), and Simulation::integrityCheck().

◆ emitLoggedWarnings()

void Logger::emitLoggedWarnings ( ) const

Calls mooseWarning if there are any logged warnings.

Definition at line 35 of file Logger.C.

36{
37 if (_n_warnings > 0)
38 {
39 std::ostringstream oss;
40 oss << "The following warnings were encountered:\n";
41 for (const auto & msg_it : _msgs)
42 if (msg_it->_type == WARNING)
43 oss << " - " << msg_it->_msg << "\n";
44 mooseWarning(oss.str());
45 }
46}
void mooseWarning(Args &&... args)

Referenced by Simulation::integrityCheck().

◆ getNumberOfErrors()

unsigned int Logger::getNumberOfErrors ( ) const

Return the number of errors.

Returns
The number of errors in this log

Definition at line 49 of file Logger.C.

50{
51 return _n_errors;
52}

◆ getNumberOfWarnings()

unsigned int Logger::getNumberOfWarnings ( ) const

Return the number of warnings.

Returns
The number of warnings in this log

Definition at line 55 of file Logger.C.

56{
57 return _n_warnings;
58}

Member Data Documentation

◆ _msgs

std::vector<Message *> Logger::_msgs
protected

The list of logged messages.

Definition at line 102 of file Logger.h.

Referenced by add(), emitLoggedErrors(), emitLoggedWarnings(), and ~Logger().

◆ _n_errors

unsigned int Logger::_n_errors
protected

The number of errors.

Definition at line 98 of file Logger.h.

Referenced by add(), emitLoggedErrors(), and getNumberOfErrors().

◆ _n_warnings

unsigned int Logger::_n_warnings
protected

The number of warnings.

Definition at line 100 of file Logger.h.

Referenced by add(), emitLoggedWarnings(), and getNumberOfWarnings().


The documentation for this class was generated from the following files: