Update RPCParser for new log routines

This commit is contained in:
Vinnie Falco
2013-05-22 14:34:50 -07:00
parent cda1431e5b
commit 4c485ac5ce

View File

@@ -32,8 +32,6 @@
#include "CallRPC.h" #include "CallRPC.h"
SETUP_LOG();
static inline bool isSwitchChar(char c) static inline bool isSwitchChar(char c)
{ {
#ifdef __WXMSW__ #ifdef __WXMSW__
@@ -332,8 +330,8 @@ Json::Value RPCParser::parseJson(const Json::Value& jvParams)
Json::Reader reader; Json::Reader reader;
Json::Value jvRequest; Json::Value jvRequest;
cLog(lsTRACE) << "RPC method: " << jvParams[0u]; WriteLog (lsTRACE, RPCParser) << "RPC method: " << jvParams[0u];
cLog(lsTRACE) << "RPC json: " << jvParams[1u]; WriteLog (lsTRACE, RPCParser) << "RPC json: " << jvParams[1u];
if (reader.parse(jvParams[1u].asString(), jvRequest)) if (reader.parse(jvParams[1u].asString(), jvRequest))
{ {
@@ -533,7 +531,7 @@ Json::Value RPCParser::parseRipplePathFind(const Json::Value& jvParams)
Json::Value jvRequest; Json::Value jvRequest;
bool bLedger = 2 == jvParams.size(); bool bLedger = 2 == jvParams.size();
cLog(lsTRACE) << "RPC json: " << jvParams[0u]; WriteLog (lsTRACE, RPCParser) << "RPC json: " << jvParams[0u];
if (reader.parse(jvParams[0u].asString(), jvRequest)) if (reader.parse(jvParams[0u].asString(), jvRequest))
{ {
@@ -719,8 +717,8 @@ Json::Value RPCParser::parseWalletSeed(const Json::Value& jvParams)
// <-- { method: xyz, params: [... ] } or { error: ..., ... } // <-- { method: xyz, params: [... ] } or { error: ..., ... }
Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams) Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams)
{ {
cLog(lsTRACE) << "RPC method:" << strMethod; WriteLog (lsTRACE, RPCParser) << "RPC method:" << strMethod;
cLog(lsTRACE) << "RPC params:" << jvParams; WriteLog (lsTRACE, RPCParser) << "RPC params:" << jvParams;
static struct { static struct {
const char* pCommand; const char* pCommand;
@@ -811,7 +809,7 @@ Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams)
else if ((commandsA[i].iMinParams >= 0 && jvParams.size() < commandsA[i].iMinParams) else if ((commandsA[i].iMinParams >= 0 && jvParams.size() < commandsA[i].iMinParams)
|| (commandsA[i].iMaxParams >= 0 && jvParams.size() > commandsA[i].iMaxParams)) || (commandsA[i].iMaxParams >= 0 && jvParams.size() > commandsA[i].iMaxParams))
{ {
cLog(lsWARNING) << "Wrong number of parameters: minimum=" << commandsA[i].iMinParams WriteLog (lsWARNING, RPCParser) << "Wrong number of parameters: minimum=" << commandsA[i].iMinParams
<< " maximum=" << commandsA[i].iMaxParams << " maximum=" << commandsA[i].iMaxParams
<< " actual=" << jvParams.size(); << " actual=" << jvParams.size();
@@ -850,7 +848,7 @@ int commandLineRPC(const std::vector<std::string>& vCmd)
jvRequest = rpParser.parseCommand(vCmd[0], jvRpcParams); jvRequest = rpParser.parseCommand(vCmd[0], jvRpcParams);
cLog(lsTRACE) << "RPC Request: " << jvRequest << std::endl; WriteLog (lsTRACE, RPCParser) << "RPC Request: " << jvRequest << std::endl;
if (jvRequest.isMember("error")) if (jvRequest.isMember("error"))
{ {
@@ -960,7 +958,7 @@ bool responseRPC(
throw std::runtime_error("no response from server"); throw std::runtime_error("no response from server");
// Parse reply // Parse reply
cLog(lsDEBUG) << "RPC reply: " << strData << std::endl; WriteLog (lsDEBUG, RPCParser) << "RPC reply: " << strData << std::endl;
Json::Reader reader; Json::Reader reader;
Json::Value jvReply; Json::Value jvReply;
@@ -986,7 +984,7 @@ void requestRPC(const std::string& strMethod, const Json::Value& jvParams,
const std::map<std::string, std::string>& mHeaders, const std::string& strPath, const std::map<std::string, std::string>& mHeaders, const std::string& strPath,
boost::asio::streambuf& sb, const std::string& strHost) boost::asio::streambuf& sb, const std::string& strHost)
{ {
cLog(lsDEBUG) << "requestRPC: strPath='" << strPath << "'"; WriteLog (lsDEBUG, RPCParser) << "requestRPC: strPath='" << strPath << "'";
std::ostream osRequest(&sb); std::ostream osRequest(&sb);
@@ -1024,7 +1022,7 @@ void callRPC(
// Send request // Send request
// Log(lsDEBUG) << "requesting" << std::endl; // Log(lsDEBUG) << "requesting" << std::endl;
// cLog(lsDEBUG) << "send request " << strMethod << " : " << strRequest << std::endl; // WriteLog (lsDEBUG, RPCParser) << "send request " << strMethod << " : " << strRequest << std::endl;
HttpsClient::httpsRequest( HttpsClient::httpsRequest(
bSSL, bSSL,