15#include <mitkCommon.h>
23 if ( m_OutputStream.is_open() ) { m_OutputStream.close(); }
28 if ( m_OutputStream.is_open() ) { m_OutputStream.close(); }
30 m_OutputStream.open(filename.c_str());
31 if ( ! m_OutputStream.is_open() )
33 MITK_ERROR(
"USNavigationLoggingBackend")
34 <<
"File '" << filename <<
"' cannot be opened for logging.";
35 mitkThrow() <<
"File '" << filename <<
"' cannot be opened for logging.";
41 if ( m_OutputStream.is_open()) {this->FormatSmart(m_OutputStream, logMessage);}
42 if (logMessage.Category ==
"USNavigationLogging")
44 m_lastNavigationMessages.push_back(logMessage.Message);
45 m_allNavigationMessages.push_back(logMessage.Message);
51return m_lastNavigationMessages;
56 std::ofstream csvStream;
57 csvStream.open(filename.c_str());
58 if ( ! csvStream.is_open() ) {MITK_ERROR(
"USNavigationLoggingBackend") <<
"File '" << filename <<
"' cannot be opened for logging.";
return;}
59 for (std::size_t i = 0; i < m_allNavigationMessages.size(); i++)
61 csvStream << m_allNavigationMessages.at(i) <<
"\n";
68m_lastNavigationMessages = std::vector<std::string>();
73 return OutputType::File;
std::vector< std::string > GetNavigationMessages()
void ClearNavigationMessages()
OutputType GetOutputType() const override
~USNavigationLoggingBackend() override
void ProcessMessage(const LogMessage &logMessage) override
This method is called by the mbi logging mechanism if the object is registered in the mbi logging mec...
void WriteCSVFileWithNavigationMessages(std::string filename)
USNavigationLoggingBackend()
void SetOutputFileName(std::string filename)
Set file path und name for the output file. The file will be opened and all log messages will be dire...