Add the ability to disable individual log categories, rather
than just the entire log channel.
Add checks, where appropriate, to make sure a log channel/category has
not been disabled before attempting to write to it.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@117715 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectLog.cpp b/source/Commands/CommandObjectLog.cpp
index 56630c9..f814dd2 100644
--- a/source/Commands/CommandObjectLog.cpp
+++ b/source/Commands/CommandObjectLog.cpp
@@ -291,31 +291,29 @@
}
else
{
- for (size_t i=0; i<argc; ++i)
- {
- Log::Callbacks log_callbacks;
+ Log::Callbacks log_callbacks;
- std::string channel(args.GetArgumentAtIndex(i));
- if (Log::GetLogChannelCallbacks (channel.c_str(), log_callbacks))
+ std::string channel(args.GetArgumentAtIndex(0));
+ args.Shift (); // Shift off the channel
+ if (Log::GetLogChannelCallbacks (channel.c_str(), log_callbacks))
+ {
+ log_callbacks.disable (args, &result.GetErrorStream());
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ }
+ else if (channel == "all")
+ {
+ Log::DisableAllLogChannels(&result.GetErrorStream());
+ }
+ else
+ {
+ LogChannelSP log_channel_sp (GetLogChannelPluginForChannel(channel.c_str()));
+ if (log_channel_sp)
{
- log_callbacks.disable ();
+ log_channel_sp->Disable(args, &result.GetErrorStream());
result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
- else if (channel == "all")
- {
- Log::DisableAllLogChannels();
- }
else
- {
- LogChannelSP log_channel_sp (GetLogChannelPluginForChannel(channel.c_str()));
- if (log_channel_sp)
- {
- log_channel_sp->Disable();
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- }
- else
- result.AppendErrorWithFormat("Invalid log channel '%s'.\n", args.GetArgumentAtIndex(0));
- }
+ result.AppendErrorWithFormat("Invalid log channel '%s'.\n", args.GetArgumentAtIndex(0));
}
}
return result.Succeeded();