https://mooseframework.inl.gov
Logger.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "Logger.h"
11 
12 Logger::Logger() : _n_errors(0), _n_warnings(0) {}
13 
15 {
16  for (auto && it : _msgs)
17  delete it;
18 }
19 
20 void
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 }
33 
34 void
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 }
47 
48 unsigned int
50 {
51  return _n_errors;
52 }
53 
54 unsigned int
56 {
57  return _n_warnings;
58 }
virtual ~Logger()
Definition: Logger.C:14
void mooseError(Args &&... args)
void emitLoggedErrors() const
Calls mooseError if there are any logged errors.
Definition: Logger.C:21
void mooseWarning(Args &&... args)
unsigned int getNumberOfWarnings() const
Return the number of warnings.
Definition: Logger.C:55
unsigned int _n_errors
The number of errors.
Definition: Logger.h:98
Logger()
Definition: Logger.C:12
void emitLoggedWarnings() const
Calls mooseWarning if there are any logged warnings.
Definition: Logger.C:35
std::vector< Message * > _msgs
The list of logged messages.
Definition: Logger.h:102
unsigned int getNumberOfErrors() const
Return the number of errors.
Definition: Logger.C:49
unsigned int _n_warnings
The number of warnings.
Definition: Logger.h:100