Adding new dependency: libzmq (ZeroMQ). Adding a new debug logging class powered by sockets and ZeroMQ, to allow a threadsafe way to communicate debug messages to a client application (i.e. openshot-qt). Also, removing unneeded Sleep.h functions. There will be lots more code utilizing ZeroMQ soon.

This commit is contained in:
Jonathan Thomas
2016-04-04 23:09:18 -05:00
parent 6d2d342719
commit 723bd24e5c
22 changed files with 322 additions and 207 deletions

View File

@@ -63,21 +63,6 @@ ReaderBase::ReaderBase()
debug = false;
}
// Output debug information as JSON
string ReaderBase::OutputDebugJSON()
{
// Return formatted string
return debug_root.toStyledString();
}
// Append debug information as JSON
void ReaderBase::AppendDebugItem(Json::Value debug_item)
{
// Append item to root array
debug_root.append(debug_item);
}
// Append debug information as JSON
void ReaderBase::AppendDebugMethod(string method_name, string arg1_name, float arg1_value,
string arg2_name, float arg2_value,
@@ -90,46 +75,37 @@ void ReaderBase::AppendDebugMethod(string method_name, string arg1_name, float a
// Don't do anything
return;
Json::Value debug_item;
debug_item["method"] = method_name;
// Output to standard output
#pragma omp critical (debug_output)
{
cout << fixed << setprecision(4);
cout << "Debug: Method: " << method_name << " (";
stringstream message;
message << fixed << setprecision(4);
message << method_name << " (";
// Add attributes to method JSON
if (arg1_name.length() > 0) {
debug_item[arg1_name] = arg1_value;
cout << arg1_name << "=" << arg1_value;
}
if (arg2_name.length() > 0) {
debug_item[arg2_name] = arg2_value;
cout << ", " << arg2_name << "=" << arg2_value;
}
if (arg3_name.length() > 0) {
debug_item[arg3_name] = arg3_value;
cout << ", " << arg3_name << "=" << arg3_value;
}
if (arg4_name.length() > 0) {
debug_item[arg4_name] = arg4_value;
cout << ", " << arg4_name << "=" << arg4_value;
}
if (arg5_name.length() > 0) {
debug_item[arg5_name] = arg5_value;
cout << ", " << arg5_name << "=" << arg5_value;
}
if (arg6_name.length() > 0) {
debug_item[arg6_name] = arg6_value;
cout << ", " << arg6_name << "=" << arg6_value;
}
if (arg1_name.length() > 0)
message << arg1_name << "=" << arg1_value;
if (arg2_name.length() > 0)
message << ", " << arg2_name << "=" << arg2_value;
if (arg3_name.length() > 0)
message << ", " << arg3_name << "=" << arg3_value;
if (arg4_name.length() > 0)
message << ", " << arg4_name << "=" << arg4_value;
if (arg5_name.length() > 0)
message << ", " << arg5_name << "=" << arg5_value;
if (arg6_name.length() > 0)
message << ", " << arg6_name << "=" << arg6_value;
// Output to standard output
cout << ")" << endl;
message << ")" << endl;
// Append method to root array
debug_root.append(debug_item);
// Send message through ZMQ
ZmqLogger::Instance()->Log(message.str());
}
}