Visual Computing Library
All Classes Functions Variables Typedefs Enumerations Friends Modules Pages Concepts
vcl::AbstractLogger Class Referenceabstract

The AbstractLogger class is used as common ancestor class for all the logger types in the library. More...

#include <vclib/misc/logger/abstract_logger.h>

Inheritance diagram for vcl::AbstractLogger:

Public Types

enum  LogLevel {
  ERROR_LOG = 0 , WARNING_LOG , MESSAGE_LOG , PROGRESS_LOG ,
  DEBUG_LOG
}
 

Public Member Functions

virtual void enableIndentation ()=0
 
virtual void disableIndentation ()=0
 
virtual void enablePrintPercentage ()=0
 
virtual void disablePrintPercentage ()=0
 
virtual void setPrintLevel (LogLevel level)=0
 Sets the maximum print level of the logger.
 
virtual void enablePrintMessageDuringProgress ()=0
 
virtual void disablePrintMessageDuringProgress ()=0
 
virtual void enablePrintTimer ()=0
 
virtual void disablePrintTimer ()=0
 
virtual void reset ()=0
 
virtual void setMaxLineWidth (uint width)=0
 
virtual void startTimer ()=0
 
virtual void stopTimer ()=0
 
virtual double time () const =0
 Returns the time passed since the last call to startTimer member function, or the time passed between the call to startTimer and the call to stopTimer member functions. The time is expressed in seconds.
 
virtual void startNewTask (double fromPerc, double toPerc, const std::string &action)=0
 
virtual void endTask (const std::string &action)=0
 
virtual double percentage () const =0
 
virtual void setPercentage (uint newPerc)=0
 
virtual void log (const std::string &msg) const =0
 Prints a message to the logger, with level LogLevel::PROGRESS and without modifying the current percentage.
 
virtual void log (const std::string &msg, LogLevel lvl) const =0
 Prints a message to the logger, with the given level and without modifying the current percentage.
 
virtual void log (uint perc, const std::string &msg)=0
 Prints a message to the logger, with the level LogLevel::PROGRESS and with the given percentage.
 
virtual void log (uint perc, const std::string &msg, LogLevel lvl)=0
 Prints a message to the logger, with the given level and with the given percentage.
 
virtual void startProgress (const std::string &msg, uint progressSize, uint percPrintProgress=10, uint startPerc=0, uint endPerc=100)=0
 Allows to easily manage progresses with the logger, along with the progress and endProgress member functions.
 
virtual void endProgress ()=0
 Allows to easily manage progresses with the logger, along with the startProgress and progress member functions.
 
virtual void progress (uint n)=0
 Allows to easily manage progresses with the logger, along with the startProgress and endProgress member functions.
 

Detailed Description

The AbstractLogger class is used as common ancestor class for all the logger types in the library.

Member Function Documentation

◆ endProgress()

virtual void vcl::AbstractLogger::endProgress ( )
pure virtual

Allows to easily manage progresses with the logger, along with the startProgress and progress member functions.

This logger functionality should be used when processing a loop having a fixed size, with regular prints of the progress.

This member function ends the current progress.

The typical usage is the following:

uint s = vec.size();
log.startProgress("Computing...", s);
for (uint i = 0; i < vec.size(); ++i) {
// make computations
log.progress(i); // will print only every 10% of progress
}
log.endProgress();
virtual void log(const std::string &msg) const =0
Prints a message to the logger, with level LogLevel::PROGRESS and without modifying the current perce...
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43

Implemented in vcl::Logger< Stream >, vcl::Logger< QTextStream >, and vcl::NullLogger.

◆ log() [1/4]

virtual void vcl::AbstractLogger::log ( const std::string &  msg) const
pure virtual

Prints a message to the logger, with level LogLevel::PROGRESS and without modifying the current percentage.

Parameters
[in]msgThe message to print.

Implemented in vcl::NullLogger, vcl::Logger< Stream >, and vcl::Logger< QTextStream >.

◆ log() [2/4]

virtual void vcl::AbstractLogger::log ( const std::string &  msg,
LogLevel  lvl 
) const
pure virtual

Prints a message to the logger, with the given level and without modifying the current percentage.

Parameters
[in]msgThe message to print.
[in]lvlThe level of the message.

Implemented in vcl::NullLogger, vcl::Logger< Stream >, and vcl::Logger< QTextStream >.

◆ log() [3/4]

virtual void vcl::AbstractLogger::log ( uint  perc,
const std::string &  msg 
)
pure virtual

Prints a message to the logger, with the level LogLevel::PROGRESS and with the given percentage.

Parameters
[in]percThe percentage of the progress.
[in]msgThe message to print.

Implemented in vcl::Logger< Stream >, vcl::Logger< QTextStream >, and vcl::NullLogger.

◆ log() [4/4]

virtual void vcl::AbstractLogger::log ( uint  perc,
const std::string &  msg,
LogLevel  lvl 
)
pure virtual

Prints a message to the logger, with the given level and with the given percentage.

Parameters
[in]percThe percentage of the progress.
[in]msgThe message to print.
[in]lvlThe level of the message.

Implemented in vcl::Logger< Stream >, vcl::Logger< QTextStream >, and vcl::NullLogger.

◆ progress()

virtual void vcl::AbstractLogger::progress ( uint  n)
pure virtual

Allows to easily manage progresses with the logger, along with the startProgress and endProgress member functions.

This logger functionality should be used when processing a loop having a fixed size, with regular prints of the progress.

This member functions increments the current progress. Only if the current percentage reaches a new step percentage (set in the startProgress member function), a message will be printed by the logger.

The typical usage is the following:

uint s = vec.size();
log.startProgress("Computing...", s);
for (uint i = 0; i < vec.size(); ++i) {
// make computations
log.progress(i); // will print only every 10% of progress
}
log.endProgress();
Parameters
[in]niteration number of the current progress. It must be less than the progressSize argument of the startProgress member function.

Implemented in vcl::Logger< Stream >, vcl::Logger< QTextStream >, and vcl::NullLogger.

◆ setPrintLevel()

virtual void vcl::AbstractLogger::setPrintLevel ( LogLevel  level)
pure virtual

Sets the maximum print level of the logger.

Only messages with a level less or equal to the given level will be printed. For example, if the level is set to LogLevel::MESSAGE, only messages with level LogLevel::ERROR, LogLevel::WARNING and LogLevel::MESSAGE will be printed.

Note
The default level is LogLevel::PROGRESS.
Parameters
[in]levelThe maximum print level of the logger.

Implemented in vcl::Logger< Stream >, vcl::Logger< QTextStream >, and vcl::NullLogger.

◆ startProgress()

virtual void vcl::AbstractLogger::startProgress ( const std::string &  msg,
uint  progressSize,
uint  percPrintProgress = 10,
uint  startPerc = 0,
uint  endPerc = 100 
)
pure virtual

Allows to easily manage progresses with the logger, along with the progress and endProgress member functions.

This logger functionality should be used when processing a loop having a fixed size, with regular prints of the progress.

This member function starts a new progress. With the default arguments, will print a message from 0% to 100%, every 10%.

The typical usage is the following:

log.startProgress("Computing...", vec.size());
for (uint i = 0; i < vec.size(); ++i) {
// make computations
log.progress(i); // will print only every 10% of progress
}
log.endProgress();
Parameters
[in]msgthe message that will be printed during the progress
[in]progressSizethe number of iterations made during the progress
[in]percPrintProgressinterval of percentage on which print a progress message, default 10%
[in]startPercstart percentage of the progress, default 0%
[in]endPercend percentage of the progress, default 100%

Implemented in vcl::NullLogger, vcl::Logger< Stream >, and vcl::Logger< QTextStream >.

◆ time()

virtual double vcl::AbstractLogger::time ( ) const
pure virtual

Returns the time passed since the last call to startTimer member function, or the time passed between the call to startTimer and the call to stopTimer member functions. The time is expressed in seconds.

Returns
The time passed, expressed in seconds.

Implemented in vcl::Logger< Stream >, vcl::Logger< QTextStream >, and vcl::NullLogger.


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