-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HPCC-31755 Soapcall LOG multi-line separator #19145
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,40 @@ using roxiemem::OwnedRoxieString; | |
#define CONNECTION "Connection" | ||
|
||
unsigned soapTraceLevel = 1; | ||
static StringBuffer soapSepString; | ||
|
||
void setSoapSepString(const char *_soapSepString) | ||
{ | ||
soapSepString.set(_soapSepString); | ||
} | ||
|
||
static void multiLineAppendReplace(StringBuffer &origStr, StringBuffer &newStr) | ||
{ | ||
if (origStr.isEmpty()) | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we newStr.ensureCapacity(origStr.length()) before starting loop so we dont have to expand it more than once ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if replacement separator was >1 char and existing separator was \n, it would still have to expand more than once. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree preallocate to the original size. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
|
||
newStr.ensureCapacity(origStr.length()); | ||
|
||
const char *cursor = origStr; | ||
while (*cursor) | ||
{ | ||
switch (*cursor) | ||
{ | ||
case '\r': | ||
newStr.append(soapSepString); | ||
if ('\n' == *(cursor+1)) | ||
cursor++; | ||
break; | ||
case '\n': | ||
newStr.append(soapSepString); | ||
break; | ||
default: | ||
newStr.append(*cursor); | ||
break; | ||
} | ||
++cursor; | ||
} | ||
} | ||
|
||
#define WSCBUFFERSIZE 0x10000 | ||
#define MAXWSCTHREADS 50 //Max Web Service Call Threads | ||
|
@@ -1951,10 +1985,18 @@ class CWSCAsyncFor : implements IWSCAsyncFor, public CInterface, public CAsyncFo | |
{ | ||
if (soapTraceLevel > 6 || master->logXML) | ||
{ | ||
if (!contentEncoded) | ||
master->logctx.mCTXLOG("%s: request(%s)", master->wscCallTypeText(), request.str()); | ||
StringBuffer contentStr; | ||
if (contentEncoded) | ||
contentStr.append(", content encoded."); | ||
// Only do translation if soapcall LOG option set and soapSepString defined | ||
if ( (master->logXML) && (soapSepString.length() > 0) ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check: I think the master->logXML test can be deleted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I left it and added comment - so we only do translation if LOG set in SOAPCALL args |
||
{ | ||
StringBuffer request2; | ||
multiLineAppendReplace(request, request2); | ||
master->logctx.CTXLOG("%s: request(%s)%s", master->wscCallTypeText(), request2.str(), contentStr.str()); | ||
} | ||
else | ||
master->logctx.mCTXLOG("%s: request(%s), content encoded.", master->wscCallTypeText(), request.str()); | ||
master->logctx.mCTXLOG("%s: request(%s)%s", master->wscCallTypeText(), request.str(), contentStr.str()); | ||
} | ||
} | ||
|
||
|
@@ -2250,9 +2292,18 @@ class CWSCAsyncFor : implements IWSCAsyncFor, public CInterface, public CAsyncFo | |
if (checkContentDecoding(dbgheader, response, contentEncoding)) | ||
decodeContent(contentEncoding.str(), response); | ||
if (soapTraceLevel > 6 || master->logXML) | ||
master->logctx.mCTXLOG("%s: LEN=%d %sresponse(%s%s)", getWsCallTypeName(master->wscType),response.length(),chunked?"CHUNKED ":"", dbgheader.str(), response.str()); | ||
else if (soapTraceLevel > 8) | ||
master->logctx.mCTXLOG("%s: LEN=%d %sresponse(%s)", getWsCallTypeName(master->wscType),response.length(),chunked?"CHUNKED ":"", response.str()); // not sure this is that useful but... | ||
{ | ||
// Only do translation if soapcall LOG option set and soapSepString defined | ||
if ( (master->logXML) && (soapSepString.length() > 0) ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
{ | ||
StringBuffer response2; | ||
multiLineAppendReplace(dbgheader, response2); | ||
multiLineAppendReplace(response, response2); | ||
master->logctx.CTXLOG("%s: LEN=%d %sresponse(%s)", getWsCallTypeName(master->wscType),response.length(),chunked?"CHUNKED ":"", response2.str()); | ||
} | ||
else | ||
master->logctx.mCTXLOG("%s: LEN=%d %sresponse(%s%s)", getWsCallTypeName(master->wscType),response.length(),chunked?"CHUNKED ":"", dbgheader.str(), response.str()); | ||
} | ||
return rval; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7738,6 +7738,10 @@ void CHThorWSCBaseActivity::init() | |
JBASE64_Encode(uidpair.str(), uidpair.length(), authToken, false); | ||
} | ||
soapTraceLevel = agent.queryWorkUnit()->getDebugValueInt("soapTraceLevel", 1); | ||
StringBuffer soapSepStr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. future: Can use SCMStringBuffer to avoid the need for the adaptor. |
||
StringBufferAdaptor soapSepAdaptor(soapSepStr); | ||
agent.queryWorkUnit()->getDebugValue("soapLogSepString", soapSepAdaptor); | ||
setSoapSepString(soapSepStr.str()); | ||
} | ||
|
||
//--------------------------------------------------------------------------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an opt, we could index for '\r' and then append chunks between newlines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, if it was very time critical, might be worth two pass, so can allocate correct size once, reserve and use regular ptr's instead of calls to StringBuffer, but doubt worth it.