aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2020-06-22 11:32:20 -0600
committerBen Burdette <bburdette@gmail.com>2020-06-22 11:32:20 -0600
commit9d1cb0c5e64db3e34896ac43de978f132860f894 (patch)
treea72fd7c5c59a03ad83bf785d9d35d9ce70a76c3c /src/libutil
parent28b079067f4248c81b8946c459435c7a91dc2971 (diff)
with normaltxt, elide yellow color code instead of canceling it; use normaltxt on plain_string hintfmt
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/fmt.hh9
-rw-r--r--src/libutil/tests/logging.cc5
2 files changed, 10 insertions, 4 deletions
diff --git a/src/libutil/fmt.hh b/src/libutil/fmt.hh
index dc7fe8056..a39de041f 100644
--- a/src/libutil/fmt.hh
+++ b/src/libutil/fmt.hh
@@ -120,6 +120,13 @@ public:
return *this;
}
+ template<class T>
+ hintformat& operator%(const normaltxt<T> &value)
+ {
+ fmt % value.value;
+ return *this;
+ }
+
std::string str() const
{
return fmt.str();
@@ -142,6 +149,6 @@ inline hintformat hintfmt(const std::string & fs, const Args & ... args)
inline hintformat hintfmt(std::string plain_string)
{
// we won't be receiving any args in this case, so just print the original string
- return hintfmt("%s", plain_string);
+ return hintfmt("%s", normaltxt(plain_string));
}
}
diff --git a/src/libutil/tests/logging.cc b/src/libutil/tests/logging.cc
index 31e3de697..6a6fb4ac3 100644
--- a/src/libutil/tests/logging.cc
+++ b/src/libutil/tests/logging.cc
@@ -43,7 +43,7 @@ namespace nix {
logger->logEI(ei);
auto str = testing::internal::GetCapturedStderr();
- ASSERT_STREQ(str.c_str(), "\x1B[31;1merror:\x1B[0m\x1B[34;1m --- TestError --- error-unit-test\x1B[0m\n\x1B[33;1m\x1B[0minitial error\x1B[0m; subsequent error message.\n");
+ ASSERT_STREQ(str.c_str(), "\x1B[31;1merror:\x1B[0m\x1B[34;1m --- TestError --- error-unit-test\x1B[0m\ninitial error; subsequent error message.\n");
}
}
@@ -61,8 +61,7 @@ namespace nix {
logError(e.info());
auto str = testing::internal::GetCapturedStderr();
- ASSERT_STREQ(str.c_str(), "\x1B[31;1merror:\x1B[0m\x1B[34;1m --- SysError --- error-unit-test\x1B[0m\n\x1B[33;1m\x1B[0mstatting file\x1B[0m: \x1B[33;1mBad file descriptor\x1B[0m\n");
-
+ ASSERT_STREQ(str.c_str(), "\x1B[31;1merror:\x1B[0m\x1B[34;1m --- SysError --- error-unit-test\x1B[0m\nstatting file: \x1B[33;1mBad file descriptor\x1B[0m\n");
}
}