https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
12Logger::Logger() : _n_errors(0), _n_warnings(0) {}
13
15{
16 for (auto && it : _msgs)
17 delete it;
18}
19
20void
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
34void
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
48unsigned int
50{
51 return _n_errors;
52}
53
54unsigned int
56{
57 return _n_warnings;
58}
void mooseWarning(Args &&... args)
void mooseError(Args &&... args)
unsigned int _n_warnings
The number of warnings.
Definition Logger.h:100
void emitLoggedErrors() const
Calls mooseError if there are any logged errors.
Definition Logger.C:21
std::vector< Message * > _msgs
The list of logged messages.
Definition Logger.h:102
unsigned int _n_errors
The number of errors.
Definition Logger.h:98
@ ERROR
Definition Logger.h:25
@ WARNING
Definition Logger.h:26
Logger()
Definition Logger.C:12
unsigned int getNumberOfWarnings() const
Return the number of warnings.
Definition Logger.C:55
virtual ~Logger()
Definition Logger.C:14
void emitLoggedWarnings() const
Calls mooseWarning if there are any logged warnings.
Definition Logger.C:35
unsigned int getNumberOfErrors() const
Return the number of errors.
Definition Logger.C:49