E-MailRelay
geventloggingcontext.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2021 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file geventloggingcontext.h
19///
20
21#ifndef G_NET_EVENT_LOGGING_CONTEXT_H
22#define G_NET_EVENT_LOGGING_CONTEXT_H
23
24#include "gdef.h"
25#include "gexceptionsource.h"
26
27namespace GNet
28{
29 class EventLoggingContext ;
30}
31
32//| \class GNet::EventLoggingContext
33/// A class that sets the G::LogOuput::context() while in scope.
34///
36{
37public:
38 explicit EventLoggingContext( ExceptionSource * esrc ) ;
39 ///< Constructor that sets the logging context to
40 ///< whatever ExceptionSource::exceptionSourceId()
41 ///< returns.
42
43 explicit EventLoggingContext( const std::string & ) ;
44 ///< Constructor that sets the logging context to
45 ///< the given string.
46
47 ~EventLoggingContext() noexcept ;
48 ///< Destructor. Restores the logging context.
49
50public:
51 EventLoggingContext( const EventLoggingContext & ) = delete ;
53 void operator=( const EventLoggingContext & ) = delete ;
54 void operator=( EventLoggingContext && ) = delete ;
55
56private:
57 static std::string fn( void * ) ;
58 std::string str() ;
59
60private:
61 static EventLoggingContext * m_inner ;
62 EventLoggingContext * m_outer ;
63 ExceptionSource * m_esrc ;
64 std::string m_s ;
65} ;
66
67#endif
A class that sets the G::LogOuput::context() while in scope.
EventLoggingContext(ExceptionSource *esrc)
Constructor that sets the logging context to whatever ExceptionSource::exceptionSourceId() returns.
~EventLoggingContext() noexcept
Destructor. Restores the logging context.
A mixin base class that identifies the source of an exception when delivered to GNet::ExceptionHandle...
Network classes.
Definition: gdef.h:1115