[lldb] Print diagnostic prefixes (error, warning) in color
Print diagnostic prefixes (error, warning) in their respective colors when colors are enabled.
This commit is contained in:
parent
12e137ab24
commit
990d0c7109
|
@ -20,7 +20,7 @@ class Debugger;
|
|||
|
||||
class StreamAsynchronousIO : public Stream {
|
||||
public:
|
||||
StreamAsynchronousIO(Debugger &debugger, bool for_stdout);
|
||||
StreamAsynchronousIO(Debugger &debugger, bool for_stdout, bool colors);
|
||||
|
||||
~StreamAsynchronousIO() override;
|
||||
|
||||
|
|
|
@ -1201,11 +1201,11 @@ bool Debugger::PopIOHandler(const IOHandlerSP &pop_reader_sp) {
|
|||
}
|
||||
|
||||
StreamSP Debugger::GetAsyncOutputStream() {
|
||||
return std::make_shared<StreamAsynchronousIO>(*this, true);
|
||||
return std::make_shared<StreamAsynchronousIO>(*this, true, GetUseColor());
|
||||
}
|
||||
|
||||
StreamSP Debugger::GetAsyncErrorStream() {
|
||||
return std::make_shared<StreamAsynchronousIO>(*this, false);
|
||||
return std::make_shared<StreamAsynchronousIO>(*this, false, GetUseColor());
|
||||
}
|
||||
|
||||
size_t Debugger::GetNumDebuggers() {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "lldb/Core/DebuggerEvents.h"
|
||||
#include "llvm/Support/WithColor.h"
|
||||
|
||||
using namespace lldb_private;
|
||||
|
||||
|
@ -56,7 +57,12 @@ llvm::StringRef DiagnosticEventData::GetPrefix() const {
|
|||
}
|
||||
|
||||
void DiagnosticEventData::Dump(Stream *s) const {
|
||||
*s << GetPrefix() << ": " << GetMessage() << '\n';
|
||||
llvm::HighlightColor color = m_type == Type::Warning
|
||||
? llvm::HighlightColor::Warning
|
||||
: llvm::HighlightColor::Error;
|
||||
llvm::WithColor(s->AsRawOstream(), color, llvm::ColorMode::Enable)
|
||||
<< GetPrefix();
|
||||
*s << ": " << GetMessage() << '\n';
|
||||
s->Flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
using namespace lldb;
|
||||
using namespace lldb_private;
|
||||
|
||||
StreamAsynchronousIO::StreamAsynchronousIO(Debugger &debugger, bool for_stdout)
|
||||
: Stream(0, 4, eByteOrderBig), m_debugger(debugger), m_data(),
|
||||
StreamAsynchronousIO::StreamAsynchronousIO(Debugger &debugger, bool for_stdout,
|
||||
bool colors)
|
||||
: Stream(0, 4, eByteOrderBig, colors), m_debugger(debugger), m_data(),
|
||||
m_for_stdout(for_stdout) {}
|
||||
|
||||
StreamAsynchronousIO::~StreamAsynchronousIO() {
|
||||
|
|
Loading…
Reference in New Issue