E-MailRelay
geventloggingcontext.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 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 "geventlogging.h"
26#include "geventstate.h"
27#include "gstringview.h"
28
29namespace GNet
30{
31 class EventLoggingContext ;
32}
33
34//| \class GNet::EventLoggingContext
35/// A class that sets the G::LogOuput::context() while in scope.
36///
38{
39public:
41 ///< Constructor that sets the G::LogOutput logging context to
42 ///< the accumulation of EventLogging::eventLoggingString()s.
43
44 explicit EventLoggingContext( std::string_view ) ;
45 ///< Constructor that sets the G::LogOutput logging context to
46 ///< the given string.
47
48 EventLoggingContext( EventState , const std::string & ) ;
49 ///< Constructor that sets the G::LogOutput logging context to
50 ///< the accumulation of EventLogging::eventLoggingString()s
51 ///< and the given string.
52
54 ///< Destructor. Restores the logging context.
55
56public:
57 EventLoggingContext( const EventLoggingContext & ) = delete ;
59 EventLoggingContext & operator=( const EventLoggingContext & ) = delete ;
60 EventLoggingContext & operator=( EventLoggingContext && ) = delete ;
61
62private:
63 static std::string_view fn( void * ) ;
64 static void set( std::string & , EventState ) ;
65
66private:
67 static EventLoggingContext * m_inner ;
68 EventLoggingContext * m_outer ;
69 static std::string m_s ;
70} ;
71
72#endif
A class that sets the G::LogOuput::context() while in scope.
~EventLoggingContext()
Destructor. Restores the logging context.
EventLoggingContext(EventState)
Constructor that sets the G::LogOutput logging context to the accumulation of EventLogging::eventLogg...
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
Definition: geventstate.h:131
Network classes.
Definition: gdef.h:1243