Belle II Software  release-05-02-19
LogConnectionTxtFile.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: Andreas Moll, 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 
15 #include <string>
16 #include <fstream>
17 
18 namespace Belle2 {
29  class LogConnectionTxtFile final: public LogConnectionBase {
30 
31  public:
32 
40  explicit LogConnectionTxtFile(const std::string& filename, bool append = false);
41 
43  virtual ~LogConnectionTxtFile();
44 
51  bool sendMessage(const LogMessage& message) override;
52 
58  bool isConnected() override;
59 
61  void finalizeOnAbort() override;
62 
63  private:
64  std::ofstream m_fileStream;
66  };
67 
69 } // end namespace Belle2
Belle2::LogConnectionTxtFile::LogConnectionTxtFile
LogConnectionTxtFile(const std::string &filename, bool append=false)
The constructor.
Definition: LogConnectionTxtFile.cc:17
Belle2::LogConnectionTxtFile::m_fileStream
std::ofstream m_fileStream
The file output stream used for sending the log message.
Definition: LogConnectionTxtFile.h:72
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::LogConnectionTxtFile::finalizeOnAbort
void finalizeOnAbort() override
Make sure the file is closed on abort.
Definition: LogConnectionTxtFile.cc:37
Belle2::LogConnectionTxtFile::isConnected
bool isConnected() override
Returns true if the connection to the text file could be established.
Definition: LogConnectionTxtFile.cc:24
Belle2::LogConnectionTxtFile::sendMessage
bool sendMessage(const LogMessage &message) override
Sends a log message.
Definition: LogConnectionTxtFile.cc:29
Belle2::LogConnectionTxtFile::~LogConnectionTxtFile
virtual ~LogConnectionTxtFile()
The LogConnectionTxtFile destructor.