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
27 namespace GNet
28{
29 class EventLoggingContext ;
30}
31
32//| \class GNet::EventLoggingContext
33/// A class that sets the G::LogOuput::context() while in scope.
34///
35 class GNet::EventLoggingContext
36{
37 public:
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
50 public:
51 EventLoggingContext( const EventLoggingContext & ) = delete ;
52 EventLoggingContext( EventLoggingContext && ) = delete ;
53 void operator=( const EventLoggingContext & ) = delete ;
54 void operator=( EventLoggingContext && ) = delete ;
55
56 private:
57 static std::string fn( void * ) ;
58 std::string str() ;
59
60 private:
61 static EventLoggingContext * m_inner ;
62 EventLoggingContext * m_outer ;
63 ExceptionSource * m_esrc ;
64 std::string m_s ;
65} ;
66
67#endif
GNet::EventLoggingContext
A class that sets the G::LogOuput::context() while in scope.
Definition: geventloggingcontext.h:36
GNet::EventLoggingContext::EventLoggingContext
EventLoggingContext(ExceptionSource *esrc)
Constructor that sets the logging context to whatever ExceptionSource::exceptionSourceId() returns.
Definition: geventloggingcontext.cpp:28
GNet::EventLoggingContext::~EventLoggingContext
~EventLoggingContext() noexcept
Destructor. Restores the logging context.
Definition: geventloggingcontext.cpp:45
GNet::ExceptionSource
A mixin base class that identifies the source of an exception when delivered to GNet::ExceptionHandle...
Definition: gexceptionsource.h:40
gexceptionsource.h
GNet
Network classes.
Definition: gdef.h:1115