Apache Log4cxx
Version 1.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
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
namespace
LOG4CXX_NS
25
{
26
namespace
helpers
27
{
32
class
LOG4CXX_EXPORT
ThreadSpecificData
33
{
34
public
:
35
ThreadSpecificData
();
36
ThreadSpecificData
(
ThreadSpecificData
&& other);
37
~ThreadSpecificData
();
38
43
static
ThreadSpecificData
*
getCurrentData
();
44
48
void
recycle
();
49
53
static
void
put
(
const
LogString
& key,
const
LogString
& val);
54
58
static
void
push
(
const
LogString
& val);
59
63
static
void
inherit
(
const
NDC::Stack
& stack);
64
68
NDC::Stack
&
getStack
();
69
73
MDC::Map
&
getMap
();
74
78
template
<
typename
T>
79
static
std::basic_ostringstream<T>&
getStringStream
()
80
{
81
return
getStream(T());
82
}
83
87
template
<
typename
T>
88
static
void
releaseStringStream
(std::basic_ostringstream<T>& ss)
89
{
90
releaseStream(ss);
91
}
92
96
struct
NamePair
97
{
98
LogString
idString
;
99
LogString
threadName
;
100
};
101
using
NamePairPtr
= std::shared_ptr<NamePair>;
108
static
NamePairPtr
getNames
();
109
private
:
110
static
std::basic_ostringstream<char>& getStream(
const
char
&);
111
static
void
releaseStream(std::basic_ostringstream<char>&);
112
113
#if LOG4CXX_WCHAR_T_API || LOG4CXX_LOGCHAR_IS_WCHAR
114
static
std::basic_ostringstream<wchar_t>& getStream(
const
wchar_t
&);
115
static
void
releaseStream(std::basic_ostringstream<wchar_t>&);
116
#endif
117
#if LOG4CXX_UNICHAR_API || LOG4CXX_LOGCHAR_IS_UNICHAR
118
static
std::basic_ostringstream<UniChar>& getStream(
const
UniChar
&);
119
static
void
releaseStream(std::basic_ostringstream<UniChar>&);
120
#endif
121
LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(ThreadSpecificDataPrivate, m_priv)
122
};
123
124
}
// namespace helpers
125
}
// namespace log4cxx
126
127
128
#endif
log4cxx::MDC::Map
std::map< LogString, LogString > Map
String to string stl map.
Definition
mdc.h:50
log4cxx::NDC::Stack
std::stack< DiagnosticContext > Stack
Definition
ndc.h:85
log4cxx::helpers::ThreadSpecificData::NamePairPtr
std::shared_ptr< NamePair > NamePairPtr
Definition
threadspecificdata.h:101
log4cxx::helpers::ThreadSpecificData::push
static void push(const LogString &val)
Add val to the nested diagnostic context of the current thread.
log4cxx::helpers::ThreadSpecificData::releaseStringStream
static void releaseStringStream(std::basic_ostringstream< T > &ss)
Make ss available for use by the current thread.
Definition
threadspecificdata.h:88
log4cxx::helpers::ThreadSpecificData::~ThreadSpecificData
~ThreadSpecificData()
log4cxx::helpers::ThreadSpecificData::getStringStream
static std::basic_ostringstream< T > & getStringStream()
A character output stream only assessable to the current thread.
Definition
threadspecificdata.h:79
log4cxx::helpers::ThreadSpecificData::ThreadSpecificData
ThreadSpecificData()
log4cxx::helpers::ThreadSpecificData::ThreadSpecificData
ThreadSpecificData(ThreadSpecificData &&other)
log4cxx::helpers::ThreadSpecificData::getCurrentData
static ThreadSpecificData * getCurrentData()
Gets current thread specific data.
log4cxx::helpers::ThreadSpecificData::getNames
static NamePairPtr getNames()
A reference counted pointer to the names of the current thread.
log4cxx::helpers::ThreadSpecificData::getStack
NDC::Stack & getStack()
The nested diagnostic context of the current thread.
log4cxx::helpers::ThreadSpecificData::put
static void put(const LogString &key, const LogString &val)
Add the key val pair to the mapped diagnostic context of the current thread.
log4cxx::helpers::ThreadSpecificData::inherit
static void inherit(const NDC::Stack &stack)
Use stack as the nested diagnostic context of the current thread.
log4cxx::helpers::ThreadSpecificData::getMap
MDC::Map & getMap()
The mapped diagnostic context of the current thread.
log4cxx::helpers::ThreadSpecificData::recycle
void recycle()
Remove current thread data from APR if the diagnostic context is empty.
mdc.h
log4cxx::LogString
std::basic_string< logchar > LogString
Definition
logstring.h:60
log4cxx::UniChar
unsigned short UniChar
Definition
logstring.h:38
ndc.h
log4cxx::helpers::ThreadSpecificData::NamePair
The names assigned to the current thread.
Definition
threadspecificdata.h:97
log4cxx::helpers::ThreadSpecificData::NamePair::threadName
LogString threadName
Definition
threadspecificdata.h:99
log4cxx::helpers::ThreadSpecificData::NamePair::idString
LogString idString
Definition
threadspecificdata.h:98
src
main
include
log4cxx
helpers
threadspecificdata.h
Generated by
1.17.0 on
SITE_PUBLISHED_DATE
Copyright © 2017-2026
Apache Software Foundation
. Apache, Chainsaw, log4cxx, Log4j, Log4net, log4php and the Apache logo are
trademarks or registered trademarks
of The Apache Software Foundation.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Privacy Policy
.