Skip to content

Commit b39b8a8

Browse files
committed
Clean up peer logging - serviceability
Clean up peer logging for improved serviceability. INFO level log had a lot of debug information, making it impossible to find important INFO information and errors through the noise. Changed most of the debug information to use DEBUG level. After this change, during normal transaction processing there will be a single entry in info log per block with messages like this: Channel [myc1]: Created block [1] with 43 transaction(s) Channel [myc1]: Created block [2] with 14 transaction(s) Channel [myc1]: Created block [3] with 26 transaction(s) This will make it easy to spot any anomilies in the logs, while still tracking block progress. Confirmed there are good INFO messages for important events such as peer initialization and channel creation. Removed data content from debug messages for enhanced privacy. Change-Id: I3a0b2f3a07d5c7dcf388a609d11cfa3bcf7bb065 Signed-off-by: denyeart <[email protected]>
1 parent 7134f9f commit b39b8a8

File tree

16 files changed

+48
-90
lines changed

16 files changed

+48
-90
lines changed

core/committer/txvalidator/validator.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func (v *vsccValidatorImpl) VSCCValidateTx(payload *common.Payload, envBytes []b
233233
// VSCCValidateTx should
234234
if hdrExt.ChaincodeId.Name == "lccc" {
235235
// TODO: until FAB-1934 is in, we need to stop here
236-
logger.Infof("Invocation of LCCC detected, no further VSCC validation necessary")
236+
logger.Debugf("Invocation of LCCC detected, no further VSCC validation necessary")
237237
return nil
238238
}
239239

@@ -257,7 +257,7 @@ func (v *vsccValidatorImpl) VSCCValidateTx(payload *common.Payload, envBytes []b
257257
cccid := v.ccprovider.GetCCContext(chainID, vscc, version, vscctxid, true, nil, nil)
258258

259259
// invoke VSCC
260-
logger.Info("Invoking VSCC txid", txid, "chaindID", chainID)
260+
logger.Debug("Invoking VSCC txid", txid, "chaindID", chainID)
261261
res, _, err := v.ccprovider.ExecuteChaincode(ctxt, cccid, args)
262262
if err != nil {
263263
logger.Errorf("Invoke VSCC failed for transaction txid=%s, error %s", txid, err)

core/common/ccprovider/ccprovider.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func NewCCContext(cid, name, version, txid string, syscc bool, signedProp *pb.Si
206206

207207
cccid := &CCContext{cid, name, version, txid, syscc, signedProp, prop, canName}
208208

209-
ccproviderLogger.Infof("NewCCCC (chain=%s,chaincode=%s,version=%s,txid=%s,syscc=%t,proposal=%p,canname=%s", cid, name, version, txid, syscc, prop, cccid.canonicalName)
209+
ccproviderLogger.Debugf("NewCCCC (chain=%s,chaincode=%s,version=%s,txid=%s,syscc=%t,proposal=%p,canname=%s", cid, name, version, txid, syscc, prop, cccid.canonicalName)
210210

211211
return cccid
212212
}

core/common/validation/msgvalidation.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ var putilsLogger = logging.MustGetLogger("protoutils")
3232

3333
// validateChaincodeProposalMessage checks the validity of a Proposal message of type CHAINCODE
3434
func validateChaincodeProposalMessage(prop *pb.Proposal, hdr *common.Header) (*pb.ChaincodeHeaderExtension, error) {
35-
putilsLogger.Infof("validateChaincodeProposalMessage starts for proposal %p, header %p", prop, hdr)
35+
putilsLogger.Debugf("validateChaincodeProposalMessage starts for proposal %p, header %p", prop, hdr)
3636

3737
// 4) based on the header type (assuming it's CHAINCODE), look at the extensions
3838
chaincodeHdrExt, err := utils.GetChaincodeHeaderExtension(hdr)
3939
if err != nil {
4040
return nil, errors.New("Invalid header extension for type CHAINCODE")
4141
}
4242

43-
putilsLogger.Infof("validateChaincodeProposalMessage info: header extension references chaincode %s", chaincodeHdrExt.ChaincodeId)
43+
putilsLogger.Debugf("validateChaincodeProposalMessage info: header extension references chaincode %s", chaincodeHdrExt.ChaincodeId)
4444

4545
// - ensure that the chaincodeID is correct (?)
4646
// TODO: should we even do this? If so, using which interface?
@@ -64,7 +64,7 @@ func validateChaincodeProposalMessage(prop *pb.Proposal, hdr *common.Header) (*p
6464
// this function returns Header and ChaincodeHeaderExtension messages since they
6565
// have been unmarshalled and validated
6666
func ValidateProposalMessage(signedProp *pb.SignedProposal) (*pb.Proposal, *common.Header, *pb.ChaincodeHeaderExtension, error) {
67-
putilsLogger.Infof("ValidateProposalMessage starts for signed proposal %p", signedProp)
67+
putilsLogger.Debugf("ValidateProposalMessage starts for signed proposal %p", signedProp)
6868

6969
// extract the Proposal message from signedProp
7070
prop, err := utils.GetProposal(signedProp.ProposalBytes)
@@ -127,7 +127,7 @@ func ValidateProposalMessage(signedProp *pb.SignedProposal) (*pb.Proposal, *comm
127127
// this function returns nil if the creator
128128
// is a valid cert and the signature is valid
129129
func checkSignatureFromCreator(creatorBytes []byte, sig []byte, msg []byte, ChainID string) error {
130-
putilsLogger.Infof("checkSignatureFromCreator starts")
130+
putilsLogger.Debugf("checkSignatureFromCreator starts")
131131

132132
// check for nil argument
133133
if creatorBytes == nil || sig == nil || msg == nil {
@@ -145,23 +145,23 @@ func checkSignatureFromCreator(creatorBytes []byte, sig []byte, msg []byte, Chai
145145
return fmt.Errorf("Failed to deserialize creator identity, err %s", err)
146146
}
147147

148-
putilsLogger.Infof("checkSignatureFromCreator info: creator is %s", creator.GetIdentifier())
148+
putilsLogger.Debugf("checkSignatureFromCreator info: creator is %s", creator.GetIdentifier())
149149

150150
// ensure that creator is a valid certificate
151151
err = creator.Validate()
152152
if err != nil {
153153
return fmt.Errorf("The creator certificate is not valid, err %s", err)
154154
}
155155

156-
putilsLogger.Infof("checkSignatureFromCreator info: creator is valid")
156+
putilsLogger.Debugf("checkSignatureFromCreator info: creator is valid")
157157

158158
// validate the signature
159159
err = creator.Verify(msg, sig)
160160
if err != nil {
161161
return fmt.Errorf("The creator's signature over the proposal is not valid, err %s", err)
162162
}
163163

164-
putilsLogger.Infof("checkSignatureFromCreator exists successfully")
164+
putilsLogger.Debugf("checkSignatureFromCreator exists successfully")
165165

166166
return nil
167167
}
@@ -200,7 +200,7 @@ func validateChannelHeader(cHdr *common.ChannelHeader) error {
200200
return fmt.Errorf("invalid header type %s", common.HeaderType(cHdr.Type))
201201
}
202202

203-
putilsLogger.Infof("validateChannelHeader info: header type %d", common.HeaderType(cHdr.Type))
203+
putilsLogger.Debugf("validateChannelHeader info: header type %d", common.HeaderType(cHdr.Type))
204204

205205
// TODO: validate chainID in cHdr.ChainID
206206

@@ -249,7 +249,7 @@ func validateCommonHeader(hdr *common.Header) (*common.ChannelHeader, *common.Si
249249
// validateConfigTransaction validates the payload of a
250250
// transaction assuming its type is CONFIG
251251
func validateConfigTransaction(data []byte, hdr *common.Header) error {
252-
putilsLogger.Infof("validateConfigTransaction starts for data %p, header %s", data, hdr)
252+
putilsLogger.Debugf("validateConfigTransaction starts for data %p, header %s", data, hdr)
253253

254254
// check for nil argument
255255
if data == nil || hdr == nil {
@@ -264,7 +264,7 @@ func validateConfigTransaction(data []byte, hdr *common.Header) error {
264264
// validateEndorserTransaction validates the payload of a
265265
// transaction assuming its type is ENDORSER_TRANSACTION
266266
func validateEndorserTransaction(data []byte, hdr *common.Header) error {
267-
putilsLogger.Infof("validateEndorserTransaction starts for data %p, header %s", data, hdr)
267+
putilsLogger.Debugf("validateEndorserTransaction starts for data %p, header %s", data, hdr)
268268

269269
// check for nil argument
270270
if data == nil || hdr == nil {
@@ -290,7 +290,7 @@ func validateEndorserTransaction(data []byte, hdr *common.Header) error {
290290
return errors.New("At least one TransactionAction is required")
291291
}
292292

293-
putilsLogger.Infof("validateEndorserTransaction info: there are %d actions", len(tx.Actions))
293+
putilsLogger.Debugf("validateEndorserTransaction info: there are %d actions", len(tx.Actions))
294294

295295
for _, act := range tx.Actions {
296296
// check for nil argument
@@ -311,7 +311,7 @@ func validateEndorserTransaction(data []byte, hdr *common.Header) error {
311311
return err
312312
}
313313

314-
putilsLogger.Infof("validateEndorserTransaction info: signature header is valid")
314+
putilsLogger.Debugf("validateEndorserTransaction info: signature header is valid")
315315

316316
// if the type is ENDORSER_TRANSACTION we unmarshal a ChaincodeActionPayload
317317
ccActionPayload, err := utils.GetChaincodeActionPayload(act.Payload)
@@ -346,7 +346,7 @@ func validateEndorserTransaction(data []byte, hdr *common.Header) error {
346346

347347
// ValidateTransaction checks that the transaction envelope is properly formed
348348
func ValidateTransaction(e *common.Envelope) (*common.Payload, pb.TxValidationCode) {
349-
putilsLogger.Infof("ValidateTransactionEnvelope starts for envelope %p", e)
349+
putilsLogger.Debugf("ValidateTransactionEnvelope starts for envelope %p", e)
350350

351351
// check for nil argument
352352
if e == nil {
@@ -361,7 +361,7 @@ func ValidateTransaction(e *common.Envelope) (*common.Payload, pb.TxValidationCo
361361
return nil, pb.TxValidationCode_BAD_PAYLOAD
362362
}
363363

364-
putilsLogger.Infof("Header is %s", payload.Header)
364+
putilsLogger.Debugf("Header is %s", payload.Header)
365365

366366
// validate the header
367367
chdr, shdr, err := validateCommonHeader(payload.Header)
@@ -396,7 +396,7 @@ func ValidateTransaction(e *common.Envelope) (*common.Payload, pb.TxValidationCo
396396
}
397397

398398
err = validateEndorserTransaction(payload.Data, payload.Header)
399-
putilsLogger.Infof("ValidateTransactionEnvelope returns err %s", err)
399+
putilsLogger.Debugf("ValidateTransactionEnvelope returns err %s", err)
400400

401401
if err != nil {
402402
putilsLogger.Errorf("validateEndorserTransaction returns err %s", err)

core/endorser/endorser.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func (e *Endorser) getCDSFromLCCC(ctx context.Context, chainID string, txid stri
227227

228228
//endorse the proposal by calling the ESCC
229229
func (e *Endorser) endorseProposal(ctx context.Context, chainID string, txid string, signedProp *pb.SignedProposal, proposal *pb.Proposal, response *pb.Response, simRes []byte, event *pb.ChaincodeEvent, visibility []byte, ccid *pb.ChaincodeID, txsim ledger.TxSimulator, cd *ccprovider.ChaincodeData) (*pb.ProposalResponse, error) {
230-
endorserLogger.Infof("endorseProposal starts for chainID %s, ccid %s", chainID, ccid)
230+
endorserLogger.Debugf("endorseProposal starts for chainID %s, ccid %s", chainID, ccid)
231231

232232
// 1) extract the name of the escc that is requested to endorse this chaincode
233233
var escc string
@@ -243,7 +243,7 @@ func (e *Endorser) endorseProposal(ctx context.Context, chainID string, txid str
243243
escc = "escc"
244244
}
245245

246-
endorserLogger.Infof("endorseProposal info: escc for cid %s is %s", ccid, escc)
246+
endorserLogger.Debugf("endorseProposal info: escc for cid %s is %s", ccid, escc)
247247

248248
// marshalling event bytes
249249
var err error

core/ledger/kvledger/history/historydb/historyleveldb/historyleveldb.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ func (historyDB *historyDB) Commit(block *common.Block) error {
8989

9090
dbBatch := leveldbhelper.NewUpdateBatch()
9191

92-
logger.Debugf("Updating history database for blockNo [%v] with [%d] transactions",
93-
blockNo, len(block.Data.Data))
92+
logger.Debugf("Channel [%s]: Updating history database for blockNo [%v] with [%d] transactions",
93+
historyDB.dbName, blockNo, len(block.Data.Data))
9494

9595
//TODO add check for invalid trans in bit array
9696
for _, envBytes := range block.Data.Data {
@@ -157,7 +157,7 @@ func (historyDB *historyDB) Commit(block *common.Block) error {
157157
return err
158158
}
159159

160-
logger.Debugf("Updates committed to history database for blockNo [%v]", blockNo)
160+
logger.Debugf("Channel [%s]: Updates committed to history database for blockNo [%v]", historyDB.dbName, blockNo)
161161
return nil
162162
}
163163

core/ledger/kvledger/kv_ledger.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -212,25 +212,26 @@ func (l *kvLedger) Commit(block *common.Block) error {
212212
var err error
213213
blockNo := block.Header.Number
214214

215-
logger.Debugf("Validating block [%d]", blockNo)
215+
logger.Debugf("Channel [%s]: Validating block [%d]", l.ledgerID, blockNo)
216216
err = l.txtmgmt.ValidateAndPrepare(block, true)
217217
if err != nil {
218218
return err
219219
}
220220

221-
logger.Debugf("Committing block [%d] to storage", blockNo)
221+
logger.Debugf("Channel [%s]: Committing block [%d] to storage", l.ledgerID, blockNo)
222222
if err = l.blockStore.AddBlock(block); err != nil {
223223
return err
224224
}
225+
logger.Infof("Channel [%s]: Created block [%d] with %d transaction(s)", l.ledgerID, block.Header.Number, len(block.Data.Data))
225226

226-
logger.Debugf("Committing block [%d] transactions to state database", blockNo)
227+
logger.Debugf("Channel [%s]: Committing block [%d] transactions to state database", l.ledgerID, blockNo)
227228
if err = l.txtmgmt.Commit(); err != nil {
228229
panic(fmt.Errorf(`Error during commit to txmgr:%s`, err))
229230
}
230231

231232
// History database could be written in parallel with state and/or async as a future optimization
232233
if ledgerconfig.IsHistoryDBEnabled() {
233-
logger.Debugf("Committing block [%d] transactions to history database", blockNo)
234+
logger.Debugf("Channel [%s]: Committing block [%d] transactions to history database", l.ledgerID, blockNo)
234235
if err := l.historyDB.Commit(block); err != nil {
235236
panic(fmt.Errorf(`Error during commit to history db:%s`, err))
236237
}

core/ledger/kvledger/txmgmt/statedb/statecouchdb/statecouchdb.go

+1-18
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,6 @@ func (vdb *VersionedDB) GetState(namespace string, key string) (*statedb.Version
122122
return nil, nil
123123
}
124124

125-
// trace the first 200 bytes of value only, in case it is huge
126-
if couchDoc.JSONValue != nil && logger.IsEnabledFor(logging.DEBUG) {
127-
if len(couchDoc.JSONValue) < 200 {
128-
logger.Debugf("getCommittedValueAndVersion() Read docBytes %s", couchDoc.JSONValue)
129-
} else {
130-
logger.Debugf("getCommittedValueAndVersion() Read docBytes %s...", couchDoc.JSONValue[0:200])
131-
}
132-
}
133-
134125
//remove the data wrapper and return the value and version
135126
returnValue, returnVersion := removeDataWrapper(couchDoc.JSONValue, couchDoc.Attachments)
136127

@@ -248,15 +239,7 @@ func (vdb *VersionedDB) ApplyUpdates(batch *statedb.UpdateBatch, height *version
248239
updates := batch.GetUpdates(ns)
249240
for k, vv := range updates {
250241
compositeKey := constructCompositeKey(ns, k)
251-
252-
// trace the first 200 characters of versioned value only, in case it is huge
253-
if logger.IsEnabledFor(logging.DEBUG) {
254-
versionedValueDump := fmt.Sprintf("%#v", vv)
255-
if len(versionedValueDump) > 200 {
256-
versionedValueDump = versionedValueDump[0:200] + "..."
257-
}
258-
logger.Debugf("Applying key=%#v, versionedValue=%s", compositeKey, versionedValueDump)
259-
}
242+
logger.Debugf("Channel [%s]: Applying key=[%#v]", vdb.dbName, compositeKey)
260243

261244
//convert nils to deletes
262245
if vv.Value == nil {

core/ledger/kvledger/txmgmt/statedb/stateleveldb/stateleveldb.go

+2-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package stateleveldb
1919
import (
2020
"bytes"
2121
"errors"
22-
"fmt"
2322

2423
"github.com/hyperledger/fabric/common/ledger/util/leveldbhelper"
2524
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/statedb"
@@ -134,14 +133,8 @@ func (vdb *versionedDB) ApplyUpdates(batch *statedb.UpdateBatch, height *version
134133
updates := batch.GetUpdates(ns)
135134
for k, vv := range updates {
136135
compositeKey := constructCompositeKey(ns, k)
137-
// trace the first 200 characters of versioned value only, in case it is huge
138-
if logger.IsEnabledFor(logging.DEBUG) {
139-
versionedValueDump := fmt.Sprintf("%#v", vv)
140-
if len(versionedValueDump) > 200 {
141-
versionedValueDump = versionedValueDump[0:200] + "..."
142-
}
143-
logger.Debugf("Applying key=%#v, versionedValue=%s", compositeKey, versionedValueDump)
144-
}
136+
logger.Debugf("Channel [%s]: Applying key=[%#v]", vdb.dbName, compositeKey)
137+
145138
if vv.Value == nil {
146139
dbBatch.Delete(compositeKey)
147140
} else {

core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr/lockbased_query_executer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ func (q *lockBasedQueryExecutor) ExecuteQuery(namespace, query string) (ledger.R
5959

6060
// Done implements method in interface `ledger.QueryExecutor`
6161
func (q *lockBasedQueryExecutor) Done() {
62-
logger.Debugf("Done query executer/ tx simulator [%s]", q.id)
62+
logger.Debugf("Done with transaction simulation / query execution [%s]", q.id)
6363
q.helper.done()
6464
}

core/ledger/kvledger/txmgmt/validator/statebasedval/state_based_validator.go

-10
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,6 @@ func (v *Validator) validateEndorserTX(envBytes []byte, doMVCCValidation bool, u
5757
return nil, peer.TxValidationCode_INVALID_OTHER_REASON, nil
5858
}
5959

60-
// trace the first 1000 characters of RWSet only, in case it is huge
61-
if logger.IsEnabledFor(logging.DEBUG) {
62-
txRWSetString := txRWSet.String()
63-
if len(txRWSetString) < 1000 {
64-
logger.Debugf("validating txRWSet:[%s]", txRWSetString)
65-
} else {
66-
logger.Debugf("validating txRWSet:[%s...]", txRWSetString[0:1000])
67-
}
68-
}
69-
7060
var txResult peer.TxValidationCode = peer.TxValidationCode_VALID
7161

7262
//mvccvalidation, may invalidate transaction

core/ledger/util/couchdb/couchdb.go

+6-18
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func (dbclient *CouchDatabase) EnsureFullCommit() (*DBOperationResponse, error)
390390
//SaveDoc method provides a function to save a document, id and byte array
391391
func (dbclient *CouchDatabase) SaveDoc(id string, rev string, couchDoc *CouchDoc) (string, error) {
392392

393-
logger.Debugf("Entering SaveDoc()")
393+
logger.Debugf("Entering SaveDoc() id=[%s]", id)
394394
if !utf8.ValidString(id) {
395395
return "", fmt.Errorf("doc id [%x] not a valid utf8 string", id)
396396
}
@@ -405,8 +405,6 @@ func (dbclient *CouchDatabase) SaveDoc(id string, rev string, couchDoc *CouchDoc
405405
// id can contain a '/', so encode separately
406406
saveURL = &url.URL{Opaque: saveURL.String() + "/" + encodePathElement(id)}
407407

408-
logger.Debugf(" id=%s, value=%s, attachments=%d", id, string(couchDoc.JSONValue), len(couchDoc.Attachments))
409-
410408
if rev == "" {
411409

412410
//See if the document already exists, we need the rev for save
@@ -560,7 +558,7 @@ func getRevisionHeader(resp *http.Response) (string, error) {
560558
//ReadDoc method provides function to retrieve a document from the database by id
561559
func (dbclient *CouchDatabase) ReadDoc(id string) (*CouchDoc, string, error) {
562560
var couchDoc CouchDoc
563-
logger.Debugf("Entering ReadDoc() id=%s", id)
561+
logger.Debugf("Entering ReadDoc() id=[%s]", id)
564562
if !utf8.ValidString(id) {
565563
return nil, "", fmt.Errorf("doc id [%x] not a valid utf8 string", id)
566564
}
@@ -581,13 +579,13 @@ func (dbclient *CouchDatabase) ReadDoc(id string) (*CouchDoc, string, error) {
581579

582580
resp, couchDBReturn, err := dbclient.couchInstance.handleRequest(http.MethodGet, readURL.String(), nil, "", "")
583581
if err != nil {
584-
fmt.Printf("couchDBReturn=%v", couchDBReturn)
585582
if couchDBReturn != nil && couchDBReturn.StatusCode == 404 {
586583
logger.Debug("Document not found (404), returning nil value instead of 404 error")
587584
// non-existent document should return nil value instead of a 404 error
588585
// for details see https://github.com/hyperledger-archives/fabric/issues/936
589586
return nil, "", nil
590587
}
588+
logger.Debugf("couchDBReturn=%v\n", couchDBReturn)
591589
return nil, "", err
592590
}
593591
defer resp.Body.Close()
@@ -679,7 +677,6 @@ func (dbclient *CouchDatabase) ReadDoc(id string) (*CouchDoc, string, error) {
679677
return nil, "", err
680678
}
681679

682-
logger.Debugf("Read document, id=%s, value=%s", id, string(couchDoc.JSONValue))
683680
logger.Debugf("Exiting ReadDoc()")
684681
return &couchDoc, revision, nil
685682
}
@@ -973,18 +970,9 @@ func (couchInstance *CouchInstance) handleRequest(method, connectURL string, dat
973970
}
974971

975972
if logger.IsEnabledFor(logging.DEBUG) {
976-
dump, err2 := httputil.DumpRequestOut(req, true)
977-
if err2 != nil {
978-
log.Fatal(err2)
979-
}
980-
// trace the first 200 bytes of http request only, in case it is huge
981-
if dump != nil {
982-
if len(dump) <= 200 {
983-
logger.Debugf("HTTP Request: %s", dump)
984-
} else {
985-
logger.Debugf("HTTP Request: %s...", dump[0:200])
986-
}
987-
}
973+
dump, _ := httputil.DumpRequestOut(req, false)
974+
// compact debug log by replacing carriage return / line feed with dashes to separate http headers
975+
logger.Debugf("HTTP Request: %s", bytes.Replace(dump, []byte{0x0d, 0x0a}, []byte{0x20, 0x7c, 0x20}, -1))
988976
}
989977

990978
//Create the http client

0 commit comments

Comments
 (0)