Skip to content

Commit

Permalink
[FAB-18270] Disable debug of CouchDB response body
Browse files Browse the repository at this point in the history
The CouchDB query response body should not be added to debug log.
This change reduces the debug to the HTTP headers only, so that
the peer debug log can still be associated with the CouchDB logs, without
logging the full response content.

Signed-off-by: David Enyeart <enyeart@us.ibm.com>
  • Loading branch information
denyeart committed Oct 14, 2020
1 parent 192b03b commit 4e2ac6f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions core/ledger/kvledger/txmgmt/statedb/statecouchdb/couchdb.go
Expand Up @@ -890,11 +890,12 @@ func (dbclient *couchDatabase) readDocRange(startKey, endKey string, limit int32
defer closeResponseBody(resp)

if couchdbLogger.IsEnabledFor(zapcore.DebugLevel) {
dump, err2 := httputil.DumpResponse(resp, true)
dump, err2 := httputil.DumpResponse(resp, false)
if err2 != nil {
log.Fatal(err2)
}
couchdbLogger.Debugf("[%s] %s", dbclient.dbName, dump)
// compact debug log by replacing carriage return / line feed with dashes to separate http headers
couchdbLogger.Debugf("[%s] HTTP Response: %s", dbclient.dbName, bytes.Replace(dump, []byte{0x0d, 0x0a}, []byte{0x20, 0x7c, 0x20}, -1))
}

//handle as JSON document
Expand Down Expand Up @@ -1026,11 +1027,12 @@ func (dbclient *couchDatabase) queryDocuments(query string) ([]*queryResult, str
defer closeResponseBody(resp)

if couchdbLogger.IsEnabledFor(zapcore.DebugLevel) {
dump, err2 := httputil.DumpResponse(resp, true)
dump, err2 := httputil.DumpResponse(resp, false)
if err2 != nil {
log.Fatal(err2)
}
couchdbLogger.Debugf("[%s] %s", dbclient.dbName, dump)
// compact debug log by replacing carriage return / line feed with dashes to separate http headers
couchdbLogger.Debugf("[%s] HTTP Response: %s", dbclient.dbName, bytes.Replace(dump, []byte{0x0d, 0x0a}, []byte{0x20, 0x7c, 0x20}, -1))
}

//handle as JSON document
Expand Down

0 comments on commit 4e2ac6f

Please sign in to comment.