Visual Computing Library
Loading...
Searching...
No Matches
vcl::Logger< Stream > Class Template Referenceabstract
Inheritance diagram for vcl::Logger< Stream >:

Public Member Functions

void enableIndentation () override final
 
void disableIndentation () override final
 
void enablePrintPercentage () override final
 
void disablePrintPercentage () override final
 
void setPrintLevel (LogLevel level) override final
 Sets the maximum print level of the logger.
 
void enablePrintMessageDuringProgress () override final
 
void disablePrintMessageDuringProgress () override final
 
void enablePrintTimer () override final
 
void disablePrintTimer () override final
 
void reset () override final
 
void setMaxLineWidth (uint w) override final
 
void startTimer () override final
 
void stopTimer () override final
 
double time () const override final
 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.
 
void startNewTask (double fromPerc, double toPerc, const std::string &action) override final
 
void endTask (const std::string &action) override final
 
double percentage () const override final
 
virtual void setPercentage (uint newPerc) override
 
void log (const std::string &msg) const override final
 Prints a message to the logger, with level LogLevel::PROGRESS and without modifying the current percentage.
 
void log (const std::string &msg, LogLevel lvl) const override final
 Prints a message to the logger, with the given level and without modifying the current percentage.
 
void log (uint perc, const std::string &msg) override final
 Prints a message to the logger, with the level LogLevel::PROGRESS and with the given percentage.
 
void log (uint perc, const std::string &msg, LogLevel lvl) override final
 Prints a message to the logger, with the given level and with the given percentage.
 
void startProgress (const std::string &msg, uint progressSize, uint percPrintProgress=10, uint startPerc=0, uint endPerc=100) override final
 Allows to easily manage progresses with the logger, along with the progress and endProgress member functions.
 
void endProgress () override final
 Allows to easily manage progresses with the logger, along with the startProgress and progress member functions.
 
void progress (uint n) override final
 Allows to easily manage progresses with the logger, along with the startProgress and endProgress member functions.
 

Protected Member Functions

virtual StreamlevelStream (LogLevel lvl) const =0
 Returns the stream corresponding to the given LogLevel.
 
virtual void alignLeft (Stream &o) const
 
virtual void alignRight (Stream &o) const
 
virtual void setWidth (Stream &o, uint w) const
 
virtual void flush (Stream &o) const
 

Private Types

enum  InternalLogLevel { START = DEBUG_LOG + 1 , END }
 

Private Member Functions

void updateStep ()
 
void printLine (const std::string &msg, uint lvl) const
 
uint printPercentage (Stream &o) const
 
uint printIndentation (Stream &o) const
 
void printMessage (Stream &o, const std::string &msg, uint lvl, uint n) const
 
void printElapsedTime (Stream &o) const
 

Private Attributes

uint mPercPrecision = 0
 
std::stack< std::pair< double, double > > mIntervals
 
double mGlobalPercProgress = 0
 
double mStep = 1
 
uint mLineWidth = 80
 
Timer mTimer
 
std::string mProgressMessage
 
LogLevel mPrintLevel = PROGRESS_LOG
 
uint mProgressStep
 
uint mProgressPerc
 
uint mProgressPercStep
 
uint mProgressSize
 
uint mLastProgress
 
bool mIsProgressActive = false
 
bool mPrintPerc = true
 
bool mPrintMsgDuringProgress = true
 
bool mIndent = true
 
bool mPrintTimer = false
 
std::mutex mMutex
 

Static Private Attributes

static const uint TIMER_MAX_CHAR_NUMBER = 12
 

Additional Inherited Members

- Public Types inherited from vcl::AbstractLogger
enum  LogLevel {
  ERROR_LOG = 0 , WARNING_LOG , MESSAGE_LOG , PROGRESS_LOG ,
  DEBUG_LOG
}
 

Member Function Documentation

◆ disableIndentation()

template<typename Stream >
void vcl::Logger< Stream >::disableIndentation ( )
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ disablePrintMessageDuringProgress()

template<typename Stream >
void vcl::Logger< Stream >::disablePrintMessageDuringProgress ( )
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ disablePrintPercentage()

template<typename Stream >
void vcl::Logger< Stream >::disablePrintPercentage ( )
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ disablePrintTimer()

template<typename Stream >
void vcl::Logger< Stream >::disablePrintTimer ( )
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ enableIndentation()

template<typename Stream >
void vcl::Logger< Stream >::enableIndentation ( )
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ enablePrintMessageDuringProgress()

template<typename Stream >
void vcl::Logger< Stream >::enablePrintMessageDuringProgress ( )
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ enablePrintPercentage()

template<typename Stream >
void vcl::Logger< Stream >::enablePrintPercentage ( )
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ enablePrintTimer()

template<typename Stream >
void vcl::Logger< Stream >::enablePrintTimer ( )
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ endProgress()

template<typename Stream >
void vcl::Logger< Stream >::endProgress ( )
inlinefinaloverridevirtual

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();
void log(const std::string &msg) const override final
Prints a message to the logger, with level LogLevel::PROGRESS and without modifying the current perce...
Definition logger.h:168
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43

Implements vcl::AbstractLogger.

◆ endTask()

template<typename Stream >
void vcl::Logger< Stream >::endTask ( const std::string &  action)
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ levelStream()

template<typename Stream >
virtual Stream * vcl::Logger< Stream >::levelStream ( LogLevel  lvl) const
protectedpure virtual

Returns the stream corresponding to the given LogLevel.

It should be implemented by the derived classes.

Parameters
[in]lvlthe LogLevel for which the stream is requested.
Returns
the stream corresponding to the given LogLevel.

Implemented in vcl::qt::TextEditLogger.

◆ log() [1/4]

template<typename Stream >
void vcl::Logger< Stream >::log ( const std::string &  msg) const
inlinefinaloverridevirtual

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

Parameters
[in]msgThe message to print.

Implements vcl::AbstractLogger.

◆ log() [2/4]

template<typename Stream >
void vcl::Logger< Stream >::log ( const std::string &  msg,
LogLevel  lvl 
) const
inlinefinaloverridevirtual

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.

Implements vcl::AbstractLogger.

◆ log() [3/4]

template<typename Stream >
void vcl::Logger< Stream >::log ( uint  perc,
const std::string &  msg 
)
inlinefinaloverridevirtual

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.

Implements vcl::AbstractLogger.

◆ log() [4/4]

template<typename Stream >
void vcl::Logger< Stream >::log ( uint  perc,
const std::string &  msg,
LogLevel  lvl 
)
inlinefinaloverridevirtual

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.

Implements vcl::AbstractLogger.

◆ percentage()

template<typename Stream >
double vcl::Logger< Stream >::percentage ( ) const
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ progress()

template<typename Stream >
void vcl::Logger< Stream >::progress ( uint  n)
inlinefinaloverridevirtual

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.

Implements vcl::AbstractLogger.

◆ reset()

template<typename Stream >
void vcl::Logger< Stream >::reset ( )
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ setMaxLineWidth()

template<typename Stream >
void vcl::Logger< Stream >::setMaxLineWidth ( uint  w)
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ setPercentage()

template<typename Stream >
virtual void vcl::Logger< Stream >::setPercentage ( uint  newPerc)
inlineoverridevirtual

Implements vcl::AbstractLogger.

◆ setPrintLevel()

template<typename Stream >
void vcl::Logger< Stream >::setPrintLevel ( LogLevel  level)
inlinefinaloverridevirtual

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.

Implements vcl::AbstractLogger.

◆ startNewTask()

template<typename Stream >
void vcl::Logger< Stream >::startNewTask ( double  fromPerc,
double  toPerc,
const std::string &  action 
)
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ startProgress()

template<typename Stream >
void vcl::Logger< Stream >::startProgress ( const std::string &  msg,
uint  progressSize,
uint  percPrintProgress = 10,
uint  startPerc = 0,
uint  endPerc = 100 
)
inlinefinaloverridevirtual

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%

Implements vcl::AbstractLogger.

◆ startTimer()

template<typename Stream >
void vcl::Logger< Stream >::startTimer ( )
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ stopTimer()

template<typename Stream >
void vcl::Logger< Stream >::stopTimer ( )
inlinefinaloverridevirtual

Implements vcl::AbstractLogger.

◆ time()

template<typename Stream >
double vcl::Logger< Stream >::time ( ) const
inlinefinaloverridevirtual

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.

Implements vcl::AbstractLogger.


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