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>
(cherry picked from commit 4e2ac6f)
  • Loading branch information
denyeart committed Oct 14, 2020
1 parent 4d40d65 commit 6f3ad12
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 @@ -889,11 +889,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 @@ -1025,11 +1026,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 6f3ad12

Please sign in to comment.