00001 /* 00002 * NDC.hh 00003 * 00004 * Copyright 2000, LifeLine Networks BV (www.lifeline.nl). All rights reserved. 00005 * Copyright 2000, Bastiaan Bakker. All rights reserved. 00006 * 00007 * See the COPYING file for the terms of usage and distribution. 00008 */ 00009 00010 #ifndef _LOG4CPP_NDC_HH 00011 #define _LOG4CPP_NDC_HH 00012 00013 #include <log4cpp/Portability.hh> 00014 #include <string> 00015 #include <vector> 00016 00017 LOG4CPP_NS_BEGIN 00069 class LOG4CPP_EXPORT NDC { 00070 static bool isUsedNDC; 00071 static const std::string emptyString; 00072 public: 00073 00074 struct DiagnosticContext { 00075 DiagnosticContext(const std::string& message); 00076 DiagnosticContext(const std::string& message, 00077 const DiagnosticContext& parent); 00078 00079 std::string message; 00080 std::string fullMessage; 00081 }; 00082 00083 00085 static void shutdown(); 00086 00087 typedef std::vector<DiagnosticContext> ContextStack; 00088 00097 static void clear(); 00098 00112 static ContextStack* cloneStack(); 00113 00118 static const std::string& get(); 00119 00124 static size_t getDepth(); 00125 00126 static void inherit(ContextStack* stack); 00127 00138 static std::string pop(); 00139 00148 static void push(const std::string& message); 00149 00156 static void setMaxDepth(int maxDepth); 00157 00162 static NDC& getNDC(); 00163 00164 NDC(); 00165 virtual ~NDC(); 00166 00167 public: 00168 virtual void _clear(); 00169 virtual ContextStack* _cloneStack(); 00170 virtual const std::string& _get() const; 00171 virtual size_t _getDepth() const; 00172 virtual void _inherit(ContextStack* stack); 00173 virtual std::string _pop(); 00174 virtual void _push(const std::string& message); 00175 virtual void _setMaxDepth(int maxDepth); 00176 00177 ContextStack _stack; 00178 }; 00179 LOG4CPP_NS_END 00180 00181 #endif // _LOG4CPP_NDC_HH