Ember
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
LogFile Class Reference

Write logging information either to a file or to stdout if no output file has been specified. More...

#include <debugUtils.h>

Public Member Functions

 LogFile ()
 Create a logger that writes to stdout.
 
 LogFile (const std::string &filename)
 Create a logger that writes to the file named filename.
 
 ~LogFile ()
 
void open (const std::string &filename)
 Direct any further output to the file named filename.
 
void close ()
 Close the current log file, directing any further output to stdout.
 
template<class T >
void write (const T &other, bool newline=true)
 Write the value of other to the current log destination.
 
template<class T >
void verboseWrite (const T &message, bool newline=true)
 Write the value of message to the current log destination only if the flag debugParameters::veryVerbose is set.
 

Private Attributes

bool haveFile
 
std::ofstream file
 

Detailed Description

Write logging information either to a file or to stdout if no output file has been specified.

Usually accessed through the global instance logFile.

Constructor & Destructor Documentation

◆ LogFile() [1/2]

LogFile::LogFile ( )

Create a logger that writes to stdout.

◆ LogFile() [2/2]

LogFile::LogFile ( const std::string &  filename)
explicit

Create a logger that writes to the file named filename.

An existing file with the same name will be replaced.

◆ ~LogFile()

LogFile::~LogFile ( )

Member Function Documentation

◆ open()

void LogFile::open ( const std::string &  filename)

Direct any further output to the file named filename.

◆ close()

void LogFile::close ( )

Close the current log file, directing any further output to stdout.

◆ write()

template<class T >
void LogFile::write ( const T &  other,
bool  newline = true 
)
inline

Write the value of other to the current log destination.

Templated so that any object that overloads operator<< for std::ostream will be appropriately formatted.

◆ verboseWrite()

template<class T >
void LogFile::verboseWrite ( const T &  message,
bool  newline = true 
)
inline

Write the value of message to the current log destination only if the flag debugParameters::veryVerbose is set.

Member Data Documentation

◆ haveFile

bool LogFile::haveFile
private

◆ file

std::ofstream LogFile::file
private

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