Remove lldb streams from the Log class completely
Summary:
previously we switched to llvm streams for log output, this completes
the switch for the error streams.
I also clean up the includes and remove the unused argument from
DisableAllLogChannels().
This required adding a bit of boiler plate to convert the output in the
command interpreter, but that should go away when we switch command
results to use llvm streams as well.
Reviewers: zturner, eugene
Subscribers: lldb-commits, emaste
Differential Revision: https://reviews.llvm.org/D30894
llvm-svn: 297812
diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp
index 0b6762f..0355a53 100644
--- a/lldb/source/Commands/CommandObjectLog.cpp
+++ b/lldb/source/Commands/CommandObjectLog.cpp
@@ -170,9 +170,14 @@
m_options.log_file.GetPath(log_file, sizeof(log_file));
else
log_file[0] = '\0';
+
+ std::string error;
+ llvm::raw_string_ostream error_stream(error);
bool success = m_interpreter.GetDebugger().EnableLog(
channel, args.GetArgumentArrayRef(), log_file, m_options.log_options,
- result.GetErrorStream());
+ error_stream);
+ result.GetErrorStream() << error_stream.str();
+
if (success)
result.SetStatus(eReturnStatusSuccessFinishNoResult);
else
@@ -229,12 +234,15 @@
const std::string channel = args[0].ref;
args.Shift(); // Shift off the channel
if (channel == "all") {
- Log::DisableAllLogChannels(&result.GetErrorStream());
+ Log::DisableAllLogChannels();
result.SetStatus(eReturnStatusSuccessFinishNoResult);
} else {
+ std::string error;
+ llvm::raw_string_ostream error_stream(error);
if (Log::DisableLogChannel(channel, args.GetArgumentArrayRef(),
- result.GetErrorStream()))
+ error_stream))
result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ result.GetErrorStream() << error_stream.str();
}
return result.Succeeded();
}
@@ -269,17 +277,20 @@
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
+ std::string output;
+ llvm::raw_string_ostream output_stream(output);
if (args.empty()) {
- Log::ListAllLogChannels(&result.GetOutputStream());
+ Log::ListAllLogChannels(output_stream);
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
bool success = true;
for (const auto &entry : args.entries())
- success = success && Log::ListChannelCategories(
- entry.ref, result.GetOutputStream());
+ success =
+ success && Log::ListChannelCategories(entry.ref, output_stream);
if (success)
result.SetStatus(eReturnStatusSuccessFinishResult);
}
+ result.GetOutputStream() << output_stream.str();
return result.Succeeded();
}
};