Skip to content

Commit

Permalink
translating the prefix in warnings and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Dec 5, 2023
1 parent d71e419 commit 5b18ece
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/utils/common/MsgHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ bool MsgHandler::myWriteDebugMessages = false;
bool MsgHandler::myWriteDebugGLMessages = false;
bool MsgHandler::myWriteTimestamps = false;
bool MsgHandler::myWriteProcessId = false;
std::string MsgHandler::myErrorPrefix = "Error: ";
std::string MsgHandler::myWarningPrefix = "Warning: ";


// ===========================================================================
Expand Down Expand Up @@ -305,6 +307,8 @@ MsgHandler::setupI18n(const std::string& locale) {
#else
UNUSED_PARAMETER(locale);
#endif
myWarningPrefix = TL("Warning: ");
myErrorPrefix = TL("Error: ");
}


Expand Down
32 changes: 22 additions & 10 deletions src/utils/common/MsgHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ class MsgHandler {
case MsgType::MT_MESSAGE:
break;
case MsgType::MT_WARNING:
prefix += "Warning: ";
prefix += myWarningPrefix;
break;
case MsgType::MT_ERROR:
prefix += "Error: ";
prefix += myErrorPrefix;
break;
case MsgType::MT_DEBUG:
prefix += "Debug: ";
Expand Down Expand Up @@ -259,21 +259,33 @@ class MsgHandler {
/// @brief storage for initial messages
std::vector<std::string> myInitialMessages;

private:
/// @brief invalid copy constructor
MsgHandler(const MsgHandler& s) = delete;

/// @brief invalid assignment operator
MsgHandler& operator=(const MsgHandler& s) = delete;

/** @brief Flag to enable or disable debug GL Functions
/** @brief Flag to enable or disable debug output
*
* This value is used to show more internal information through warning messages about certain operations
*/
static bool myWriteDebugMessages;

/// @brief Flag to enable or disable GL specific debug output
static bool myWriteDebugGLMessages;

/// @brief Whether to prefix every message with a time stamp
static bool myWriteTimestamps;

/// @brief Whether to prefix every message with the process id
static bool myWriteProcessId;

/// @brief The possibly translated error prefix (mainly for speedup)
static std::string myErrorPrefix;

/// @brief The possibly translated warning prefix (mainly for speedup)
static std::string myWarningPrefix;

private:
/// @brief invalid copy constructor
MsgHandler(const MsgHandler& s) = delete;

/// @brief invalid assignment operator
MsgHandler& operator=(const MsgHandler& s) = delete;
};


Expand Down

0 comments on commit 5b18ece

Please sign in to comment.