mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
wip fieldpadding
This commit is contained in:
parent
c1d5a012ea
commit
3bbe4aba84
3 changed files with 23 additions and 3 deletions
|
|
@ -443,3 +443,7 @@ func (api *DebugAPI) GetTrieFlushInterval() (string, error) {
|
||||||
}
|
}
|
||||||
return api.eth.blockchain.GetTrieFlushInterval().String(), nil
|
return api.eth.blockchain.GetTrieFlushInterval().String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (api *DebugAPI) FieldPaddings() (string, error) {
|
||||||
|
return string(log.FieldPaddings()), nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -501,6 +501,11 @@ web3._extend({
|
||||||
call: 'debug_getTrieFlushInterval',
|
call: 'debug_getTrieFlushInterval',
|
||||||
params: 0
|
params: 0
|
||||||
}),
|
}),
|
||||||
|
new web3._extend.Method({
|
||||||
|
name: 'fieldPaddings',
|
||||||
|
call: 'debug_fieldPaddings',
|
||||||
|
params: 0
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
properties: []
|
properties: []
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,10 @@ type Format interface {
|
||||||
Format(r *Record) []byte
|
Format(r *Record) []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
json.Unmarshal([]byte("{\n \"ETH\": 2,\n \"LES\": 1,\n \"accounts\": 2,\n \"age\": 9,\n \"backend\": 5,\n \"blocks\": 1,\n \"cap\": 10,\n \"clean\": 9,\n \"dangling\": 1,\n \"dbversion\": 5,\n \"dirty\": 9,\n \"duration\": 10,\n \"elapsed\": 11,\n \"err\": 31,\n \"fees\": 7,\n \"gas\": 5,\n \"gcnodes\": 1,\n \"gcsize\": 5,\n \"gctime\": 2,\n \"hash\": 14,\n \"id\": 18,\n \"ip\": 9,\n \"limit\": 9,\n \"livenodes\": 1,\n \"livesize\": 5,\n \"mgas\": 5,\n \"mgasps\": 6,\n \"network\": 4,\n \"nodes\": 2,\n \"nonce\": 1,\n \"number\": 2,\n \"reason\": 8,\n \"reqid\": 2,\n \"root\": 14,\n \"scheme\": 4,\n \"seq\": 17,\n \"size\": 7,\n \"slots\": 1,\n \"snapdiffs\": 7,\n \"storage\": 7,\n \"tcp\": 1,\n \"td\": 1,\n \"threshold\": 1,\n \"time\": 11,\n \"total\": 2,\n \"triedirty\": 7,\n \"txs\": 1,\n \"udp\": 1,\n \"url\": 13,\n \"value\": 3,\n \"withdrawals\": 1\n}"), fieldPadding)
|
||||||
|
}
|
||||||
|
|
||||||
// FormatFunc returns a new Format object which uses
|
// FormatFunc returns a new Format object which uses
|
||||||
// the given function to perform record formatting.
|
// the given function to perform record formatting.
|
||||||
func FormatFunc(f func(*Record) []byte) Format {
|
func FormatFunc(f func(*Record) []byte) Format {
|
||||||
|
|
@ -187,9 +191,9 @@ func logfmt(buf *bytes.Buffer, ctx []interface{}, color int, term bool) {
|
||||||
if padding < length && length <= termCtxMaxPadding {
|
if padding < length && length <= termCtxMaxPadding {
|
||||||
padding = length
|
padding = length
|
||||||
|
|
||||||
fieldPaddingLock.Lock()
|
//fieldPaddingLock.Lock()
|
||||||
fieldPadding[k] = padding
|
//fieldPadding[k] = padding
|
||||||
fieldPaddingLock.Unlock()
|
//fieldPaddingLock.Unlock()
|
||||||
}
|
}
|
||||||
if color > 0 {
|
if color > 0 {
|
||||||
fmt.Fprintf(buf, "\x1b[%dm%s\x1b[0m=", color, k)
|
fmt.Fprintf(buf, "\x1b[%dm%s\x1b[0m=", color, k)
|
||||||
|
|
@ -211,6 +215,13 @@ func JSONFormat() Format {
|
||||||
return JSONFormatEx(false, true)
|
return JSONFormatEx(false, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FieldPaddings() []byte {
|
||||||
|
fieldPaddingLock.RLock()
|
||||||
|
output, _ := json.MarshalIndent(fieldPadding, "", " ")
|
||||||
|
fieldPaddingLock.RUnlock()
|
||||||
|
return output
|
||||||
|
}
|
||||||
|
|
||||||
// JSONFormatOrderedEx formats log records as JSON arrays. If pretty is true,
|
// JSONFormatOrderedEx formats log records as JSON arrays. If pretty is true,
|
||||||
// records will be pretty-printed. If lineSeparated is true, records
|
// records will be pretty-printed. If lineSeparated is true, records
|
||||||
// will be logged with a new line between each record.
|
// will be logged with a new line between each record.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue