Apache Log4cxx  Version 1.2.0
Loading...
Searching...
No Matches
ndc.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _LOG4CXX_NDC_H
19#define _LOG4CXX_NDC_H
20
21#include <log4cxx/log4cxx.h>
22#include <log4cxx/logstring.h>
23#include <stack>
24
25namespace LOG4CXX_NS
26{
27
78class LOG4CXX_EXPORT NDC
79{
80 public:
84 typedef std::pair<LogString, LogString> DiagnosticContext;
85 typedef std::stack<DiagnosticContext> Stack;
86
93 NDC(const std::string& message);
94
101
107 static void clear();
108
120 static Stack* cloneStack();
121
134 static void inherit(Stack* stack);
135
142 static bool get(LogString& dest);
143
147 static int getDepth();
148
149
153 static bool empty();
154
162 static LogString pop();
168 static bool pop(std::string& buf);
169
177 static LogString peek();
183 static bool peek(std::string& buf);
184
191 static void push(const std::string& message);
198 static void pushLS(const LogString& message);
199
206 static void remove();
207
208#if LOG4CXX_WCHAR_T_API
215 NDC(const std::wstring& message);
220 static void push(const std::wstring& message);
226 static bool peek(std::wstring& dst);
232 static bool pop(std::wstring& dst);
233#endif
234#if LOG4CXX_UNICHAR_API
241 NDC(const std::basic_string<UniChar>& message);
248 static void push(const std::basic_string<UniChar>& message);
254 static bool peek(std::basic_string<UniChar>& dst);
260 static bool pop(std::basic_string<UniChar>& dst);
261#endif
262#if LOG4CXX_CFSTRING_API
269 NDC(const CFStringRef& message);
274 static void push(const CFStringRef& message);
280 static bool peek(CFStringRef& dst);
286 static bool pop(CFStringRef& dst);
287#endif
288
289 private:
290 NDC(const NDC&);
291 NDC& operator=(const NDC&);
292 static LogString& getMessage(DiagnosticContext& ctx);
293 static LogString& getFullMessage(DiagnosticContext& ctx);
294}; // class NDC;
295} // namespace log4cxx
296
297#endif // _LOG4CXX_NDC_H
A Nested Diagnostic Context, or NDC in short, is an instrument to distinguish interleaved log output ...
Definition: ndc.h:79
static void pushLS(const LogString &message)
Add message to the stack associated with the current thread.
NDC(const std::basic_string< UniChar > &message)
Add message onto the context stack.
std::stack< DiagnosticContext > Stack
Definition: ndc.h:85
static void push(const std::basic_string< UniChar > &message)
Add message to the stack associated with the current thread.
static void push(const CFStringRef &message)
Add message to the stack associated with the current thread.
~NDC()
Remove the topmost element from the context stack associated with the current thread.
static bool pop(CFStringRef &dst)
Append to dst the top value in the stack associated with the current thread and then remove it.
static LogString pop()
Get the value at the top of the stack associated with the current thread and then remove it.
static Stack * cloneStack()
Clone the diagnostic context for the current thread.
static void push(const std::string &message)
Add message to the stack associated with the current thread.
std::pair< LogString, LogString > DiagnosticContext
Pair of Message and FullMessage.
Definition: ndc.h:84
static bool pop(std::string &buf)
Append to buf the top value in the stack associated with the current thread and then remove it.
static void clear()
Clear any nested diagnostic information if any.
static bool peek(std::basic_string< UniChar > &dst)
Append to dst the top value in the stack associated with the current thread without removing it.
static void inherit(Stack *stack)
Inherit the diagnostic context of another thread.
static void push(const std::wstring &message)
Add message to the stack associated with the current thread.
static bool empty()
Tests if the NDC is empty.
NDC(const CFStringRef &message)
Add message onto the context stack.
static bool pop(std::wstring &dst)
Appends the current NDC content to the provided string and removes the value from the NDC.
static void remove()
Remove all the diagnostic context data for this thread.
static int getDepth()
Get the current nesting depth of this diagnostic context.
NDC(const std::string &message)
Add message onto the context stack.
static bool peek(CFStringRef &dst)
Append to dst the top value in the stack associated with the current thread without removing it.
static LogString peek()
Get the value at the top of the stack associated with the current thread without removing it.
static bool pop(std::basic_string< UniChar > &dst)
Append to dst the top value in the stack associated with the current thread and then remove it.
static bool get(LogString &dest)
Get the current value of the NDC of the currrent thread.
static bool peek(std::wstring &dst)
Append to dst the top value in the stack associated with the current thread without removing it.
static bool peek(std::string &buf)
Append to buf the top value in the stack associated with the current thread without removing it.
NDC(const std::wstring &message)
Add message onto the context stack.
const struct __CFString * CFStringRef
Definition: logstring.h:30
std::basic_string< logchar > LogString
Definition: logstring.h:60