log4cpp 1.1
|
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 namespace log4cpp { 00069 class LOG4CPP_EXPORT NDC { 00074 static bool isUsedNDC; 00075 static const std::string emptyString; 00076 public: 00077 00078 struct DiagnosticContext { 00079 DiagnosticContext(const std::string& message); 00080 DiagnosticContext(const std::string& message, 00081 const DiagnosticContext& parent); 00082 00083 std::string message; 00084 std::string fullMessage; 00085 }; 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 } 00180 00181 #endif // _LOG4CPP_NDC_HH