MCPcopy Create free account
hub / github.com/chain/Core / Log

Method Log

net/http/httperror/httperror.go:81–99  ·  view source on GitHub ↗

Log writes a structured log entry to the chain/log logger with information about the error and the HTTP response.

(ctx context.Context, err error)

Source from the content-addressed store, hash-verified

79// Log writes a structured log entry to the chain/log logger with
80// information about the error and the HTTP response.
81func (f Formatter) Log(ctx context.Context, err error) {
82 var errorMessage string
83 if err != nil {
84 // strip the stack trace, if there is one
85 errorMessage = err.Error()
86 }
87
88 resp := f.Format(err)
89 keyvals := []interface{}{
90 "status", resp.HTTPStatus,
91 "chaincode", resp.ChainCode,
92 "path", reqid.PathFromContext(ctx),
93 log.KeyError, errorMessage,
94 }
95 if resp.HTTPStatus == 500 {
96 keyvals = append(keyvals, log.KeyStack, errors.Stack(err))
97 }
98 log.Printkv(ctx, keyvals...)
99}

Callers 15

TestLogSkipFunction · 0.95
WriteMethod · 0.95
NewDBFunction · 0.80
NewTxFunction · 0.80
TestMerkleRootFunction · 0.80
TestMapTxFunction · 0.80
TestLookupFunction · 0.80
TestInsertFunction · 0.80
TestRecoveryFunction · 0.80
batchRecoverFunction · 0.80

Calls 3

FormatMethod · 0.95
PrintkvMethod · 0.80
ErrorMethod · 0.45

Tested by 12

TestLogSkipFunction · 0.76
TestMerkleRootFunction · 0.64
TestMapTxFunction · 0.64
TestLookupFunction · 0.64
TestInsertFunction · 0.64
TestRecoveryFunction · 0.64
TestFailoverFunction · 0.64
TestPrintkvFunction · 0.64
TestFormatKeyFunction · 0.64
TestFormatValueFunction · 0.64