Belle II Software  release-05-02-19
LogConnectionFilter.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010-2018 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Thomas Kuhr, Thomas Hauth, Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/logging/LogConnectionBase.h>
14 #include <framework/logging/LogMessage.h>
15 
16 #include <memory>
17 
18 namespace Belle2 {
30  class LogConnectionFilter final : public LogConnectionBase {
31 
32  public:
33 
39  explicit LogConnectionFilter(LogConnectionBase* logConnection);
40 
44  virtual ~LogConnectionFilter();
45 
52  bool sendMessage(const LogMessage& message) override;
53 
59  bool isConnected() override;
60 
64  void finalizeOnAbort() override
65  {
67  m_logConnection->finalizeOnAbort();
68  }
69 
70  private:
73 
74  std::unique_ptr<LogConnectionBase> m_logConnection;
76  int m_repeatCounter;
77  };
78 
80 } // end namespace Belle2
Belle2::LogConnectionFilter::sendMessage
bool sendMessage(const LogMessage &message) override
Sends a log message.
Definition: LogConnectionFilter.cc:37
Belle2::LogConnectionFilter::isConnected
bool isConnected() override
Returns true if the log connection could be established.
Definition: LogConnectionFilter.cc:31
Belle2::LogConnectionFilter::m_repeatCounter
int m_repeatCounter
Counter for repeated messages.
Definition: LogConnectionFilter.h:84
Belle2::LogConnectionFilter::finalizeOnAbort
void finalizeOnAbort() override
Finalize on Abort: make sure last repetition is printed if there is any and that connected connection...
Definition: LogConnectionFilter.h:72
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::LogConnectionFilter::LogConnectionFilter
LogConnectionFilter(LogConnectionBase *logConnection)
The constructor.
Definition: LogConnectionFilter.cc:17
Belle2::LogConnectionFilter::m_logConnection
std::unique_ptr< LogConnectionBase > m_logConnection
The actual log connection.
Definition: LogConnectionFilter.h:82
Belle2::LogConnectionFilter::m_previousMessage
LogMessage m_previousMessage
The previous log message.
Definition: LogConnectionFilter.h:83
Belle2::LogConnectionFilter::~LogConnectionFilter
virtual ~LogConnectionFilter()
The LogConnectionFilter destructor.
Definition: LogConnectionFilter.cc:25
Belle2::LogConnectionBase::LogConnectionBase
LogConnectionBase()
The LogConnectionBase default constructor.
Definition: LogConnectionBase.h:36
Belle2::LogConnectionFilter::printRepetitions
void printRepetitions()
If there are repeated messages print the number of repetitions.
Definition: LogConnectionFilter.cc:54
Belle2::LogMessage
The LogMessage class.
Definition: LogMessage.h:39