LCOV - code coverage report
Current view: top level - include/interfaces - LoggingInterface.h (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 5 5 100.0 %
Date: 2025-07-30 13:02:48 Functions: 0 0 -
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             : #pragma once
      11             : 
      12             : #include "Logger.h"
      13             : 
      14             : class FEProblemBase;
      15             : 
      16             : /**
      17             :  * Interface class for logging errors and warnings
      18             :  *
      19             :  * This allows errors/warnings to be cached and output all at once instead of
      20             :  * needing to stop each time an error is encountered.
      21             :  */
      22             : class LoggingInterface
      23             : {
      24             : public:
      25             :   /**
      26             :    * Constructor
      27             :    *
      28             :    * @param[in] fe_problem  FEProblemBase-derived object that has the Logger instance
      29             :    */
      30             :   LoggingInterface(Logger & log);
      31             : 
      32             :   /**
      33             :    * Logs an error
      34             :    */
      35             :   template <typename... Args>
      36             :   void logError(Args &&... args) const
      37             :   {
      38          16 :     _log.add(Logger::ERROR, std::forward<Args>(args)...);
      39          16 :   }
      40             : 
      41             :   /**
      42             :    * Logs an error for a component
      43             :    *
      44             :    * @param[in] component_name  Name of the component
      45             :    */
      46             :   template <typename... Args>
      47             :   void logComponentError(const std::string & component_name, Args &&... args) const
      48             :   {
      49         273 :     _log.add(Logger::ERROR, component_name, ": ", std::forward<Args>(args)...);
      50           6 :   }
      51             : 
      52             :   /**
      53             :    * Logs a warning
      54             :    */
      55             :   template <typename... Args>
      56             :   void logWarning(Args &&... args) const
      57             :   {
      58             :     _log.add(Logger::WARNING, std::forward<Args>(args)...);
      59             :   }
      60             : 
      61             :   /**
      62             :    * Logs a warning for a component
      63             :    *
      64             :    * @param[in] component_name  Name of the component
      65             :    */
      66             :   template <typename... Args>
      67             :   void logComponentWarning(const std::string & component_name, Args &&... args) const
      68             :   {
      69          46 :     _log.add(Logger::WARNING, component_name, ": ", std::forward<Args>(args)...);
      70             :   }
      71             : 
      72             : protected:
      73             :   Logger & _log;
      74             : };

Generated by: LCOV version 1.14