AQUAgpusph 4.1.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions
Aqua::InputOutput::Logger Class Reference

On screen and log file output manager. More...

#include <Logger.h>

Inheritance diagram for Aqua::InputOutput::Logger:
Inheritance graph
[legend]
Collaboration diagram for Aqua::InputOutput::Logger:
Collaboration graph
[legend]

Public Member Functions

 Logger ()
 Constructor.
 
 ~Logger ()
 Destructor.
 
void initNCurses ()
 Transform the terminal into an ncurses one.
 
void endNCurses ()
 Transform the terminal into an ncurses one.
 
void initFrame ()
 Call to setup a new terminal frame.
 
void endFrame ()
 Call to refresh the terminal frame.
 
void writeReport (std::string msg, std::string color="white", bool bold=false)
 Write a new message in the terminal output.
 
void addMessage (TLogLevel level, std::string log, std::string func="")
 Add a new log record message.
 
void printDate (TLogLevel level=L_DEBUG)
 Print a time stamp in the screen and the log file.
 
void printOpenCLError (cl_int error, TLogLevel level=L_DEBUG)
 Print an OpenCL error.
 
void save (float t)
 Do nothing.
 
- Public Member Functions inherited from Aqua::InputOutput::Report
virtual void save (float t)=0
 Save the data.
 
virtual void load ()
 Load the data.
 
std::string file ()
 Get the used output file path.
 
virtual void save (float t)=0
 Save the data.
 
virtual void load ()=0
 Load the data.
 

Protected Member Functions

void printLog ()
 Print the log record.
 
void refreshAll ()
 
void open ()
 Create the log file.
 
void close ()
 Close the log file.
 
- Protected Member Functions inherited from Aqua::Singleton< Aqua::InputOutput::Logger >
 Singleton ()
 Constructor.
 
virtual ~Singleton ()
 Destructor.
 
- Protected Member Functions inherited from Aqua::InputOutput::Report
 Report ()
 Constructor.
 
virtual ~Report ()
 Destructor.
 
void file (std::string filename)
 Set the report file name.
 
void file (std::string basename, unsigned int start_index)
 Look for the first non-existing file name.
 
- Protected Member Functions inherited from Aqua::InputOutput::InputOutput
 InputOutput ()
 Constructor.
 
virtual ~InputOutput ()
 Destructor.
 

Additional Inherited Members

- Static Public Member Functions inherited from Aqua::Singleton< Aqua::InputOutput::Logger >
static Aqua::InputOutput::Loggersingleton ()
 Returns the instance of the class.
 

Detailed Description

On screen and log file output manager.

AQUAgpusph is generating, during runtime, an HTML log file, placed in the execution folder, and named log.X.html, where X is replaced by the first unsigned integer which generates a non-existing file.

Constructor & Destructor Documentation

◆ Logger()

Aqua::InputOutput::Logger::Logger ( )

Constructor.

Here is the call graph for this function:

◆ ~Logger()

Aqua::InputOutput::Logger::~Logger ( )

Destructor.

Here is the call graph for this function:

Member Function Documentation

◆ addMessage()

void Aqua::InputOutput::Logger::addMessage ( TLogLevel  level,
std::string  log,
std::string  func = "" 
)

Add a new log record message.

The old messages may be removed from the terminal if no more space left.

Parameters
levelMessage classification (L_DEBUG, L_INFO, L_WARNING, L_ERROR)
logLog message.
funcFunction name to print, NULL if it should not be printed.
Note
In order to append the class and the method name before the message use addMessageF instead of this one.
Here is the call graph for this function:

◆ close()

void Aqua::InputOutput::Logger::close ( )
protected

Close the log file.

◆ endFrame()

void Aqua::InputOutput::Logger::endFrame ( )

Call to refresh the terminal frame.

This method should be called at the end of every time step.

Here is the call graph for this function:

◆ endNCurses()

void Aqua::InputOutput::Logger::endNCurses ( )

Transform the terminal into an ncurses one.

This method should be called after finishing the simulation main loop

◆ initFrame()

void Aqua::InputOutput::Logger::initFrame ( )

Call to setup a new terminal frame.

This method should be called at the start of every time step.

◆ initNCurses()

void Aqua::InputOutput::Logger::initNCurses ( )

Transform the terminal into an ncurses one.

This method should be called ONCE before starting the simulation main loop

◆ open()

void Aqua::InputOutput::Logger::open ( )
protected

Create the log file.

Here is the call graph for this function:

◆ printDate()

void Aqua::InputOutput::Logger::printDate ( TLogLevel  level = L_DEBUG)

Print a time stamp in the screen and the log file.

Parameters
levelMessage classification (L_DEBUG, L_INFO, L_WARNING, L_ERROR)
Here is the call graph for this function:

◆ printLog()

void Aqua::InputOutput::Logger::printLog ( )
protected

Print the log record.

This function will compute automatically where the log record should be placed

◆ printOpenCLError()

void Aqua::InputOutput::Logger::printOpenCLError ( cl_int  error,
TLogLevel  level = L_DEBUG 
)

Print an OpenCL error.

Parameters
errorError code returned by OpenCL.
levelMessage classification (L_DEBUG, L_INFO, L_WARNING, L_ERROR)
Here is the call graph for this function:

◆ refreshAll()

void Aqua::InputOutput::Logger::refreshAll ( )
protected

Call to refresh the output screen, useless if ncurses is not active.

◆ save()

void Aqua::InputOutput::Logger::save ( float  t)
inlinevirtual

Do nothing.

Parameters
tSimulation time

Implements Aqua::InputOutput::Report.

◆ writeReport()

void Aqua::InputOutput::Logger::writeReport ( std::string  msg,
std::string  color = "white",
bool  bold = false 
)

Write a new message in the terminal output.

This method is not redirecting the data to the log file. In case that ncurses is active:

  • Tabulators '\t' are interpreted as 1 blank space
  • Line breaks '\n' are intepreted as line breaks
  • It is fitting the message replacing spaces by lines break Otherwise:
  • stdout will be used
  • A line break '\n' is appended if it is not detected at the end
Parameters
msgMessage to print in the screen.
colorColor name. Valid colors are:
  1. white
  2. green
  3. blue
  4. yellow
  5. red
  6. magenta
  7. cyan
boldtrue if bold font should be used, false otherwise
Here is the call graph for this function:

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