LCOV - code coverage report
Current view: top level - snaplogger - nested_diagnostic.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 15 73.3 %
Date: 2019-08-24 13:53:02 Functions: 3 5 60.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013-2019  Made to Order Software Corp.  All Rights Reserved
       3             :  *
       4             :  * https://snapwebsites.org/project/snaplogger
       5             :  * contact@m2osw.com
       6             :  *
       7             :  * This program is free software; you can redistribute it and/or modify
       8             :  * it under the terms of the GNU General Public License as published by
       9             :  * the Free Software Foundation; either version 2 of the License, or
      10             :  * (at your option) any later version.
      11             :  *
      12             :  * This program is distributed in the hope that it will be useful,
      13             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :  * GNU General Public License for more details.
      16             :  *
      17             :  * You should have received a copy of the GNU General Public License along
      18             :  * with this program; if not, write to the Free Software Foundation, Inc.,
      19             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      20             :  */
      21             : 
      22             : /** \file
      23             :  * \brief Appenders are used to append data to somewhere.
      24             :  *
      25             :  * This file declares the base appender class.
      26             :  */
      27             : 
      28             : 
      29             : // self
      30             : //
      31             : #include    "snaplogger/nested_diagnostic.h"
      32             : 
      33             : #include    "snaplogger/guard.h"
      34             : #include    "snaplogger/message.h"
      35             : #include    "snaplogger/private_logger.h"
      36             : 
      37             : 
      38             : // last include
      39             : //
      40             : #include    <snapdev/poison.h>
      41             : 
      42             : 
      43             : 
      44             : namespace snaplogger
      45             : {
      46             : 
      47             : 
      48             : 
      49           3 : nested_diagnostic::nested_diagnostic(std::string const & diagnostic, bool emit_enter_exit_events)
      50           3 :     : f_emit_enter_exit_events(emit_enter_exit_events)
      51             : {
      52           3 :     get_private_logger()->push_nested_diagnostic(diagnostic);
      53             : 
      54           3 :     if(f_emit_enter_exit_events)
      55             :     {
      56           0 :         SNAP_LOG_UNIMPORTANT << "entering nested diagnostic" << SNAP_LOG_SEND;
      57             :     }
      58           3 : }
      59             : 
      60             : 
      61           6 : nested_diagnostic::~nested_diagnostic()
      62             : {
      63           3 :     if(f_emit_enter_exit_events)
      64             :     {
      65           0 :         SNAP_LOG_UNIMPORTANT << "exiting nested diagnostic" << SNAP_LOG_SEND;
      66             :     }
      67             : 
      68           3 :     get_private_logger()->pop_nested_diagnostic();
      69           3 : }
      70             : 
      71             : 
      72           0 : string_vector_t get_nested_diagnostics()
      73             : {
      74           0 :     return get_private_logger()->get_nested_diagnostics();
      75             : }
      76             : 
      77             : 
      78           8 : string_vector_t get_nested_diagnostics(message const & msg)
      79             : {
      80           8 :     return get_private_logger(msg)->get_nested_diagnostics();
      81             : }
      82             : 
      83             : 
      84             : 
      85             : } // snaplogger namespace
      86             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.12