DamBreak++ Wave Simulator 0.3
DamBreak++ Simulation Framework
Loading...
Searching...
No Matches
Sfx::Logger Class Reference

Class to output a message log file. Singleton base class manage the creation/deletion of the logger. That the instance function returns a pointer to a static variable and thus is declared static. Only the class function Instance can call the constructor. Public access to the constructor is denied. The constructor, copy constructor and assignment operator are all private to ensure that the programmer using the singleton class can only create a single instance of the class using only the Instance() function. The life of the singleton instantiation is for the duration of the application. More...

#include <Sfx_Logger.h>

Inheritance diagram for Sfx::Logger:

Public Types

enum class  eOpeningMode { fstream = 0 , FILE = 1 }
 Opening file mode. More...

Public Member Functions

bool Init ()
 Initiates log. Don't call, it is in the constructor.
bool Shutdown ()
 Shuts down log, in the destructor.
void OutputNewline ()
 outpout newline to log file
void OutputError (char *text,...)
 outpout error message to log file
void OutputSuccess (char *text,...)
 outpout success message to log file
void write2File (const std::string aMessage)
 writing log event to file
eOpeningMode getOpeningMode ()
void setOpeningMode (const eOpeningMode aOpenMode)
 Open file for writing result of the simulation.
bool openLogFile (std::string logFile)
 Open file for writing result of the simulation.
void writeToLogFile (const std::string aStr)
 Write to log file.
bool closeLogFile ()
 Close file.

Protected Member Functions

 Logger ()
 Default ctor.
 ~Logger ()
 Destructor.
 Logger (const Logger &aOther)=delete
 prevent copy and assignment
Loggeroperator= (const Logger &aOther)=delete
 prevent assignment
void close ()
 close file if opened

Protected Attributes

FILEm_logfile
bool m_opened
eOpeningMode m_openMode
std::string m_fileName
std::filesystem::path m_filePath
std::ofstream m_fStream
char m_logFileNAME [256]

Friends

class Singleton< Logger >
 make friend to access protected and private

Detailed Description

Class to output a message log file. Singleton base class manage the creation/deletion of the logger. That the instance function returns a pointer to a static variable and thus is declared static. Only the class function Instance can call the constructor. Public access to the constructor is denied. The constructor, copy constructor and assignment operator are all private to ensure that the programmer using the singleton class can only create a single instance of the class using only the Instance() function. The life of the singleton instantiation is for the duration of the application.

Member Enumeration Documentation

◆ eOpeningMode

enum class Sfx::Logger::eOpeningMode
strong

Opening file mode.

Enumerator
fstream 
FILE 

Constructor & Destructor Documentation

◆ Logger() [1/2]

Sfx::Logger::Logger ( )
protected

Default ctor.

◆ ~Logger()

Sfx::Logger::~Logger ( )
protected

Destructor.

◆ Logger() [2/2]

Sfx::Logger::Logger ( const Logger & aOther)
protecteddelete

prevent copy and assignment

Parameters
aOtherobject to copy from

Member Function Documentation

◆ close()

void Sfx::Logger::close ( )
protected

close file if opened

◆ closeLogFile()

bool Sfx::Logger::closeLogFile ( )

Close file.

Returns
true/false

◆ getOpeningMode()

eOpeningMode Sfx::Logger::getOpeningMode ( )
inline

◆ Init()

bool Sfx::Logger::Init ( )

Initiates log. Don't call, it is in the constructor.

Returns

◆ openLogFile()

bool Sfx::Logger::openLogFile ( std::string logFile)

Open file for writing result of the simulation.

Parameters
logFilefile name
Returns
true/false on success

◆ operator=()

Logger & Sfx::Logger::operator= ( const Logger & aOther)
protecteddelete

prevent assignment

Parameters
aOtherobject to assign from
Returns
this

◆ OutputError()

void Sfx::Logger::OutputError ( char * text,
... )

outpout error message to log file

Parameters
text

◆ OutputNewline()

void Sfx::Logger::OutputNewline ( )

outpout newline to log file

◆ OutputSuccess()

void Sfx::Logger::OutputSuccess ( char * text,
... )

outpout success message to log file

Parameters
text

◆ setOpeningMode()

void Sfx::Logger::setOpeningMode ( const eOpeningMode aOpenMode)
inline

Open file for writing result of the simulation.

Parameters
aOpenMode

◆ Shutdown()

bool Sfx::Logger::Shutdown ( )

Shuts down log, in the destructor.

Returns

◆ write2File()

void Sfx::Logger::write2File ( const std::string aMessage)

writing log event to file

Parameters
aMessage

◆ writeToLogFile()

void Sfx::Logger::writeToLogFile ( const std::string aStr)

Write to log file.

Parameters
aStrmessage to write

◆ Singleton< Logger >

friend class Singleton< Logger >
friend

make friend to access protected and private

Member Data Documentation

◆ m_fileName

std::string Sfx::Logger::m_fileName
protected

file name

◆ m_filePath

std::filesystem::path Sfx::Logger::m_filePath
protected

file path

◆ m_fStream

std::ofstream Sfx::Logger::m_fStream
protected

file stream

◆ m_logfile

FILE* Sfx::Logger::m_logfile
protected

file handle

◆ m_logFileNAME

char Sfx::Logger::m_logFileNAME[256]
protected

log file name

◆ m_opened

bool Sfx::Logger::m_opened
protected

flag

◆ m_openMode

eOpeningMode Sfx::Logger::m_openMode
protected

open mode


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