108 static void setupI18n(
const std::string& locale =
"");
117 virtual void inform(std::string msg,
bool addType =
true);
121 template<
typename T,
typename... Targs>
122 void informf(
const std::string& format, T value, Targs... Fargs) {
144 virtual void clear(
bool resetInformed =
true);
176 inline std::string
build(
const std::string& msg,
bool addType) {
198 prefix +=
"GLDebug: ";
295#define WRITE_WARNING(msg) MsgHandler::getWarningInstance()->inform(msg);
296#define WRITE_WARNINGF(...) MsgHandler::getWarningInstance()->informf(__VA_ARGS__);
297#define WRITE_MESSAGE(msg) MsgHandler::getMessageInstance()->inform(msg);
298#define WRITE_MESSAGEF(...) MsgHandler::getMessageInstance()->informf(__VA_ARGS__);
299#define PROGRESS_BEGIN_MESSAGE(msg) MsgHandler::getMessageInstance()->beginProcessMsg((msg) + std::string(" ..."));
300#define PROGRESS_DONE_MESSAGE() MsgHandler::getMessageInstance()->endProcessMsg2(true);
301#define PROGRESS_BEGIN_TIME_MESSAGE(msg) SysUtils::getCurrentMillis(); MsgHandler::getMessageInstance()->beginProcessMsg((msg) + std::string(" ..."));
302#define PROGRESS_TIME_MESSAGE(before) MsgHandler::getMessageInstance()->endProcessMsg2(true, SysUtils::getCurrentMillis() - before);
303#define PROGRESS_FAILED_MESSAGE() MsgHandler::getMessageInstance()->endProcessMsg2(false);
304#define WRITE_ERROR(msg) MsgHandler::getErrorInstance()->inform(msg);
305#define WRITE_ERRORF(...) MsgHandler::getErrorInstance()->informf(__VA_ARGS__);
306#define WRITE_DEBUG(msg) if(MsgHandler::writeDebugMessages()){MsgHandler::getDebugInstance()->inform(msg);};
307#define WRITE_GLDEBUG(msg) if(MsgHandler::writeDebugGLMessages()){MsgHandler::getGLDebugInstance()->inform(msg);};
310#define TL(string) gettext(string)
312#define TLF(string, ...) StringUtils::format(gettext(string), __VA_ARGS__)
315#define TL(string) (string)
317#define TLF(string, ...) StringUtils::format(string, __VA_ARGS__)
virtual void addRetriever(OutputDevice *retriever)
Adds a further retriever to the instance responsible for a certain msg type.
std::vector< std::string > myInitialMessages
storage for initial messages
static MsgHandler * getGLDebugInstance()
Returns the instance to add GLdebug to.
bool wasInformed() const
Returns the information whether any messages were added.
MsgType myType
The type of the instance.
std::string buildProcessIdPrefix(void) const
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
std::string buildTimestampPrefix(void) const
static void enableDebugGLMessages(bool enable)
enable/disable gl-debug messages
static MsgHandler * myGLDebugInstance
The instance to handle glDebug.
MsgHandler & operator=(const MsgHandler &s)=delete
invalid assignment operator
static std::string insertLineBreaks(std::string msg, int lineWidth)
reformats a long string to contain newline after a certain line length in px (depending on the curren...
virtual void endProcessMsg(std::string msg)
Ends a process information.
std::string build(const std::string &msg, bool addType)
Builds the string which includes the mml-message type.
virtual bool aggregationThresholdReached(const std::string &format)
static Factory myFactory
The function to call for new MsgHandlers, nullptr means use default constructor.
bool myWasInformed
information whether an output occurred at all
static bool myWriteTimestamps
Whether to prefix every message with a time stamp.
static void setupI18n(const std::string &locale="")
set up gettext stuff
static void initOutputOptions()
init output options
static MsgHandler * myErrorInstance
The instance to handle errors.
static MsgHandler * getDebugInstance()
Returns the instance to add debug to.
static MsgHandler * myMessageInstance
The instance to handle normal messages.
static bool writeDebugGLMessages()
check whether to enable/disable gl-debug messages
bool isRetriever(OutputDevice *retriever) const
Returns whether the given output device retrieves messages from the handler.
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
static void setFactory(Factory func)
Sets the factory function to use for new MsgHandlers.
std::map< const std::string, int > myAggregationCount
count for messages of the same type
static void enableDebugMessages(bool enable)
enable/disable debug messages
static bool myAmProcessingProcess
Information whether a process information is printed to cout.
std::vector< OutputDevice * > myRetrievers
The list of retrievers that shall be informed about new messages or errors.
MsgHandler(const MsgHandler &s)=delete
invalid copy constructor
MsgHandler *(* Factory)(MsgType)
virtual ~MsgHandler()
destructor
virtual void clear(bool resetInformed=true)
Clears information whether an error occurred previously and print aggregated message summary.
static MsgHandler * myDebugInstance
The instance to handle debug.
void setAggregationThreshold(const int thresh)
static bool writeDebugMessages()
check whether to enable/disable debug messages
MsgHandler & operator<<(const T &t)
Generic output operator.
static MsgHandler * myWarningInstance
The instance to handle warnings.
virtual void endProcessMsg2(bool success, long duration=-1)
Ends a process information with predefined messages.
virtual void beginProcessMsg(std::string msg, bool addType=true)
Begins a process information.
static bool myWriteDebugMessages
Flag to enable or disable debug output.
static bool myWriteDebugGLMessages
Flag to enable or disable GL specific debug output.
static std::string myWarningPrefix
The possibly translated warning prefix (mainly for speedup)
void informf(const std::string &format, T value, Targs... Fargs)
adds a new formatted message
static bool myWriteProcessId
Whether to prefix every message with the process id.
static void cleanupOnEnd()
Removes pending handler.
static std::string myErrorPrefix
The possibly translated error prefix (mainly for speedup)
static void removeRetrieverFromAllInstances(OutputDevice *out)
ensure that that given output device is no longer used as retriever by any instance
virtual void removeRetriever(OutputDevice *retriever)
Removes the retriever from the handler.
int myAggregationThreshold
do not output more messages of the same type if the count exceeds this threshold
@ MT_GLDEBUG
The message is GL debug output.
@ MT_DEBUG
The message is debug output.
@ MT_MESSAGE
The message is only something to show.
@ MT_ERROR
The message is an error.
@ MT_WARNING
The message is a warning.
static MsgHandler * getMessageInstance()
Returns the instance to add normal messages to.
Static storage of an output device and its base (abstract) implementation.
static const std::string format(const std::string &format, T value, Targs... Fargs)
adds a new formatted message