From 4e2ac6f8a5d4913ed5526f21477ff7464049a8a9 Mon Sep 17 00:00:00 2001 From: David Enyeart Date: Wed, 14 Oct 2020 00:02:58 -0400 Subject: [PATCH] [FAB-18270] Disable debug of CouchDB response body 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 --- .../kvledger/txmgmt/statedb/statecouchdb/couchdb.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/ledger/kvledger/txmgmt/statedb/statecouchdb/couchdb.go b/core/ledger/kvledger/txmgmt/statedb/statecouchdb/couchdb.go index c06a7cbc0eb..f9d70df4a74 100644 --- a/core/ledger/kvledger/txmgmt/statedb/statecouchdb/couchdb.go +++ b/core/ledger/kvledger/txmgmt/statedb/statecouchdb/couchdb.go @@ -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 @@ -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