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