Commit 641ab130 authored by Dominik Charousset's avatar Dominik Charousset

Fix out-of-range error; allow restoring verbosity

By returning the previous verbosity level from the setter, we allow
users to restore the log level with a scope guard when changing the
verbosity level for a limited scope.
parent c91ace23
......@@ -334,8 +334,8 @@ public:
set_live();
format_to(colored(),
"{0:{1}}$R(error): check failed\n"
"{0:{1}} loc: $C({3}):$Y({4})$0\n"
"{0:{1}} check: {5}\n",
"{0:{1}} loc: $C({2}):$Y({3})$0\n"
"{0:{1}} check: {4}\n",
' ', indent_, location.file_name(), location.line(), arg);
}
......@@ -388,8 +388,10 @@ public:
' ', indent_, location.file_name(), location.line(), msg);
}
void verbosity(unsigned level) override {
unsigned verbosity(unsigned level) override {
auto result = level_;
level_ = level;
return result;
}
void no_colors(bool new_value) override {
......
......@@ -75,7 +75,8 @@ public:
info(std::string_view msg, const detail::source_location& location)
= 0;
virtual void verbosity(unsigned level) = 0;
/// Sets the verbosity level of the reporter and returns the previous value.
virtual unsigned verbosity(unsigned level) = 0;
/// Sets whether the reporter disables colored output even when writing to a
/// TTY.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment