General: Toggle to log outgoing response and events

This commit is contained in:
Brendan Hagan 2017-07-04 13:41:20 -04:00
parent b57982b6cb
commit 7675a1ee58
3 changed files with 24 additions and 7 deletions

View File

@ -20,6 +20,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <util/platform.h>
#include <QTimer>
#include <QPushButton>
#include "Config.h"
#include "Utils.h"
#include "WSEvents.h"
#include "obs-websocket.h"
@ -213,9 +214,15 @@ void WSEvents::broadcastUpdate(const char* updateType, obs_data_t* additionalFie
if (additionalFields != NULL)
obs_data_apply(update, additionalFields);
_srv->broadcast(obs_data_get_json(update));
const char *json = obs_data_get_json(update);
obs_data_release(update);
if (Config::Current()->DebugEnabled)
{
blog(LOG_DEBUG, "Update << '%s'", json);
}
_srv->broadcast(json);
}
void WSEvents::connectTransitionSignals(obs_source_t* transition)

View File

@ -117,7 +117,7 @@ void WSRequestHandler::processIncomingMessage(QString textMessage)
if (Config::Current()->DebugEnabled)
{
blog(LOG_INFO, ">> '%s'", msg);
blog(LOG_DEBUG, "Request >> '%s'", msg);
}
if (!hasField("request-type") ||
@ -161,9 +161,7 @@ void WSRequestHandler::SendOKResponse(obs_data_t* additionalFields)
if (additionalFields)
obs_data_apply(response, additionalFields);
_client->sendTextMessage(obs_data_get_json(response));
obs_data_release(response);
SendResponse(response);
}
void WSRequestHandler::SendErrorResponse(const char* errorMessage)
@ -173,9 +171,20 @@ void WSRequestHandler::SendErrorResponse(const char* errorMessage)
obs_data_set_string(response, "error", errorMessage);
obs_data_set_string(response, "message-id", _messageId);
_client->sendTextMessage(obs_data_get_json(response));
SendResponse(response);
}
void WSRequestHandler::SendResponse(obs_data_t* response)
{
const char *json = obs_data_get_json(response);
obs_data_release(response);
if (Config::Current()->DebugEnabled)
{
blog(LOG_DEBUG, "Response << '%s'", json);
}
_client->sendTextMessage(json);
}
bool WSRequestHandler::hasField(const char* name)

View File

@ -45,6 +45,7 @@ class WSRequestHandler : public QObject
void SendOKResponse(obs_data_t* additionalFields = NULL);
void SendErrorResponse(const char* errorMessage);
void SendResponse(obs_data_t* response);
static void HandleGetVersion(WSRequestHandler* req);
static void HandleGetAuthRequired(WSRequestHandler* req);