log4cplus 2.0.8
mdc.h
Go to the documentation of this file.
1// -*- C++ -*-
2// Copyright (C) 2010-2017, Vaclav Haisman. All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without modifica-
5// tion, are permitted provided that the following conditions are met:
6//
7// 1. Redistributions of source code must retain the above copyright notice,
8// this list of conditions and the following disclaimer.
9//
10// 2. Redistributions in binary form must reproduce the above copyright notice,
11// this list of conditions and the following disclaimer in the documentation
12// and/or other materials provided with the distribution.
13//
14// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
15// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
17// APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
19// DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
20// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
25#ifndef LOG4CPLUS_MDC_H_HEADER
26#define LOG4CPLUS_MDC_H_HEADER
27
28#include <log4cplus/config.hxx>
29
30#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
31#pragma once
32#endif
33
34#include <log4cplus/tstring.h>
35
36#include <map>
37
38
39namespace log4cplus
40{
41
42
43typedef std::map<tstring, tstring> MappedDiagnosticContextMap;
44
45
47{
48public:
54 void clear();
55
56 void put (tstring const & key, tstring const & value);
57 bool get (tstring * value, tstring const & key) const;
58 void remove (tstring const & key);
59
61
62 // Public ctor and dtor but only to be used by internal::DefaultContext.
63 MDC ();
64 virtual ~MDC ();
65
66private:
68};
69
70
72
73
74} // namespace log4cplus
75
76
77#endif // LOG4CPLUS_MDC_H_HEADER
void clear()
Clear any nested diagnostic information if any.
void put(tstring const &key, tstring const &value)
virtual ~MDC()
bool get(tstring *value, tstring const &key) const
MappedDiagnosticContextMap const & getContext() const
void remove(tstring const &key)
#define LOG4CPLUS_PRIVATE
Definition: config.hxx:53
LOG4CPLUS_EXPORT MDC & getMDC()
std::basic_string< tchar > tstring
Definition: tstring.h:39
std::map< tstring, tstring > MappedDiagnosticContextMap
Definition: mdc.h:43
#define LOG4CPLUS_EXPORT
Definition: win32.h:141