NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
Logger Class Reference

This class represents a simple logging functionality, which might be extended in the future to handle more generic logging formats. More...

#include <logger.hpp>

Inheritance diagram for Logger:
Collaboration diagram for Logger:

Public Types

enum  LogLevel {
  LVL_DEBUG , LVL_INFO , LVL_CMDLINE , LVL_WARNING ,
  LVL_ERROR , LVL_DISABLED
}
 

Public Member Functions

 Logger ()
 Empty default constructor. More...
 
 Logger (const std::string &sLogFile)
 Generic constructor. Will open the target file, if possible. More...
 
bool open (const std::string &sLogFile)
 Open the target logging file for writing. More...
 
void close ()
 Close the logger stream. More...
 
bool is_open () const
 Check, whether the logger stream is currently open. More...
 
void push (const std::string &sMessage)
 Push a message to the logger stream. Will automatically re-open a file, if the stream had been closed. More...
 
void push_line (const std::string &sMessage)
 Push a line to the logger stream. The stream will automatically append the line termination characters. More...
 

Private Member Functions

bool ensure_open ()
 Ensures that the stream is open and tries to re-open it otherwise. More...
 

Private Attributes

std::ofstream m_logFile
 
std::string m_sLogFile
 

Detailed Description

This class represents a simple logging functionality, which might be extended in the future to handle more generic logging formats.

Definition at line 32 of file logger.hpp.

Member Enumeration Documentation

◆ LogLevel

Enumerator
LVL_DEBUG 
LVL_INFO 
LVL_CMDLINE 
LVL_WARNING 
LVL_ERROR 
LVL_DISABLED 

Definition at line 51 of file logger.hpp.

Constructor & Destructor Documentation

◆ Logger() [1/2]

Logger::Logger ( )

Empty default constructor.

Definition at line 71 of file logger.cpp.

◆ Logger() [2/2]

Logger::Logger ( const std::string &  sLogFile)

Generic constructor. Will open the target file, if possible.

Parameters
sLogFileconst std::string&

Definition at line 84 of file logger.cpp.

References open().

Here is the call graph for this function:

Member Function Documentation

◆ close()

void Logger::close ( )

Close the logger stream.

Returns
void

Definition at line 118 of file logger.cpp.

References m_logFile.

Referenced by Script::close(), Script::getNextScriptCommandFromScript(), and Script::returnCommand().

◆ ensure_open()

bool Logger::ensure_open ( )
private

Ensures that the stream is open and tries to re-open it otherwise.

Returns
bool

Definition at line 144 of file logger.cpp.

References m_logFile, and m_sLogFile.

Referenced by push(), and push_line().

◆ is_open()

bool Logger::is_open ( ) const

Check, whether the logger stream is currently open.

Returns
bool

Definition at line 131 of file logger.cpp.

References m_logFile.

Referenced by Script::close(), Script::getNextScriptCommandFromScript(), DetachedLogger::is_buffering(), and Script::returnCommand().

◆ open()

bool Logger::open ( const std::string &  sLogFile)

Open the target logging file for writing.

Parameters
sLogFileconst std::string&
Returns
bool
Warning
The logger will not validate file paths.

Definition at line 100 of file logger.cpp.

References m_logFile, and m_sLogFile.

Referenced by Logger(), DetachedLogger::open(), and Script::startInstallation().

◆ push()

void Logger::push ( const std::string &  sMessage)

Push a message to the logger stream. Will automatically re-open a file, if the stream had been closed.

Parameters
sMessageconst std::string&
Returns
void

Definition at line 162 of file logger.cpp.

References ensure_open(), and m_logFile.

Referenced by Script::close(), Script::getNextScriptCommandFromScript(), and Script::returnCommand().

Here is the call graph for this function:

◆ push_line()

void Logger::push_line ( const std::string &  sMessage)

Push a line to the logger stream. The stream will automatically append the line termination characters.

Parameters
sMessageconst std::string&
Returns
void

Definition at line 178 of file logger.cpp.

References ensure_open(), and m_logFile.

Referenced by Script::evaluateInstallInformation(), Script::getNextScriptCommandFromScript(), DetachedLogger::open(), DetachedLogger::push_info(), Script::startInstallation(), Script::writeLayout(), Script::writeProcedure(), and Script::writeWholeFile().

Here is the call graph for this function:

Member Data Documentation

◆ m_logFile

std::ofstream Logger::m_logFile
private

Definition at line 35 of file logger.hpp.

Referenced by close(), ensure_open(), is_open(), open(), push(), and push_line().

◆ m_sLogFile

std::string Logger::m_sLogFile
private

Definition at line 36 of file logger.hpp.

Referenced by ensure_open(), and open().


The documentation for this class was generated from the following files: