13 #ifndef ML_ERROR_OUTPUT_H
14 #define ML_ERROR_OUTPUT_H
27 ML_UTILS_START_NAMESPACE
32 ML_UTILS_END_NAMESPACE
55 ML_UTILS_START_NAMESPACE
60 class ErrorOutputInfos;
378 const std::string &libraryPrefix,
379 const std::string &fPrefix,
380 const std::string &functionName,
381 const std::string &reason,
382 const std::string &handling =
"",
383 const std::string &file =
"",
385 const void *dumpObj =
nullptr,
393 const std::string &libraryPrefix,
394 const std::string &fPrefix,
395 const std::string &functionName,
397 const std::string &handling =
"",
398 const std::string &file =
"",
400 const void *dumpObj =
nullptr,
415 const std::string &libraryPrefix,
416 std::stringstream &reason,
432 const std::string &libraryPrefix,
443 friend class ML_NAMESPACE::State;
454 friend std::ostream& std::operator<<(std::ostream& s,
const ErrorOutput &errorOutput);
460 void _printConsole(
const std::string &errStr,
const ErrorOutputInfos &infos)
const;
465 std::string getTraceDump()
const;
470 std::streambuf *_defaultCoutBuffer;
475 std::streambuf *_defaultCerrBuffer;
489 bool _isFullDebuggingOn;
537 std::vector<void*> _errorUserDataList;
540 std::vector<ErrorOutputCB*> _errorOutputCBList;
543 std::vector<std::string> _debugEnvStrings;
552 bool _outputMessagesInVisualStudio;
560 ML_UTILS_END_NAMESPACE
Struct that contains all information about errors, fatal errors, warnings, information,...
Class to handle all ML debug prints, errors, warnings, and information.
void sendMessagesToCout(bool on)
If on is passed as true, the sending of a message to std::cout is enabled.
size_t getNumOutputCBs() const
Returns the number of registered callbacks.
void init()
Only to force access to instances of this class to make the objects automatically initialize during D...
ErrorOutput(const ErrorOutput &errorOutput)
Copy constructor, only to be used by state class of the ML.
void destroy()
Destroys global settings; to be called during ML or mlUtils destruction; not to be called by applicat...
void setFullDebuggingOn(bool on)
Enables/disables full debugging by passing true or false as on.
MLTerminator getTerminationType(MLMessageType level) const
Returns the way how the ML shall handle messages.
bool hasErrorOutputCB(void *userData, ErrorOutputCB *callback) const
Returns true if the output function is registered, i.e., if both parameters are identical with their ...
MLuint32 getTraceDumpMessageBits() const
Returns the bit mask describing all message types that shall lead to a trace list and trace stack dum...
void removeAllErrorOutputCBs()
Removes all registered error print functions from the list.
ErrorOutput()
Constructor.
void setOutputMessagesInVisualStudio(bool flag)
Sets whether messages should be printed in Visual Studio (turned on by default in debug mode).
~ErrorOutput()
Destructor.
void addDebugEnvName(const std::string &envName)
Adds a debug environment string whose information shall be printed.
void setMaxNumTraceListDumps(MLGlobalTraceBufferType num)
Sets the maximum number of trace list entries to be shown on fatal error outputs.
bool areMessagesSentToCout() const
Messages are only sent to std::cout if this flag is true.
bool areMessagesSentToCerr() const
Messages are only sent to std::cerr if this flag is true.
void sendMessagesToCerr(bool on)
If on is passed as true, the sending of a message to std::cerr is enabled.
void setDumpCB(DumpCB *dumpCB)
Registers a dump function dumpCB that will be called by the ML to dump object structures,...
ErrorOutput & operator=(const ErrorOutput &errorOutput)
Assignment operator, only to be used by state class of the ML.
void removeDebugEnvName(const std::string &envName)
Removes a registered debug environment string whose information shall not be printed anymore.
size_t getNumDebugEnvNames() const
Returns the number of registered debug environment names.
void setTerminationType(MLMessageType level, MLTerminator term)
Sets the way how the ML shall handle a specific message type, note that ML_ALL_MESSAGES is not a vali...
void addErrorOutputCB(void *userData, ErrorOutputCB *callback)
Registers a function called when any message is sent MLErrorOutput.
bool hasDebugEnvName(const std::string &envName) const
Returns true if the debug environment name exists.
void setMessageFilter(MLuint32 messageType)
Sets messages to be handled by MLErrorOutput as set bits in messageType.
bool shouldOutputMessagesInVisualStudio() const
Returns wheter messages should be printed in Visual Studio.
MLuint32 getMaxNumTraceStackDumps() const
Returns the maximum number of trace stack entries to be shown on fatal error outputs.
void removeErrorOutputCB(void *userData, ErrorOutputCB *callback)
Removes an error-print function from the function list if both parameters are identical with their co...
void ErrorOutputCB(void *usrData, const char *errStr, const ErrorOutputInfos &infos)
Function type that can be passed to the ErrorOutput class.
void removeAllDebugEnvNames()
Removes all registered debug environment strings from list.
MLuint32 getMessageFilter()
Returns the bit mask specifying the message filter that is composed from binary OR'd MLMessageTypes e...
void setMaxNumTraceStackDumps(MLGlobalTraceBufferType num)
Sets the maximum number of trace stack entries to be shown on fatal error outputs.
void setTraceDumpMessageBits(MLuint32 bitMask)
Sets the bit mask describing all message types that shall lead to a trace list and trace stack dump.
const std::vector< std::string > & getDebugEnvNames() const
Returns a list of debug environment names.
DumpCB * getDumpCB() const
Returns the currently registered dump callback. Default is NULL.
MLuint32 getMaxNumTraceListDumps() const
Returns the maximum number of trace list entries to be shown on fatal error outputs.
char * DumpCB(const void *dumpObj, const RuntimeType *dumpObjRT)
Definition of a callback type that can be registered at the ML C-API.
void reset()
Resets instance to construction state.
bool isFullDebuggingOn() const
Returns true if full debugging is enabled; otherwise, it returns false.
RuntimeType contains type and inheritance information of a class and a static dictionary with informa...
MLint32 MLErrorCode
Type of an ML Error code.
#define ML_RESULT_OK
No error. Everything seems to be okay.
void printAndNotify(MLMessageType messageType, const std::string &libraryPrefix, const std::string &fPrefix, const std::string &functionName, const std::string &reason, const std::string &handling="", const std::string &file="", int line=-1, const void *dumpObj=nullptr, const RuntimeType *dumpObjRT=nullptr, MLErrorCode errCode=ML_RESULT_OK) const
Core error printing function used by all other functions.
boost::recursive_mutex RecursiveMutex
Defines a recursive mutex.
void handleDebugPrint(const std::string &envVar, const std::string &libraryPrefix, const char *reason, const char *file, int line) const
Function called from mlDebugPrint.
void handleDebugPrint(const std::string &envVar, const std::string &libraryPrefix, std::stringstream &reason, const char *file, int line) const
Function called from mlDebugPrint.
void printAndNotify(MLMessageType messageType, const std::string &libraryPrefix, const std::string &fPrefix, const std::string &functionName, MLErrorCode reason, const std::string &handling="", const std::string &file="", int line=-1, const void *dumpObj=nullptr, const RuntimeType *dumpObjRT=nullptr) const
Similar to the other printAndNotify() function with the difference that reason is an MLErrorCode that...
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator '<<' for stream output of Field objects.
MLTerminator
Termination types for error handling.
MLMessageType
Message types handled by the ErrorOutput class.
MLCSO_EXPORT void level(CSO *cso)
Determines the normal and the center of gravity of the given CSO.
ML_UTILS_EXPORT ErrorOutput MLErrorOutput
This is a singleton used for all ML Error input and output;.
MLuint16 MLGlobalTraceBufferType
The type used in the MLGlobalTraceBuffer.