aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-03-03 17:41:52 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-03-03 17:41:52 +0800
commite7030c4bf59e8e148822c50ae1a5896c604c38c1 (patch)
tree4403290e84761608e8437d23ecef4d934406dd46 /internal
parentfaf713632c307e3fd77a492481846b858ad991f9 (diff)
downloadgo-tangerine-e7030c4bf59e8e148822c50ae1a5896c604c38c1.tar.gz
go-tangerine-e7030c4bf59e8e148822c50ae1a5896c604c38c1.tar.zst
go-tangerine-e7030c4bf59e8e148822c50ae1a5896c604c38c1.zip
all: update light logs (and a few others) to the new model
Diffstat (limited to 'internal')
-rw-r--r--internal/debug/api.go7
-rw-r--r--internal/debug/flags.go6
-rw-r--r--internal/debug/trace.go5
-rw-r--r--internal/ethapi/api.go54
4 files changed, 35 insertions, 37 deletions
diff --git a/internal/debug/api.go b/internal/debug/api.go
index 01126b41b..8b7693f6a 100644
--- a/internal/debug/api.go
+++ b/internal/debug/api.go
@@ -22,7 +22,6 @@ package debug
import (
"errors"
- "fmt"
"io"
"os"
"os/user"
@@ -111,7 +110,7 @@ func (h *HandlerT) StartCPUProfile(file string) error {
}
h.cpuW = f
h.cpuFile = file
- log.Info(fmt.Sprint("CPU profiling started, writing to", h.cpuFile))
+ log.Info("CPU profiling started", "dump", h.cpuFile)
return nil
}
@@ -123,7 +122,7 @@ func (h *HandlerT) StopCPUProfile() error {
if h.cpuW == nil {
return errors.New("CPU profiling not in progress")
}
- log.Info(fmt.Sprint("done writing CPU profile to", h.cpuFile))
+ log.Info("Done writing CPU profile", "dump", h.cpuFile)
h.cpuW.Close()
h.cpuW = nil
h.cpuFile = ""
@@ -179,7 +178,7 @@ func (*HandlerT) Stacks() string {
func writeProfile(name, file string) error {
p := pprof.Lookup(name)
- log.Info(fmt.Sprintf("writing %d %s profile records to %s", p.Count(), name, file))
+ log.Info("Writing profile records", "count", p.Count(), "type", name, "dump", file)
f, err := os.Create(expandHome(file))
if err != nil {
return err
diff --git a/internal/debug/flags.go b/internal/debug/flags.go
index f95251939..6247cc7dc 100644
--- a/internal/debug/flags.go
+++ b/internal/debug/flags.go
@@ -129,8 +129,10 @@ func Setup(ctx *cli.Context) error {
if ctx.GlobalBool(pprofFlag.Name) {
address := fmt.Sprintf("%s:%d", ctx.GlobalString(pprofAddrFlag.Name), ctx.GlobalInt(pprofPortFlag.Name))
go func() {
- log.Info(fmt.Sprintf("starting pprof server at http://%s/debug/pprof", address))
- log.Error(fmt.Sprint(http.ListenAndServe(address, nil)))
+ log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address))
+ if err := http.ListenAndServe(address, nil); err != nil {
+ log.Error("Failure in running pprof server", "err", err)
+ }
}()
}
return nil
diff --git a/internal/debug/trace.go b/internal/debug/trace.go
index 5e4b9df84..cab5deaaf 100644
--- a/internal/debug/trace.go
+++ b/internal/debug/trace.go
@@ -20,7 +20,6 @@ package debug
import (
"errors"
- "fmt"
"os"
"runtime/trace"
@@ -44,7 +43,7 @@ func (h *HandlerT) StartGoTrace(file string) error {
}
h.traceW = f
h.traceFile = file
- log.Info(fmt.Sprint("trace started, writing to", h.traceFile))
+ log.Info("Go tracing started", "dump", h.traceFile)
return nil
}
@@ -56,7 +55,7 @@ func (h *HandlerT) StopGoTrace() error {
if h.traceW == nil {
return errors.New("trace not in progress")
}
- log.Info(fmt.Sprint("done writing trace to", h.traceFile))
+ log.Info("Done writing Go trace", "dump", h.traceFile)
h.traceW.Close()
h.traceW = nil
h.traceFile = ""
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 5b7115e44..caa742180 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -477,7 +477,7 @@ func (s *PublicBlockChainAPI) GetUncleByBlockNumberAndIndex(ctx context.Context,
if block != nil {
uncles := block.Uncles()
if index >= hexutil.Uint(len(uncles)) {
- log.Debug(fmt.Sprintf("uncle block on index %d not found for block #%d", index, blockNr))
+ log.Debug("Requested uncle not found", "number", blockNr, "hash", block.Hash(), "index", index)
return nil, nil
}
block = types.NewBlockWithHeader(uncles[index])
@@ -493,7 +493,7 @@ func (s *PublicBlockChainAPI) GetUncleByBlockHashAndIndex(ctx context.Context, b
if block != nil {
uncles := block.Uncles()
if index >= hexutil.Uint(len(uncles)) {
- log.Debug(fmt.Sprintf("uncle block on index %d not found for block %s", index, blockHash.Hex()))
+ log.Debug("Requested uncle not found", "number", block.Number(), "hash", blockHash, "index", index)
return nil, nil
}
block = types.NewBlockWithHeader(uncles[index])
@@ -579,7 +579,7 @@ type CallArgs struct {
}
func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr rpc.BlockNumber, vmCfg vm.Config) ([]byte, *big.Int, error) {
- defer func(start time.Time) { log.Debug(fmt.Sprintf("call took %v", time.Since(start))) }(time.Now())
+ defer func(start time.Time) { log.Debug("Executing EVM call finished", "runtime", time.Since(start)) }(time.Now())
state, header, err := s.b.StateAndHeaderByNumber(ctx, blockNr)
if state == nil || err != nil {
@@ -999,42 +999,40 @@ func getTransactionBlockData(chainDb ethdb.Database, txHash common.Hash) (common
}
// GetTransactionByHash returns the transaction for the given hash
-func (s *PublicTransactionPoolAPI) GetTransactionByHash(ctx context.Context, txHash common.Hash) (*RPCTransaction, error) {
+func (s *PublicTransactionPoolAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error) {
var tx *types.Transaction
var isPending bool
var err error
- if tx, isPending, err = getTransaction(s.b.ChainDb(), s.b, txHash); err != nil {
- log.Debug(fmt.Sprintf("%v\n", err))
+ if tx, isPending, err = getTransaction(s.b.ChainDb(), s.b, hash); err != nil {
+ log.Debug("Failed to retrieve transaction", "hash", hash, "err", err)
return nil, nil
} else if tx == nil {
return nil, nil
}
-
if isPending {
return newRPCPendingTransaction(tx), nil
}
- blockHash, _, _, err := getTransactionBlockData(s.b.ChainDb(), txHash)
+ blockHash, _, _, err := getTransactionBlockData(s.b.ChainDb(), hash)
if err != nil {
- log.Debug(fmt.Sprintf("%v\n", err))
+ log.Debug("Failed to retrieve transaction block", "hash", hash, "err", err)
return nil, nil
}
if block, _ := s.b.GetBlock(ctx, blockHash); block != nil {
- return newRPCTransaction(block, txHash)
+ return newRPCTransaction(block, hash)
}
-
return nil, nil
}
// GetRawTransactionByHash returns the bytes of the transaction for the given hash.
-func (s *PublicTransactionPoolAPI) GetRawTransactionByHash(ctx context.Context, txHash common.Hash) (hexutil.Bytes, error) {
+func (s *PublicTransactionPoolAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) {
var tx *types.Transaction
var err error
- if tx, _, err = getTransaction(s.b.ChainDb(), s.b, txHash); err != nil {
- log.Debug(fmt.Sprintf("%v\n", err))
+ if tx, _, err = getTransaction(s.b.ChainDb(), s.b, hash); err != nil {
+ log.Debug("Failed to retrieve transaction", "hash", hash, "err", err)
return nil, nil
} else if tx == nil {
return nil, nil
@@ -1044,22 +1042,22 @@ func (s *PublicTransactionPoolAPI) GetRawTransactionByHash(ctx context.Context,
}
// GetTransactionReceipt returns the transaction receipt for the given transaction hash.
-func (s *PublicTransactionPoolAPI) GetTransactionReceipt(txHash common.Hash) (map[string]interface{}, error) {
- receipt := core.GetReceipt(s.b.ChainDb(), txHash)
+func (s *PublicTransactionPoolAPI) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error) {
+ receipt := core.GetReceipt(s.b.ChainDb(), hash)
if receipt == nil {
- log.Debug(fmt.Sprintf("receipt not found for transaction %s", txHash.Hex()))
+ log.Debug("Receipt not found for transaction", "hash", hash)
return nil, nil
}
- tx, _, err := getTransaction(s.b.ChainDb(), s.b, txHash)
+ tx, _, err := getTransaction(s.b.ChainDb(), s.b, hash)
if err != nil {
- log.Debug(fmt.Sprintf("%v\n", err))
+ log.Debug("Failed to retrieve transaction", "hash", hash, "err", err)
return nil, nil
}
- txBlock, blockIndex, index, err := getTransactionBlockData(s.b.ChainDb(), txHash)
+ txBlock, blockIndex, index, err := getTransactionBlockData(s.b.ChainDb(), hash)
if err != nil {
- log.Debug(fmt.Sprintf("%v\n", err))
+ log.Debug("Failed to retrieve transaction block", "hash", hash, "err", err)
return nil, nil
}
@@ -1073,7 +1071,7 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(txHash common.Hash) (ma
"root": hexutil.Bytes(receipt.PostState),
"blockHash": txBlock,
"blockNumber": hexutil.Uint64(blockIndex),
- "transactionHash": txHash,
+ "transactionHash": hash,
"transactionIndex": hexutil.Uint64(index),
"from": from,
"to": tx.To(),
@@ -1162,9 +1160,9 @@ func submitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (c
signer := types.MakeSigner(b.ChainConfig(), b.CurrentBlock().Number())
from, _ := types.Sender(signer, tx)
addr := crypto.CreateAddress(from, tx.Nonce())
- log.Info(fmt.Sprintf("Tx(%s) created: %s\n", tx.Hash().Hex(), addr.Hex()))
+ log.Info("Submitted contract creation", "fullhash", tx.Hash().Hex(), "contract", addr.Hex())
} else {
- log.Info(fmt.Sprintf("Tx(%s) to: %s\n", tx.Hash().Hex(), tx.To().Hex()))
+ log.Info("Submitted transaction", "fullhash", tx.Hash().Hex(), "recipient", tx.To())
}
return tx.Hash(), nil
}
@@ -1216,9 +1214,9 @@ func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encod
return "", err
}
addr := crypto.CreateAddress(from, tx.Nonce())
- log.Info(fmt.Sprintf("Tx(%x) created: %x\n", tx.Hash(), addr))
+ log.Info("Submitted contract creation", "fullhash", tx.Hash().Hex(), "contract", addr.Hex())
} else {
- log.Info(fmt.Sprintf("Tx(%x) to: %x\n", tx.Hash(), tx.To()))
+ log.Info("Submitted transaction", "fullhash", tx.Hash().Hex(), "recipient", tx.To())
}
return tx.Hash().Hex(), nil
@@ -1423,10 +1421,10 @@ func (api *PrivateDebugAPI) ChaindbCompact() error {
return fmt.Errorf("chaindbCompact does not work for memory databases")
}
for b := byte(0); b < 255; b++ {
- log.Info(fmt.Sprintf("compacting chain DB range 0x%0.2X-0x%0.2X", b, b+1))
+ log.Info("Compacting chain database", "range", fmt.Sprintf("0x%0.2X-0x%0.2X", b, b+1))
err := ldb.LDB().CompactRange(util.Range{Start: []byte{b}, Limit: []byte{b + 1}})
if err != nil {
- log.Error(fmt.Sprintf("compaction error: %v", err))
+ log.Error("Database compaction failed", "err", err)
return err
}
}