summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands/CommandObjectLog.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2017-02-17 13:27:42 +0000
committerPavel Labath <labath@google.com>2017-02-17 13:27:42 +0000
commitfb0d22d6454a9b55e6c9219c5e06646c9707889a (patch)
tree46add8c31f16f9e9c2c4f397e17d7fbbc1df56c7 /lldb/source/Commands/CommandObjectLog.cpp
parent38699dbac5b69f8f71718abaecd7bb96f2170f8e (diff)
downloadbcm5719-llvm-fb0d22d6454a9b55e6c9219c5e06646c9707889a.tar.gz
bcm5719-llvm-fb0d22d6454a9b55e6c9219c5e06646c9707889a.zip
Reapply "Refactor log channel registration mechanism"
Changes wrt. previous version: - add #include <atomic>: fix build on windows - add extra {} around the string literals used to initialize llvm::StringLiteral: fix gcc build llvm-svn: 295442
Diffstat (limited to 'lldb/source/Commands/CommandObjectLog.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectLog.cpp44
1 files changed, 10 insertions, 34 deletions
diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp
index 6fbab08ac63..c10f868dea4 100644
--- a/lldb/source/Commands/CommandObjectLog.cpp
+++ b/lldb/source/Commands/CommandObjectLog.cpp
@@ -227,25 +227,15 @@ protected:
return false;
}
- Log::Callbacks log_callbacks;
-
const std::string channel = args[0].ref;
args.Shift(); // Shift off the channel
- if (Log::GetLogChannelCallbacks(ConstString(channel), log_callbacks)) {
- log_callbacks.disable(args.GetConstArgumentVector(),
- &result.GetErrorStream());
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- } else if (channel == "all") {
+ if (channel == "all") {
Log::DisableAllLogChannels(&result.GetErrorStream());
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
} else {
- LogChannelSP log_channel_sp(LogChannel::FindPlugin(channel.data()));
- if (log_channel_sp) {
- log_channel_sp->Disable(args.GetConstArgumentVector(),
- &result.GetErrorStream());
+ if (Log::DisableLogChannel(channel, args.GetConstArgumentVector(),
+ result.GetErrorStream()))
result.SetStatus(eReturnStatusSuccessFinishNoResult);
- } else
- result.AppendErrorWithFormat("Invalid log channel '%s'.\n",
- channel.data());
}
return result.Succeeded();
}
@@ -284,26 +274,12 @@ protected:
Log::ListAllLogChannels(&result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
- for (auto &entry : args.entries()) {
- Log::Callbacks log_callbacks;
-
- if (Log::GetLogChannelCallbacks(ConstString(entry.ref),
- log_callbacks)) {
- log_callbacks.list_categories(&result.GetOutputStream());
- result.SetStatus(eReturnStatusSuccessFinishResult);
- } else if (entry.ref == "all") {
- Log::ListAllLogChannels(&result.GetOutputStream());
- result.SetStatus(eReturnStatusSuccessFinishResult);
- } else {
- LogChannelSP log_channel_sp(LogChannel::FindPlugin(entry.c_str()));
- if (log_channel_sp) {
- log_channel_sp->ListCategories(&result.GetOutputStream());
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- } else
- result.AppendErrorWithFormat("Invalid log channel '%s'.\n",
- entry.c_str());
- }
- }
+ bool success = true;
+ for (const auto &entry : args.entries())
+ success = success && Log::ListChannelCategories(
+ entry.ref, result.GetOutputStream());
+ if (success)
+ result.SetStatus(eReturnStatusSuccessFinishResult);
}
return result.Succeeded();
}
OpenPOWER on IntegriCloud