19#include <FMEThirdPartyWarningsDisable.h>
22#include <FMEThirdPartyWarningsRestore.h>
37 typedef bool (*InterruptCheckFunc)(
void *userData);
90 unsigned int * ){
return true; }
108 void logInfo (
const std::string &
func,
const std::string &reason=
"");
257 const std::string &info,
270 bool _autoNewLineTerminate;
273 std::stringstream *_outputStream;
283 bool _useRichTextCodingFlag;
288 bool _updateProgressDuringInterruptChecksFlag;
291 bool _wasInterrupted;
294 std::string _fatalErrorPrefix;
297 std::string _errorPrefix;
300 std::string _warningPrefix;
303 std::string _infoPrefix;
324 double _stopTestTimeIntervalInSeconds;
327 double _checkStatusUpdateTimeIntervalInSeconds;
330 InterruptCheckFunc _checkFunc;
333 void *_checkFuncUserData;
Field without value for notifications.
Configurable logger and progress handler class which can be used as base class for logging,...
double getStatusUpdateTimeIntervalInSeconds() const
Returns the currently set Module::updateProgress() call time interval when status fields are updated.
void setInterruptCheckField(NotifyField *interruptField=nullptr)
Set a NotifyField which shall be checked for button presses which mean interruptions; ignored if null...
virtual bool getInterruptedFlag() const
Returns current state of interruption flag (but does not check for interruption).
void logFullInfo(const std::string &func, const std::string &reason)
Same as logFullFatalError, logFullError, and logFullWarning, but logging only information without err...
std::string getWarningMessagePrefix() const
FormatFlags
Enumerator describing some formatting flags.
void setInfoMessagePrefix(const std::string &msg)
void logInfo(const std::string &func, const std::string &reason="")
Same as logFatalError, logError, and logWarning, but logging only information without error.
bool getRichTextCodingFlag() const
If enabled (the default) then outputs newlines are always converted to hyper/rich text line separator...
void logFullError(const std::string &func, MLErrorCode err, const std::string &reason)
See logFullFatalError() for details.
StringField * getStatusField() const
Return the currently set StringField pointer which is updated on logged messages; default is nullptr.
virtual bool _isStopPressed() const
Checks for interruption with currently set _checkFunc or _interruptCheckField or returns false if not...
void logWarning(const std::string &func, MLErrorCode err, const std::string &reason)
See logFatalError() for details.
void logError(const std::string &func, MLErrorCode err, const std::string &reason)
See logFatalError() for details.
bool hadFatalError() const
Returns true if any fatal error, error, warning or info was logged; can be reset with corresponding s...
void logAnyMessage(std::string msg, unsigned int formatFlags=NoFlags)
Log any string into the console.
static void _updateProgressIndicatorCB(void *userData, const std::string &info, float state)
Static callback version to update a progress indicator about the current import state.
void logFullWarning(const std::string &func, MLErrorCode err, const std::string &reason)
See logFullFatalError() for details.
void setAutoNewLineTermination(bool on)
Enable/disable automatic newline termination of logged messages.
void setErrorMessagePrefix(const std::string &msg)
virtual void updateProgressIndicator(const std::string &, float)
Update a progress indicator which shows the message info and the percentage percState.
void setFatalErrorMessagePrefix(const std::string &msg)
Set/get prefixes for messages.
void logFullFatalError(const std::string &func, MLErrorCode err, const std::string &reason)
Logs a fatal error, an error, warning or information to the defined output stream/console and sends t...
double getCheckTimeIntervalInSeconds() const
Returns the currently set interrupt check time interval.
virtual ~ProgressLogger()
Destructor.
void setHadWarningFlag(bool hadWarningFlag)
void setHadFlags(bool hadFlag)
Sets all had*Flags to hadFlag.
void logFatalError(const std::string &func, MLErrorCode err, const std::string &reason)
Logs a fatal error, an error, warning or information to the defined output stream/console.
std::string getErrorMessagePrefix() const
void setCheckTimeIntervalInSeconds(double checkIntervalInSeconds)
Sets a time interval which is used to avoid that too many interruption checks are performed which usu...
void setStatusUpdateTimeIntervalInSeconds(double checkIntervalInSeconds)
Sets a time interval which is used to avoid that too many Module::updateProgress() calls are performe...
std::string getInfoMessagePrefix() const
InterruptCheckFunc getInterruptCheckFunction() const
Returns the currently set function for interrupt checks.
void setRichTextCodingFlag(bool useRichTextCoding)
See getRichTextCodingFlag() for details.
virtual void setInterruptedFlag(bool wasInterrupted)
Sets current state of interruption flag (but does not check for interruption).
bool getUpdateProgressDuringInterruptChecksFlag() const
If enabled then progress updates are performed on each interrupt check; this is useful to enable the ...
virtual void _updateConsole(bool=true)
Updates the output console if there is any.
std::string getFatalErrorMessagePrefix() const
NotifyField * getInterruptCheckField() const
Return the currently set NotifyField pointer which shall be checked for button presses; default is nu...
virtual bool messageHook(const ProgressLogger &, MLMessageType, const std::string *, const std::string *, MLErrorCode *, const std::string *, unsigned int *)
All logging methods pass their function arguments through this hook which allows to collect all messa...
std::string _doAutoNewLineTerminate(const std::string &msg) const
Helper to terminate msg with newline at end according.
void setWarningMessagePrefix(const std::string &msg)
bool isAutoNewLineTerminationOn() const
Returns enabled/disabled automatic newline termination of logged messages.
virtual bool orToInterruptedFlag(bool wasInterrupted)
Update interruption flag by ORing the passed flag to the internal flag and then returning the flag (b...
virtual bool wasInterrupted()
If the interruption flag is already set then immediately true is returned.
void setHadErrorFlag(bool hadErrorFlag)
void setInterruptCheckFunction(InterruptCheckFunc checkFunc, void *userData)
Set a function which actually does a check for interrupts and its user data.
ProgressLogger(std::stringstream *outputStream=nullptr, NotifyField *intCheckField=nullptr, StringField *statusField=nullptr, bool useRichTextCoding=true)
Default and convenience constructor.
void setHadInfoFlag(bool hadInfoFlag)
void setUpdateProgressDuringInterruptChecksFlag(bool callUpdateProgressDuringInterruptChecks)
See getUpdateProgressDuringInterruptChecksFlag() for details.
static bool isPressedField(NotifyField *fieldToCheck)
Convenience implementation of an interrupt check function if user of this class does not want to impl...
void setStatusField(StringField *statusField)
Set a StringField which always shall be updated with all logged messages; ignored if nullptr.
void * getInterruptCheckFunctionUserData() const
Returns the currently set user data pointer for interrupt checks.
void setHadFatalErrorFlag(bool hadFatalErrorFlag)
Sets the state of the corresponding _had* member; used to clear recent logging states.
Field to encapsulate a string value.
Class to measure precise time intervals.
MLint32 MLErrorCode
Type of an ML Error code.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
MLMessageType
Message types handled by the ErrorOutput class.