Belle II Software development
LogConnectionTxtFile.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <framework/logging/LogConnectionBase.h>
12
13#include <string>
14#include <fstream>
15
16namespace Belle2 {
28
29 public:
30
38 explicit LogConnectionTxtFile(const std::string& filename, bool append = false);
39
42
49 bool sendMessage(const LogMessage& message) override;
50
56 bool isConnected() override;
57
59 void finalizeOnAbort() override;
60
61 private:
62 std::ofstream m_fileStream;
64 };
65
67} // end namespace Belle2
Abstract base class for the different types of log connections.
Implements a log connection to a text file.
virtual ~LogConnectionTxtFile()
The LogConnectionTxtFile destructor.
std::ofstream m_fileStream
The file output stream used for sending the log message.
bool isConnected() override
Returns true if the connection to the text file could be established.
bool sendMessage(const LogMessage &message) override
Sends a log message.
void finalizeOnAbort() override
Make sure the file is closed on abort.
The LogMessage class.
Definition: LogMessage.h:29
Abstract base class for different kinds of events.