ProgressLogger class to be notified of some process' progress.
More...
#include <ProgressLogger.h>
|
| ProgressLogger (bool detailedProgress=false, double updateDelay=kDefaultUpdateDelay) |
|
virtual void | setStepCount (int stepCount) |
|
virtual void | setDetailedProgress (bool detailedProgress) |
|
bool | getDetailedProgress () const |
|
virtual bool | logNewStep (const string &stepName, size_t progress=0, size_t maxProgress=100) |
|
bool | logProgress (const string &stepName, size_t progress=0, size_t maxProgress=100) |
|
bool | logProgress (const string &stepName, int64_t progress, int64_t maxProgress) |
|
virtual bool | logStatus (const string &stepName, int status=0) |
|
virtual bool | logDuration (const string &operationName, double duration, int precision=1) |
|
|
static constexpr double | kDefaultUpdateDelay = 2 |
|
|
virtual bool | logProgress (const string &stepName, size_t progress, size_t maxProgress, bool newStep) |
|
virtual void | logMessage (const string &message) |
|
virtual void | logErrorMessage (const string &message) |
|
virtual void | updateStep (size_t progress=0, size_t maxProgress=100) |
|
virtual void | updateNextProgressTime () |
| Callback to schedule the time of the next text update.
|
|
virtual bool | shouldKeepGoing () |
|
|
bool | detailedProgress_ |
|
double | updateDelay_ |
|
int | stepNumber_ |
|
int | stepCount_ |
|
double | nextProgressTime_ |
|
ProgressLogger class to be notified of some process' progress.
Helper class to implement status logging when opening a VRS file By default, logs to use XR_LOGI and XR_LOGE, but can be easily overwritten to log anywhere. By default, this class never requests to stop the operation, but that can be overridden.
◆ ProgressLogger()
vrs::ProgressLogger::ProgressLogger |
( |
bool |
detailedProgress = false , |
|
|
double |
updateDelay = kDefaultUpdateDelay |
|
) |
| |
|
explicit |
By default, only logs every 2 seconds, and after 2 seconds, so opening from a file will be silent, unless a slow re-indexing operation is required.
- Parameters
-
detailedProgress | pass true to log every new step, regardless of timing. |
updateDelay | time in seconds between updates. |
◆ getDetailedProgress()
bool vrs::ProgressLogger::getDetailedProgress |
( |
| ) |
const |
|
inline |
Get if progress details logging is enabled.
- Returns
- True if progress details logging is enabled.
◆ logDuration()
bool vrs::ProgressLogger::logDuration |
( |
const string & |
operationName, |
|
|
double |
duration, |
|
|
int |
precision = 1 |
|
) |
| |
|
virtual |
Log that an operation was performed in a specific duration.
- Parameters
-
operationName | text describing the operation. |
duration | number of seconds the operation lasted. |
precision | precision to use when printing the duration. |
- Returns
- True if the operation should continue, false if it should be cancelled.
Reimplemented in vrs::SilentLogger.
◆ logErrorMessage()
void vrs::ProgressLogger::logErrorMessage |
( |
const string & |
message | ) |
|
|
protectedvirtual |
Log an error message. This is called when some text needs to actually be logged after all the filtering logic has been applied.
- Parameters
-
message | the error text message to log. |
◆ logMessage()
void vrs::ProgressLogger::logMessage |
( |
const string & |
message | ) |
|
|
protectedvirtual |
Log an actual message. This is called when some text needs to actually be logged after all the filtering logic has been applied.
- Parameters
-
message | the text message to log. |
◆ logNewStep()
bool vrs::ProgressLogger::logNewStep |
( |
const string & |
stepName, |
|
|
size_t |
progress = 0 , |
|
|
size_t |
maxProgress = 100 |
|
) |
| |
|
virtual |
Start logging a new step.
- Parameters
-
stepName | the name of the step. |
progress | the current progress in the step. |
maxProgress | the max value of the progress counter in the step. |
- Returns
- True if the operation should continue, false if it should be cancelled.
◆ logProgress() [1/3]
bool vrs::ProgressLogger::logProgress |
( |
const string & |
stepName, |
|
|
int64_t |
progress, |
|
|
int64_t |
maxProgress |
|
) |
| |
|
inline |
Convenience method for when a status is signed. Note that values are expected to be positive anyways!
◆ logProgress() [2/3]
bool vrs::ProgressLogger::logProgress |
( |
const string & |
stepName, |
|
|
size_t |
progress, |
|
|
size_t |
maxProgress, |
|
|
bool |
newStep |
|
) |
| |
|
protectedvirtual |
- Parameters
-
stepName | the name of the step. |
progress | the current progress in the step. |
maxProgress | the max value of the progress counter in the step. |
newStep | tells if the step is a new step (for internal use). |
- Returns
- True if the operation should continue, false if it should be cancelled.
Reimplemented in vrs::SilentLogger.
◆ logProgress() [3/3]
bool vrs::ProgressLogger::logProgress |
( |
const string & |
stepName, |
|
|
size_t |
progress = 0 , |
|
|
size_t |
maxProgress = 100 |
|
) |
| |
|
inline |
Log progress of a step that has an internal progress counter. logNewStep() should always be called first.
- Parameters
-
stepName | the name of the step. |
progress | the current progress in the step. |
maxProgress | the max value of the progress counter in the step. |
- Returns
- True if the operation should continue, false if it should be cancelled.
◆ logStatus()
bool vrs::ProgressLogger::logStatus |
( |
const string & |
stepName, |
|
|
int |
status = 0 |
|
) |
| |
|
virtual |
Log that a step is completed, with a specific status.
- Parameters
-
stepName | the name of the step. |
status | 0 on success, otherwise, the step is considered failed. |
- Returns
- True if the operation should continue, false if it should be cancelled.
Reimplemented in vrs::SilentLogger.
◆ setDetailedProgress()
void vrs::ProgressLogger::setDetailedProgress |
( |
bool |
detailedProgress | ) |
|
|
virtual |
Force logging at every step.
- Parameters
-
detailedProgress | true if logging should be done of every new step. |
◆ setStepCount()
void vrs::ProgressLogger::setStepCount |
( |
int |
stepCount | ) |
|
|
virtual |
Set the number of steps anticipated, if expecting more than one step. The step counter is incremented each time a new step is logged.
- Parameters
-
stepCount | total number of steps anticipated. |
◆ shouldKeepGoing()
bool vrs::ProgressLogger::shouldKeepGoing |
( |
| ) |
|
|
protectedvirtual |
Callback to tell if the operation should stop or keep going. Override this method to check if the operation should be cancelled, and probably cache the result.
- Returns
- True if the operation should continue, false if it should be cancelled.
◆ updateStep()
void vrs::ProgressLogger::updateStep |
( |
size_t |
progress = 0 , |
|
|
size_t |
maxProgress = 100 |
|
) |
| |
|
protectedvirtual |
Callback to update the current step's progress, for instance, when displaying a progress bar.
- Parameters
-
progress | the current progress in the step. |
maxProgress | the max value of the progress counter in the step. |
The documentation for this class was generated from the following files: