LCOV - code coverage report
Current view: top level - src/utils - Logger.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 24 29 82.8 %
Date: 2026-05-29 20:41:18 Functions: 4 7 57.1 %
Legend: Lines: hit not hit

          Line data    Source code
       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        2117 : Logger::Logger() : _n_errors(0), _n_warnings(0) {}
      13             : 
      14        1951 : Logger::~Logger()
      15             : {
      16        1975 :   for (auto && it : _msgs)
      17          48 :     delete it;
      18        1951 : }
      19             : 
      20             : void
      21        3906 : Logger::emitLoggedErrors() const
      22             : {
      23        3906 :   if (_n_errors > 0)
      24             :   {
      25         136 :     std::ostringstream oss;
      26         136 :     oss << "The following errors were encountered:\n";
      27         378 :     for (const auto & msg_it : _msgs)
      28         242 :       if (msg_it->_type == ERROR)
      29         234 :         oss << "  - " << msg_it->_msg << "\n";
      30         136 :     mooseError(oss.str());
      31           0 :   }
      32        3770 : }
      33             : 
      34             : void
      35        1991 : Logger::emitLoggedWarnings() const
      36             : {
      37        1991 :   if (_n_warnings > 0)
      38             :   {
      39          12 :     std::ostringstream oss;
      40          12 :     oss << "The following warnings were encountered:\n";
      41          58 :     for (const auto & msg_it : _msgs)
      42          46 :       if (msg_it->_type == WARNING)
      43          38 :         oss << "  - " << msg_it->_msg << "\n";
      44           8 :     mooseWarning(oss.str());
      45           8 :   }
      46        1987 : }
      47             : 
      48             : unsigned int
      49           0 : Logger::getNumberOfErrors() const
      50             : {
      51           0 :   return _n_errors;
      52             : }
      53             : 
      54             : unsigned int
      55           0 : Logger::getNumberOfWarnings() const
      56             : {
      57           0 :   return _n_warnings;
      58             : }

Generated by: LCOV version 1.14