log4tango  5.0.0
NDC.hh
Go to the documentation of this file.
1 //
2 // NDC.hh
3 //
4 // Copyright (C) : 2000 - 2002
5 // LifeLine Networks BV (www.lifeline.nl). All rights reserved.
6 // Bastiaan Bakker. All rights reserved.
7 //
8 // 2004,2005,2006,2007,2008,2009,2010,2011,2012
9 // Synchrotron SOLEIL
10 // L'Orme des Merisiers
11 // Saint-Aubin - BP 48 - France
12 //
13 // This file is part of log4tango.
14 //
15 // Log4ango is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU Lesser General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 // Log4tango is distributed in the hope that it will be useful,
21 // but WITHOUT ANY WARRANTY; without even the implied warranty of
22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 // GNU Lesser General Public License for more details.
24 //
25 // You should have received a copy of the GNU Lesser General Public License
26 // along with Log4Tango. If not, see <http://www.gnu.org/licenses/>.
27 
28 #ifndef _LOG4TANGO_NDC_H
29 #define _LOG4TANGO_NDC_H
30 
31 #ifdef LOG4TANGO_HAS_NDC
32 
33 #include <log4tango/Portability.hh>
34 #include <string>
35 #include <vector>
36 
37 namespace log4tango {
89 class LOG4TANGO_EXPORT NDC
90 {
91 public:
92 
93  struct DiagnosticContext {
94  DiagnosticContext(const std::string& message);
95  DiagnosticContext(const std::string& message,
96  const DiagnosticContext& parent);
97 
98  std::string message;
99  std::string full_msg;
100  };
101 
102  typedef std::vector<DiagnosticContext> ContextStack;
103 
112  static void clear (void);
113 
127  static ContextStack* clone_stack (void);
128 
133  static const std::string& get (void);
134 
139  static int get_depth (void);
140 
141  static void inherit (ContextStack* stack);
142 
152  static std::string pop (void);
153 
162  static void push (const std::string& message);
163 
170  static void set_max_depth (int max_depth);
171 
176  static NDC& get_ndc();
177 
178  NDC();
179  virtual ~NDC();
180 
181 public:
182  virtual void _clear (void);
183  virtual ContextStack* _clone_stack (void);
184  virtual const std::string& _get (void) const;
185  virtual int _get_depth (void) const;
186  virtual void _inherit (ContextStack* stack);
187  virtual std::string _pop (void);
188  virtual void _push (const std::string& message);
189  virtual void _set_max_depth (int max_depth);
190 
191  ContextStack _stack;
192 };
193 
194 } // namespace log4tango
195 
196 #endif // LOG4TANGO_HAS_NDC
197 
198 #endif // _LOG4TANGO_NDC_HH
Definition: Appender.hh:40
#define LOG4TANGO_EXPORT
Definition: Export.hh:38