Apache log4cxx  Version 0.12.0
threadspecificdata.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_HELPERS_THREAD_SPECIFIC_DATA_H
19 #define _LOG4CXX_HELPERS_THREAD_SPECIFIC_DATA_H
20 
21 #include <log4cxx/ndc.h>
22 #include <log4cxx/mdc.h>
23 
24 #if defined(_MSC_VER)
25  #pragma warning ( push )
26  #pragma warning ( disable: 4251 )
27 #endif
28 
29 namespace log4cxx
30 {
31 namespace helpers
32 {
37 class LOG4CXX_EXPORT ThreadSpecificData
38 {
39  public:
42 
47  static ThreadSpecificData* getCurrentData();
51  void recycle();
52 
53  static void put(const LogString& key, const LogString& val);
54  static void push(const LogString& val);
55  static void inherit(const log4cxx::NDC::Stack& stack);
56 
57  log4cxx::NDC::Stack& getStack();
58  log4cxx::MDC::Map& getMap();
59 
60 
61  private:
62  static ThreadSpecificData& getDataNoThreads();
63  static ThreadSpecificData* createCurrentData();
64  log4cxx::NDC::Stack ndcStack;
65  log4cxx::MDC::Map mdcMap;
66 };
67 
68 } // namespace helpers
69 } // namespace log4cxx
70 
71 #if defined(_MSC_VER)
72  #pragma warning (pop)
73 #endif
74 
75 #endif
std::map< LogString, LogString > Map
String to string stl map.
Definition: mdc.h:46
This class contains all the thread-specific data in use by log4cxx.
Definition: threadspecificdata.h:37
std::stack< DiagnosticContext > Stack
Definition: ndc.h:102
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66