Add a logging mode that takes a callback and flush'es to that callback.
Also add SB API's to set this callback, and to enable the log channels. llvm-svn: 151018
This commit is contained in:
@@ -43,20 +43,19 @@ ProcessKDPLog::GetLogIfAllCategoriesSet (uint32_t mask)
|
||||
}
|
||||
|
||||
void
|
||||
ProcessKDPLog::DisableLog (Args &args, Stream *feedback_strm)
|
||||
ProcessKDPLog::DisableLog (const char **categories, Stream *feedback_strm)
|
||||
{
|
||||
LogSP log (GetLog ());
|
||||
if (log)
|
||||
{
|
||||
uint32_t flag_bits = 0;
|
||||
|
||||
const size_t argc = args.GetArgumentCount ();
|
||||
if (argc > 0)
|
||||
if (categories[0] != NULL)
|
||||
{
|
||||
flag_bits = log->GetMask().Get();
|
||||
for (size_t i = 0; i < argc; ++i)
|
||||
for (size_t i = 0; categories[i] != NULL; ++i)
|
||||
{
|
||||
const char *arg = args.GetArgumentAtIndex (i);
|
||||
const char *arg = categories[i];
|
||||
|
||||
|
||||
if (::strcasecmp (arg, "all") == 0 ) flag_bits &= ~KDP_LOG_ALL;
|
||||
@@ -92,7 +91,7 @@ ProcessKDPLog::DisableLog (Args &args, Stream *feedback_strm)
|
||||
}
|
||||
|
||||
LogSP
|
||||
ProcessKDPLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, Args &args, Stream *feedback_strm)
|
||||
ProcessKDPLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const char **categories, Stream *feedback_strm)
|
||||
{
|
||||
// Try see if there already is a log - that way we can reuse its settings.
|
||||
// We could reuse the log in toto, but we don't know that the stream is the same.
|
||||
@@ -111,10 +110,9 @@ ProcessKDPLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, Args &a
|
||||
if (log)
|
||||
{
|
||||
bool got_unknown_category = false;
|
||||
const size_t argc = args.GetArgumentCount();
|
||||
for (size_t i=0; i<argc; ++i)
|
||||
for (size_t i=0; categories[i] != NULL; ++i)
|
||||
{
|
||||
const char *arg = args.GetArgumentAtIndex(i);
|
||||
const char *arg = categories[i];
|
||||
|
||||
if (::strcasecmp (arg, "all") == 0 ) flag_bits |= KDP_LOG_ALL;
|
||||
else if (::strcasecmp (arg, "async") == 0 ) flag_bits |= KDP_LOG_ASYNC;
|
||||
|
||||
Reference in New Issue
Block a user