summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorCallum Prentice <callum@lindenlab.com>2021-03-09 14:39:51 -0800
committerCallum Prentice <callum@lindenlab.com>2021-03-09 14:39:51 -0800
commit168d177197bd7558bbe0ca13d01c984ad8638da7 (patch)
tree60b01576041b1d1e336fef9c4944570c2c4dfcc4 /indra/llcommon
parent519cbcecdf78e4dfc3adc465ae8cebed5df71647 (diff)
This set of changes reverts the merge with master (git revert c83e740) and results in a version of the DRTVWR-519 that matches what was presemt before it was deployed as a release viewer *plus* 3 small fixes from Maxim (See commits). This branch can now be used for additional fixes before eventually being used to release D-519 as normal
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llerror.cpp61
1 files changed, 51 insertions, 10 deletions
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp
index f876b8ee4a..6e8b9efaf7 100644
--- a/indra/llcommon/llerror.cpp
+++ b/indra/llcommon/llerror.cpp
@@ -194,23 +194,64 @@ namespace {
{
return LLError::getEnabledLogTypesMask() & 0x04;
}
-
+
+ LL_FORCE_INLINE std::string createBoldANSI()
+ {
+ std::string ansi_code;
+ ansi_code += '\033';
+ ansi_code += "[";
+ ansi_code += "1";
+ ansi_code += "m";
+
+ return ansi_code;
+ }
+
+ LL_FORCE_INLINE std::string createResetANSI()
+ {
+ std::string ansi_code;
+ ansi_code += '\033';
+ ansi_code += "[";
+ ansi_code += "0";
+ ansi_code += "m";
+
+ return ansi_code;
+ }
+
LL_FORCE_INLINE std::string createANSI(const std::string& color)
{
std::string ansi_code;
- ansi_code += '\033';
- ansi_code += "[";
- ansi_code += color;
+ ansi_code += '\033';
+ ansi_code += "[";
+ ansi_code += "38;5;";
+ ansi_code += color;
ansi_code += "m";
+
return ansi_code;
}
virtual void recordMessage(LLError::ELevel level,
const std::string& message) override
{
- static std::string s_ansi_error = createANSI("31"); // red
- static std::string s_ansi_warn = createANSI("34"); // blue
- static std::string s_ansi_debug = createANSI("35"); // magenta
+ // The default colors for error, warn and debug are now a bit more pastel
+ // and easier to read on the default (black) terminal background but you
+ // now have the option to set the color of each via an environment variables:
+ // LL_ANSI_ERROR_COLOR_CODE (default is red)
+ // LL_ANSI_WARN_COLOR_CODE (default is blue)
+ // LL_ANSI_DEBUG_COLOR_CODE (default is magenta)
+ // The list of color codes can be found in many places but I used this page:
+ // https://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html#256-colors
+ // (Note: you may need to restart Visual Studio to pick environment changes)
+ char* val = nullptr;
+ std::string s_ansi_error_code = "160";
+ if ((val = getenv("LL_ANSI_ERROR_COLOR_CODE")) != nullptr) s_ansi_error_code = std::string(val);
+ std::string s_ansi_warn_code = "33";
+ if ((val = getenv("LL_ANSI_WARN_COLOR_CODE")) != nullptr) s_ansi_warn_code = std::string(val);
+ std::string s_ansi_debug_code = "177";
+ if ((val = getenv("LL_ANSI_DEBUG_COLOR_CODE")) != nullptr) s_ansi_debug_code = std::string(val);
+
+ static std::string s_ansi_error = createANSI(s_ansi_error_code); // default is red
+ static std::string s_ansi_warn = createANSI(s_ansi_warn_code); // default is blue
+ static std::string s_ansi_debug = createANSI(s_ansi_debug_code); // default is magenta
if (mUseANSI)
{
@@ -229,11 +270,11 @@ namespace {
LL_FORCE_INLINE void writeANSI(const std::string& ansi_code, const std::string& message)
{
- static std::string s_ansi_bold = createANSI("1"); // bold
- static std::string s_ansi_reset = createANSI("0"); // reset
+ static std::string s_ansi_bold = createBoldANSI(); // bold text
+ static std::string s_ansi_reset = createResetANSI(); // reset
// ANSI color code escape sequence, message, and reset in one fprintf call
// Default all message levels to bold so we can distinguish our own messages from those dumped by subprocesses and libraries.
- fprintf(stderr, "%s%s%s\n%s", s_ansi_bold.c_str(), ansi_code.c_str(), message.c_str(), s_ansi_reset.c_str() );
+ fprintf(stderr, "%s%s\n%s", ansi_code.c_str(), message.c_str(), s_ansi_reset.c_str() );
}
static bool checkANSI(void)