Apache Log4cxx  Version 1.3.0
Loading...
Searching...
No Matches
mdc.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_MDC_H
19#define _LOG4CXX_MDC_H
20
21#include <log4cxx/log4cxx.h>
22#include <log4cxx/logstring.h>
23#include <map>
24
25namespace LOG4CXX_NS
26{
27
46{
47 public:
50 typedef std::map<LogString, LogString> Map;
51
59 MDC(const std::string& key, const std::string& value);
61
70 static void put(const std::string& key, const std::string& value);
77 static void putLS(const LogString& key, const LogString& value);
78
86 static std::string get(const std::string& key);
93 static bool get(const LogString& key, LogString& dest);
94
101 static std::string remove(const std::string& key);
102#if LOG4CXX_WCHAR_T_API
110 MDC(const std::wstring& key, const std::wstring& value);
119 static void put(const std::wstring& key, const std::wstring& value);
127 static std::wstring get(const std::wstring& key);
134 static std::wstring remove(const std::wstring& key);
135#endif
136#if LOG4CXX_UNICHAR_API
144 MDC(const std::basic_string<UniChar>& key, const std::basic_string<UniChar>& value);
153 static void put(const std::basic_string<UniChar>& key, const std::basic_string<UniChar>& value);
161 static std::basic_string<UniChar> get(const std::basic_string<UniChar>& key);
168 static std::basic_string<UniChar> remove(const std::basic_string<UniChar>& key);
169#endif
170#if LOG4CXX_CFSTRING_API
178 MDC(const CFStringRef& key, const CFStringRef& value);
187 static void put(const CFStringRef& key, const CFStringRef& value);
195 static CFStringRef get(const CFStringRef& key);
202 static CFStringRef remove(const CFStringRef& key);
203#endif
211 static bool remove(const LogString& key, LogString& prevValue);
212
219 static void clear();
220
221 private:
222 MDC(const MDC&);
223 MDC& operator=(const MDC&);
225}; // class MDC;
226} // namespace log4cxx
227
228
229#endif // _LOG4CXX_MDC_H
A Mapped Diagnostic Context, or MDC in short, is an instrument for distinguishing interleaved log out...
Definition: mdc.h:46
MDC(const std::wstring &key, const std::wstring &value)
Places a key/value pair in the MDC for the current thread which will be removed during the correspond...
MDC(const std::string &key, const std::string &value)
Places a key/value pair in the MDC for the current thread which will be removed during the correspond...
MDC(const std::basic_string< UniChar > &key, const std::basic_string< UniChar > &value)
Places a key/value pair in the MDC for the current thread which will be removed during the correspond...
static bool get(const LogString &key, LogString &dest)
Gets the context identified by the key parameter.
MDC(const CFStringRef &key, const CFStringRef &value)
Places a key/value pair in the MDC for the current thread which will be removed during the correspond...
static void clear()
Clear all entries in the MDC.
static std::string remove(const std::string &key)
Remove the the context identified by the key parameter.
static std::basic_string< UniChar > remove(const std::basic_string< UniChar > &key)
Remove the the context identified by the key parameter.
static void putLS(const LogString &key, const LogString &value)
Set the key context in the current thread's context map to value.
static void put(const CFStringRef &key, const CFStringRef &value)
Set the key context in the current thread's context map to value.
static void put(const std::string &key, const std::string &value)
Set the key context in the current thread's context map to value.
static void put(const std::wstring &key, const std::wstring &value)
Set the key context in the current thread's context map to value.
static std::basic_string< UniChar > get(const std::basic_string< UniChar > &key)
Get the context identified by the key parameter.
static bool remove(const LogString &key, LogString &prevValue)
Remove the the context identified by the key parameter.
static void put(const std::basic_string< UniChar > &key, const std::basic_string< UniChar > &value)
Set the key context in the current thread's context map to value.
static std::string get(const std::string &key)
Get the context identified by the key parameter.
static CFStringRef get(const CFStringRef &key)
Get the context identified by the key parameter.
static std::wstring remove(const std::wstring &key)
Remove the the context identified by the key parameter.
static CFStringRef remove(const CFStringRef &key)
Remove the the context identified by the key parameter.
static std::wstring get(const std::wstring &key)
Get the context identified by the key parameter.
std::map< LogString, LogString > Map
String to string stl map.
Definition: mdc.h:50
#define LOG4CXX_EXPORT
Definition: log4cxx.h:101
#define LOG4CXX_DECLARE_PRIVATE_MEMBER(T, V)
Definition: log4cxx.h:86
#define LOG4CXX_NS
Definition: log4cxx.h:104
const struct __CFString * CFStringRef
Definition: logstring.h:30
std::basic_string< logchar > LogString
Definition: logstring.h:60