Move status-go over to go-ethereum/log #717 (#727)

This commit is contained in:
Alex Kohler 2018-03-20 14:35:28 -04:00 committed by Igor Mandrigin
parent dc4a0a98ed
commit 4a01a395b4
31 changed files with 220 additions and 437 deletions

View File

@ -3,10 +3,10 @@ package debug
import (
"bufio"
"fmt"
"log"
"net"
"reflect"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/geth/api"
)
@ -22,6 +22,7 @@ const (
type Server struct {
commandSetValue reflect.Value
listener net.Listener
log log.Logger
}
// New creates a debug server using the passed Status API.
@ -34,6 +35,7 @@ func New(statusAPI *api.StatusAPI, port string) (*Server, error) {
s := Server{
commandSetValue: reflect.ValueOf(newCommandSet(statusAPI)),
listener: listener,
log: log.New("package", "status-go/cmd/statusd/debug.Server"),
}
go s.backend()
return &s, nil
@ -45,7 +47,7 @@ func (s *Server) backend() {
for {
conn, err := s.listener.Accept()
if err != nil {
log.Printf("cannot establish debug connection: %v", err)
s.log.Error("cannot establish debug connection", "error", err)
continue
}
go s.handleConnection(conn)
@ -58,7 +60,7 @@ func (s *Server) handleConnection(conn net.Conn) {
writer := bufio.NewWriter(conn)
defer func() {
if err := conn.Close(); err != nil {
log.Printf("error while closing debug connection: %v", err)
s.log.Error("error while closing debug connection", "error", err)
}
}()
// Read, execute, and respond commands of a session.
@ -78,7 +80,7 @@ func (s *Server) handleConnection(conn net.Conn) {
}
err = s.writeReplies(writer, replies)
if err != nil {
log.Printf("cannot write replies: %v", err)
s.log.Error("cannot write replies", "error", err)
return
}
}

View File

@ -4,13 +4,13 @@ import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"runtime"
"strings"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/cmd/statusd/debug"
"github.com/status-im/status-go/geth/api"
"github.com/status-im/status-go/geth/common"
@ -70,13 +70,16 @@ var (
syncAndExit = flag.Int("sync-and-exit", -1, "Timeout in minutes for blockchain sync and exit, zero means no timeout unless sync is finished")
)
// All general log messages in this package should be routed through this logger.
var logger = log.New("package", "status-go/cmd/statusd")
func main() {
flag.Usage = printUsage
flag.Parse()
config, err := makeNodeConfig()
if err != nil {
log.Fatalf("Making config failed: %v", err)
logger.Error("Making config failed", "error", err)
return
}
@ -88,7 +91,7 @@ func main() {
backend := api.NewStatusBackend()
err = backend.StartNode(config)
if err != nil {
log.Fatalf("Node start failed: %v", err)
logger.Error("Node start failed", "error", err)
return
}
@ -98,7 +101,7 @@ func main() {
if *cliEnabled {
err := startDebug(backend)
if err != nil {
log.Fatalf("Starting debugging CLI server failed: %v", err)
logger.Error("Starting debugging CLI server failed", "error", err)
return
}
}
@ -124,7 +127,7 @@ func main() {
node, err := backend.NodeManager().Node()
if err != nil {
log.Fatalf("Getting node failed: %v", err)
logger.Error("Getting node failed", "error", err)
return
}
@ -141,11 +144,12 @@ func startDebug(backend *api.StatusBackend) error {
// startCollectingStats collects various stats about the node and other protocols like Whisper.
func startCollectingStats(interruptCh <-chan struct{}, nodeManager common.NodeManager) {
log.Printf("Starting stats on %v", *statsAddr)
logger.Info("Starting stats", "stats", *statsAddr)
node, err := nodeManager.Node()
if err != nil {
log.Printf("Failed to run metrics because could not get node: %v", err)
logger.Error("Failed to run metrics because could not get node", "error", err)
return
}
@ -153,7 +157,7 @@ func startCollectingStats(interruptCh <-chan struct{}, nodeManager common.NodeMa
defer cancel()
go func() {
if err := nodemetrics.SubscribeServerEvents(ctx, node); err != nil {
log.Printf("Failed to subscribe server events: %v", err)
logger.Error("Failed to subscribe server events", "error", err)
}
}()
@ -166,7 +170,7 @@ func startCollectingStats(interruptCh <-chan struct{}, nodeManager common.NodeMa
}
if err := server.Shutdown(context.TODO()); err != nil {
log.Printf("Failed to shutdown metrics server: %v", err)
logger.Error("Failed to shutdown metrics server", "error", err)
}
}()
go func() {
@ -180,7 +184,7 @@ func startCollectingStats(interruptCh <-chan struct{}, nodeManager common.NodeMa
switch err {
case http.ErrServerClosed:
default:
log.Printf("Metrics server failed: %v", err)
logger.Error("Metrics server failed", "error", err)
}
}()
@ -297,9 +301,9 @@ func haltOnInterruptSignal(nodeManager common.NodeManager) <-chan struct{} {
defer signal.Stop(signalCh)
<-signalCh
close(interruptCh)
log.Println("Got interrupt, shutting down...")
logger.Info("Got interrupt, shutting down...")
if err := nodeManager.StopNode(); err != nil {
log.Printf("Failed to stop node: %v", err.Error())
logger.Error("Failed to stop node", "error", err)
os.Exit(1)
}
}()

View File

@ -2,7 +2,6 @@ package main
import (
"context"
"log"
"time"
"github.com/status-im/status-go/geth/common"
@ -21,7 +20,8 @@ func createContextFromTimeout(timeout int) (context.Context, context.CancelFunc)
// that can be used in `os.Exit` to exit immediately when the function returns.
// The special exit code `-1` is used if execution was interrupted.
func syncAndStopNode(interruptCh <-chan struct{}, nodeManager common.NodeManager, timeout int) (exitCode int) {
log.Printf("syncAndStopNode: node will synchronize the chain and exit (timeout %d mins)", timeout)
logger.Info("syncAndStopNode: node will synchronize the chain and exit", "timeoutInMins", timeout)
ctx, cancel := createContextFromTimeout(timeout)
defer cancel()
@ -37,7 +37,7 @@ func syncAndStopNode(interruptCh <-chan struct{}, nodeManager common.NodeManager
select {
case err := <-errSync:
log.Printf("syncAndStopNode: failed to sync the chain: %v", err)
logger.Error("syncAndStopNode: failed to sync the chain", "error", err)
exitCode = 1
case <-doneSync:
case <-interruptCh:
@ -47,7 +47,7 @@ func syncAndStopNode(interruptCh <-chan struct{}, nodeManager common.NodeManager
}
if err := nodeManager.StopNode(); err != nil {
log.Printf("syncAndStopNode: failed to stop the node: %v", err)
logger.Error("syncAndStopNode: failed to stop the node", "error", err)
return 1
}
return

View File

@ -6,9 +6,9 @@ import (
"github.com/NaySoftware/go-fcm"
"github.com/ethereum/go-ethereum/accounts/keystore"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/jail"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/params"
"github.com/status-im/status-go/geth/transactions"
)
@ -16,6 +16,7 @@ import (
// StatusAPI provides API to access Status related functionality.
type StatusAPI struct {
b *StatusBackend
log log.Logger
}
// NewStatusAPI creates a new StatusAPI instance
@ -28,6 +29,7 @@ func NewStatusAPI() *StatusAPI {
func NewStatusAPIWithBackend(b *StatusBackend) *StatusAPI {
return &StatusAPI{
b: b,
log: log.New("package", "status-go/geth/api.StatusAPI"),
}
}
@ -198,14 +200,14 @@ func (api *StatusAPI) SetJailBaseJS(js string) {
// Notify sends a push notification to the device with the given token.
// @deprecated
func (api *StatusAPI) Notify(token string) string {
log.Debug("Notify", "token", token)
api.log.Debug("Notify", "token", token)
message := "Hello World1"
tokens := []string{token}
err := api.b.newNotification().Send(message, fcm.NotificationPayload{}, tokens...)
if err != nil {
log.Error("Notify failed:", err)
api.log.Error("Notify failed", "error", err)
}
return token
@ -213,11 +215,11 @@ func (api *StatusAPI) Notify(token string) string {
// NotifyUsers send notifications to users.
func (api *StatusAPI) NotifyUsers(message string, payload fcm.NotificationPayload, tokens ...string) error {
log.Debug("Notify", "tokens", tokens)
api.log.Debug("Notify", "tokens", tokens)
err := api.b.newNotification().Send(message, payload, tokens...)
if err != nil {
log.Error("Notify failed:", err)
api.log.Error("Notify failed", "error", err)
}
return err
@ -240,7 +242,7 @@ func (api *StatusAPI) ConnectionChange(typ string, expensive bool) {
func (api *StatusAPI) AppStateChange(state string) {
appState, err := ParseAppState(state)
if err != nil {
log.Error("AppStateChange failed, ignoring it.", "err", err)
log.Error("AppStateChange failed, ignoring", "error", err)
return // and do nothing
}
api.b.AppStateChange(appState)

View File

@ -6,10 +6,11 @@ import (
"sync"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/geth/account"
"github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/jail"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/node"
"github.com/status-im/status-go/geth/notifications/push/fcm"
"github.com/status-im/status-go/geth/params"
@ -31,6 +32,7 @@ type StatusBackend struct {
jailManager jail.Manager
newNotification common.NotificationConstructor
connectionState ConnectionState
log log.Logger
}
// NewStatusBackend create a new NewStatusBackend instance
@ -49,6 +51,7 @@ func NewStatusBackend() *StatusBackend {
jailManager: jailManager,
txQueueManager: txQueueManager,
newNotification: notificationManager,
log: log.New("package", "status-go/geth/api.StatusBackend"),
}
}
@ -111,12 +114,12 @@ func (b *StatusBackend) startNode(config *params.NodeConfig) (err error) {
// on rpc client being created
b.txQueueManager.Start()
if err := b.registerHandlers(); err != nil {
log.Error("Handler registration failed", "err", err)
b.log.Error("Handler registration failed", "err", err)
}
if err := b.accountManager.ReSelectAccount(); err != nil {
log.Error("Reselect account failed", "err", err)
b.log.Error("Reselect account failed", "err", err)
}
log.Info("Account reselected")
b.log.Info("Account reselected")
signal.Send(signal.Envelope{Type: signal.EventNodeReady})
return nil
}
@ -230,7 +233,7 @@ func (b *StatusBackend) registerHandlers() error {
// ConnectionChange handles network state changes logic.
func (b *StatusBackend) ConnectionChange(state ConnectionState) {
log.Info("Network state change", "old", b.connectionState, "new", state)
b.log.Info("Network state change", "old", b.connectionState, "new", state)
b.connectionState = state
// logic of handling state changes here
@ -239,7 +242,7 @@ func (b *StatusBackend) ConnectionChange(state ConnectionState) {
// AppStateChange handles app state changes (background/foreground).
func (b *StatusBackend) AppStateChange(state AppState) {
log.Info("App State changed.", "new-state", state)
b.log.Info("App State changed.", "new-state", state)
// TODO: put node in low-power mode if the app is in background (or inactive)
// and normal mode if the app is in foreground.

View File

@ -15,8 +15,8 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/pborman/uuid"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/static"
)
@ -33,6 +33,9 @@ var (
ErrInvalidAccountAddressOrKey = errors.New("cannot parse address or key to valid account address")
)
// All general log messages in this package should be routed through this logger.
var logger = log.New("package", "status-go/geth/common")
// ParseAccountString parses hex encoded string and returns is as accounts.Account.
func ParseAccountString(account string) (accounts.Account, error) {
// valid address, convert to account
@ -75,7 +78,7 @@ func ImportTestAccount(keystoreDir, accountFile string) error {
dst := filepath.Join(keystoreDir, accountFile)
err := ioutil.WriteFile(dst, static.MustAsset("keys/"+accountFile), 0644)
if err != nil {
log.Warn("cannot copy test account PK", "error", err)
logger.Warn("cannot copy test account PK", "error", err)
}
return err

View File

@ -1,52 +0,0 @@
# log [![GoDoc](https://godoc.org/github.com/status-im/status-go/geth/log?status.png)](https://godoc.org/github.com/status-im/status-go/geth/log)
Package log implements logger for status-go.
Download:
```shell
go get github.com/status-im/status-go/geth/log
```
* * *
Package log implements logger for status-go.
This logger handles two loggers - it's own and ethereum-go logger.
Both are used as "singletons" - using global shared variables.
## Usage
First, import package into your code:
```
import "github.com/status-im/status-go/geth/log
```
Then simply use `Info/Error/Debug/etc` functions to log at desired level:
```
log.Info("Info message")
log.Debug("Debug message")
log.Error("Error message")
```
Slightly more complicated logging:
```
log.Warn("abnormal conn rate", "rate", curRate, "low", lowRate, "high", highRate)
```
Note, in this case parameters should be in in pairs (key, value).
This logger is based upon log15-logger, so see its documentation for advanced usage: https://github.com/inconshreveable/log15
## Initialization
By default logger is set to log to stdout with Error level via `init()` function.
You may change both level and file output by `log.SetLevel()` and `log.SetLogFile()` functions:
```
log.SetLevel("DEBUG")
log.SetLogFile("/path/to/geth.log")
```
* * *
Automatically generated by [autoreadme](https://github.com/jimmyfrasche/autoreadme) on 2017.09.15

View File

@ -1,136 +0,0 @@
/*Package log implements logger for status-go.
This logger handles two loggers - it's own and ethereum-go logger.
Both are used as "singletons" - using global shared variables.
Usage
First, import package into your code:
import "github.com/status-im/status-go/geth/log
Then simply use `Info/Error/Debug/etc` functions to log at desired level:
log.Info("Info message")
log.Debug("Debug message")
log.Error("Error message")
Slightly more complicated logging:
log.Warn("abnormal conn rate", "rate", curRate, "low", lowRate, "high", highRate)
Note, in this case parameters should be in in pairs (key, value).
This logger is based upon log15-logger, so see its documentation for advanced usage: https://github.com/inconshreveable/log15
Initialization
By default logger is set to log to stdout with Error level via `init()` function.
You may change both level and file output by `log.SetLevel()` and `log.SetLogFile()` functions:
log.SetLevel("DEBUG")
log.SetLogFile("/path/to/geth.log")
*/
package log
//go:generate autoreadme -f
import (
"fmt"
"os"
"strings"
"github.com/ethereum/go-ethereum/log"
)
// Logger is a wrapper around log.Logger.
type Logger struct {
log.Logger
level log.Lvl
handler log.Handler
}
// logger is package scope instance of Logger
var logger = Logger{
Logger: log.New("geth", "StatusIM"),
level: log.LvlError,
handler: log.StreamHandler(os.Stdout, log.TerminalFormat(true)),
}
func init() {
setHandler(logger.level, logger.handler)
}
// SetLevel inits status and ethereum-go logging packages,
// enabling logging and setting up proper log level.
//
// Our log levels are in form "DEBUG|ERROR|WARN|etc", while
// ethereum-go expects names in lower case: "debug|error|warn|etc".
func SetLevel(level string) {
lvl := levelFromString(level)
logger.level = lvl
setHandler(lvl, logger.handler)
}
// SetLogFile configures logger to write output into file.
// This call preserves current logging level.
func SetLogFile(filename string) error {
handler, err := log.FileHandler(filename, log.TerminalFormat(false))
if err != nil {
return err
}
logger.handler = handler
setHandler(logger.level, handler)
return nil
}
func levelFromString(level string) log.Lvl {
lvl, err := log.LvlFromString(strings.ToLower(level))
if err != nil {
fmt.Fprintf(os.Stderr, "Incorrect log level: %s, using defaults\n", level)
lvl = log.LvlInfo
}
return lvl
}
// setHandler is a helper that allows log (re)initialization
// with different level and handler. Useful for testing.
func setHandler(lvl log.Lvl, handler log.Handler) {
h := log.LvlFilterHandler(lvl, handler)
logger.SetHandler(h)
log.Root().SetHandler(h) // ethereum-go logger
}
// Trace is a package scope alias for logger.Trace
func Trace(msg string, ctx ...interface{}) {
logger.Trace(msg, ctx...)
}
// Debug is a package scope for logger.Debug
func Debug(msg string, ctx ...interface{}) {
logger.Debug(msg, ctx...)
}
// Info is a package scope for logger.Info
func Info(msg string, ctx ...interface{}) {
logger.Info(msg, ctx...)
}
// Warn is a package scope for logger.Warn
func Warn(msg string, ctx ...interface{}) {
logger.Warn(msg, ctx...)
}
// Error is a package scope for logger.Error
func Error(msg string, ctx ...interface{}) {
logger.Error(msg, ctx...)
}
// Crit is a package scope for logger.Crit
func Crit(msg string, ctx ...interface{}) {
logger.Crit(msg, ctx...)
}

View File

@ -1,74 +0,0 @@
package log
import (
"bytes"
"io/ioutil"
"testing"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
)
const (
trace = "trace log message\n"
debug = "debug log message\n"
info = "info log message\n"
warn = "warning log message\n"
err = "error log message\n"
)
func TestLogLevels(t *testing.T) {
var tests = []struct {
lvl log.Lvl
out string
}{
{log.LvlTrace, trace + debug + info + warn + err},
{log.LvlDebug, debug + info + warn + err},
{log.LvlInfo, info + warn + err},
{log.LvlWarn, warn + err},
{log.LvlError, err},
}
var buf bytes.Buffer
// log-compatible handler that writes log in the buffer
handler := log.FuncHandler(func(r *log.Record) error {
_, err := buf.Write([]byte(r.Msg))
return err
})
for _, test := range tests {
buf.Reset()
setHandler(test.lvl, handler)
Trace(trace)
Debug(debug)
Info(info)
Warn(warn)
Error(err)
require.Equal(t, test.out, buf.String())
}
}
func TestLogFile(t *testing.T) {
file, err := ioutil.TempFile("", "statusim_log_test")
require.NoError(t, err)
defer file.Close() //nolint: errcheck
// setup log
SetLevel("INFO")
err = SetLogFile(file.Name())
require.NoError(t, err)
// test log output to file
Info(info)
Debug(debug)
data, err := ioutil.ReadAll(file)
require.NoError(t, err)
got := string(data)
require.Contains(t, got, info)
require.NotContains(t, got, debug)
}

View File

@ -8,9 +8,10 @@ import (
"fmt"
"time"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p/discover"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/log"
)
const (
@ -28,11 +29,15 @@ var (
// PublicAPI defines a MailServer public API.
type PublicAPI struct {
provider ServiceProvider
log log.Logger
}
// NewPublicAPI returns a new PublicAPI.
func NewPublicAPI(provider ServiceProvider) *PublicAPI {
return &PublicAPI{provider}
return &PublicAPI{
provider: provider,
log: log.New("package", "status-go/geth/mailservice.PublicAPI"),
}
}
// MessagesRequest is a payload send to a MailServer to get messages.
@ -66,7 +71,7 @@ func setMessagesRequestDefaults(r *MessagesRequest) {
// RequestMessages sends a request for historic messages to a MailServer.
func (api *PublicAPI) RequestMessages(_ context.Context, r MessagesRequest) (bool, error) {
log.Info("RequestMessages", "request", r)
api.log.Info("RequestMessages", "request", r)
setMessagesRequestDefaults(&r)

View File

@ -12,10 +12,11 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/les"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p/discover"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/mailservice"
"github.com/status-im/status-go/geth/params"
"github.com/status-im/status-go/geth/rpc"
@ -50,11 +51,14 @@ type NodeManager struct {
whisperService *whisper.Whisper // reference to Whisper service
lesService *les.LightEthereum // reference to LES service
rpcClient *rpc.Client // reference to RPC client
log log.Logger
}
// NewNodeManager makes new instance of node manager
func NewNodeManager() *NodeManager {
return &NodeManager{}
return &NodeManager{
log: log.New("package", "status-go/geth/node.NodeManager"),
}
}
// StartNode start Status node, fails if node is already started
@ -69,7 +73,6 @@ func (m *NodeManager) startNode(config *params.NodeConfig) error {
if err := m.isNodeAvailable(); err == nil {
return ErrNodeExists
}
m.initLog(config)
ethNode, err := MakeNode(config)
if err != nil {
@ -95,7 +98,7 @@ func (m *NodeManager) startNode(config *params.NodeConfig) error {
m.rpcClient, err = rpc.NewClient(localRPCClient, m.config.UpstreamConfig)
}
if err != nil {
log.Error("Failed to create an RPC client", "error", err)
m.log.Error("Failed to create an RPC client", "error", err)
return RPCClientError(err)
}
return nil
@ -138,7 +141,7 @@ func (m *NodeManager) ResetChainData(config *params.NodeConfig) error {
}
err := os.RemoveAll(chainDataDir)
if err == nil {
log.Info("Chain data has been removed", "dir", chainDataDir)
m.log.Info("Chain data has been removed", "dir", chainDataDir)
}
return err
}
@ -178,17 +181,17 @@ func (m *NodeManager) populateStaticPeers() error {
return err
}
if !m.config.ClusterConfig.Enabled {
log.Info("Static peers are disabled")
m.log.Info("Static peers are disabled")
return nil
}
for _, enode := range m.config.ClusterConfig.StaticNodes {
err := m.addPeer(enode)
if err != nil {
log.Warn("Static peer addition failed", "error", err)
m.log.Warn("Static peer addition failed", "error", err)
continue
}
log.Info("Static peer added", "enode", enode)
m.log.Info("Static peer added", "enode", enode)
}
return nil
@ -196,7 +199,7 @@ func (m *NodeManager) populateStaticPeers() error {
func (m *NodeManager) removeStaticPeers() error {
if !m.config.ClusterConfig.Enabled {
log.Info("Static peers are disabled")
m.log.Info("Static peers are disabled")
return nil
}
server := m.node.Server()
@ -206,10 +209,10 @@ func (m *NodeManager) removeStaticPeers() error {
for _, enode := range m.config.ClusterConfig.StaticNodes {
err := m.removePeer(enode)
if err != nil {
log.Warn("Static peer deletion failed", "error", err)
m.log.Warn("Static peer deletion failed", "error", err)
return err
}
log.Info("Static peer deleted", "enode", enode)
m.log.Info("Static peer deleted", "enode", enode)
}
return nil
}
@ -283,7 +286,7 @@ func (m *NodeManager) LightEthereumService() (*les.LightEthereum, error) {
}
if m.lesService == nil {
if err := m.node.Service(&m.lesService); err != nil {
log.Warn("Cannot obtain LES service", "error", err)
m.log.Warn("Cannot obtain LES service", "error", err)
return nil, ErrInvalidLightEthereumService
}
}
@ -303,7 +306,7 @@ func (m *NodeManager) WhisperService() (*whisper.Whisper, error) {
}
if m.whisperService == nil {
if err := m.node.Service(&m.whisperService); err != nil {
log.Warn("Cannot obtain whisper service", "error", err)
m.log.Warn("Cannot obtain whisper service", "error", err)
return nil, ErrInvalidWhisperService
}
}
@ -361,19 +364,6 @@ func (m *NodeManager) RPCClient() *rpc.Client {
return m.rpcClient
}
// initLog initializes global logger parameters based on
// provided node configurations.
func (m *NodeManager) initLog(config *params.NodeConfig) {
log.SetLevel(config.LogLevel)
if config.LogFile != "" {
err := log.SetLogFile(config.LogFile)
if err != nil {
fmt.Println("Failed to open log file, using stdout")
}
}
}
// isNodeAvailable check if we have a node running and make sure is fully started
func (m *NodeManager) isNodeAvailable() error {
if m.node == nil || m.node.Server() == nil {
@ -410,7 +400,7 @@ func (m *NodeManager) ensureSync(ctx context.Context) error {
progress := downloader.Progress()
if m.PeerCount() > 0 && progress.CurrentBlock >= progress.HighestBlock {
log.Debug("Synchronization completed", "current block", progress.CurrentBlock, "highest block", progress.HighestBlock)
m.log.Debug("Synchronization completed", "current block", progress.CurrentBlock, "highest block", progress.HighestBlock)
return nil
}
@ -426,22 +416,22 @@ func (m *NodeManager) ensureSync(ctx context.Context) error {
return errors.New("timeout during node synchronization")
case <-ticker.C:
if m.PeerCount() == 0 {
log.Debug("No established connections with any peers, continue waiting for a sync")
m.log.Debug("No established connections with any peers, continue waiting for a sync")
continue
}
if downloader.Synchronising() {
log.Debug("Synchronization is in progress")
m.log.Debug("Synchronization is in progress")
continue
}
progress = downloader.Progress()
if progress.CurrentBlock >= progress.HighestBlock {
log.Info("Synchronization completed", "current block", progress.CurrentBlock, "highest block", progress.HighestBlock)
m.log.Info("Synchronization completed", "current block", progress.CurrentBlock, "highest block", progress.HighestBlock)
return nil
}
log.Debug("Synchronization is not finished", "current", progress.CurrentBlock, "highest", progress.HighestBlock)
m.log.Debug("Synchronization is not finished", "current", progress.CurrentBlock, "highest", progress.HighestBlock)
case <-progressTicker.C:
progress = downloader.Progress()
log.Warn("Synchronization is not finished", "current", progress.CurrentBlock, "highest", progress.HighestBlock)
m.log.Warn("Synchronization is not finished", "current", progress.CurrentBlock, "highest", progress.HighestBlock)
}
}
}

View File

@ -14,13 +14,13 @@ import (
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/les"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/whisper/mailserver"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/params"
shhmetrics "github.com/status-im/status-go/metrics/whisper"
)
@ -35,6 +35,9 @@ var (
ErrNodeStartFailure = errors.New("error starting p2p node")
)
// All general log messages in this package should be routed through this logger.
var logger = log.New("package", "status-go/geth/node")
// MakeNode create a geth node entity
func MakeNode(config *params.NodeConfig) (*node.Node, error) {
// make sure data directory exists
@ -51,10 +54,10 @@ func MakeNode(config *params.NodeConfig) (*node.Node, error) {
stackConfig := defaultEmbeddedNodeConfig(config)
if len(config.NodeKeyFile) > 0 {
log.Info("Loading private key file", "file", config.NodeKeyFile)
logger.Info("Loading private key file", "file", config.NodeKeyFile)
pk, err := crypto.LoadECDSA(config.NodeKeyFile)
if err != nil {
log.Warn(fmt.Sprintf("Failed loading private key file '%s': %v", config.NodeKeyFile, err))
logger.Error("Failed loading private key file", "file", config.NodeKeyFile, "error", err)
}
// override node's private key
@ -128,7 +131,7 @@ func defaultEmbeddedNodeConfig(config *params.NodeConfig) *node.Config {
// activateEthService configures and registers the eth.Ethereum service with a given node.
func activateEthService(stack *node.Node, config *params.NodeConfig) error {
if !config.LightEthConfig.Enabled {
log.Info("LES protocol is disabled")
logger.Info("LES protocol is disabled")
return nil
}
@ -157,8 +160,9 @@ func activateEthService(stack *node.Node, config *params.NodeConfig) error {
// activateShhService configures Whisper and adds it to the given node.
func activateShhService(stack *node.Node, config *params.NodeConfig) error {
if !config.WhisperConfig.Enabled {
log.Info("SHH protocol is disabled")
logger.Info("SHH protocol is disabled")
return nil
}
@ -181,7 +185,7 @@ func activateShhService(stack *node.Node, config *params.NodeConfig) error {
}
}
log.Info("Register MailServer")
logger.Info("Register MailServer")
var mailServer mailserver.WMailServer
whisperService.RegisterServer(&mailServer)

View File

@ -11,7 +11,7 @@ import (
"strings"
"github.com/ethereum/go-ethereum/core"
"github.com/status-im/status-go/geth/log"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/static"
)
@ -271,6 +271,8 @@ type NodeConfig struct {
// handshake phase, counted separately for inbound and outbound connections.
MaxPendingPeers int
log log.Logger
// LogFile is filename where exposed logs get written to
LogFile string
@ -318,6 +320,7 @@ func NewNodeConfig(dataDir string, clstrCfgFile string, networkID uint64, devMod
MaxPeers: MaxPeers,
MaxPendingPeers: MaxPendingPeers,
IPCFile: IPCFile,
log: log.New("package", "status-go/geth/params.NodeConfig"),
LogFile: LogFile,
LogLevel: LogLevel,
LogToStderr: LogToStderr,
@ -450,7 +453,7 @@ func (c *NodeConfig) Save() error {
return err
}
log.Info(fmt.Sprintf("config file saved: %v", configFilePath))
c.log.Info("config file saved", "path", configFilePath)
return nil
}

View File

@ -5,7 +5,6 @@ import (
"encoding/json"
gethrpc "github.com/ethereum/go-ethereum/rpc"
"github.com/status-im/status-go/geth/log"
)
const (
@ -101,7 +100,7 @@ func (c *Client) callBatchMethods(ctx context.Context, msgs json.RawMessage) str
data, err := json.Marshal(responses)
if err != nil {
log.Error("Failed to marshal batch responses:", err)
c.log.Error("Failed to marshal batch responses:", "error", err)
return newErrorResponse(errInvalidMessageCode, err, defaultMsgID)
}

View File

@ -8,6 +8,7 @@ import (
"reflect"
"sync"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/geth/params"
gethrpc "github.com/ethereum/go-ethereum/rpc"
@ -30,6 +31,7 @@ type Client struct {
handlersMx sync.RWMutex // mx guards handlers
handlers map[string]Handler // locally registered handlers
log log.Logger
}
// NewClient initializes Client and tries to connect to both,
@ -41,6 +43,7 @@ func NewClient(client *gethrpc.Client, upstream params.UpstreamRPCConfig) (*Clie
c := Client{
local: client,
handlers: make(map[string]Handler),
log: log.New("package", "status-go/geth/rpc.Client"),
}
var err error

View File

@ -11,7 +11,7 @@ import (
"sync"
"github.com/status-im/status-go/geth/log"
"github.com/ethereum/go-ethereum/log"
)
const (
@ -43,6 +43,9 @@ type NodeCrashEvent struct {
Error error `json:"error"`
}
// All general log messages in this package should be routed through this logger.
var logger = log.New("package", "status-go/geth/signal")
// MarshalJSON implements the json.Marshaller interface.
func (e NodeCrashEvent) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
@ -77,7 +80,7 @@ func ResetDefaultNodeNotificationHandler() {
// TriggerDefaultNodeNotificationHandler triggers default notification handler (helpful in tests)
func TriggerDefaultNodeNotificationHandler(jsonEvent string) {
log.Info("Notification received", "event", jsonEvent)
logger.Info("Notification received", "event", jsonEvent)
}
// Send sends application signal (JSON, normally) upwards to application (via default notification handler)

View File

@ -2,15 +2,14 @@ package queue
import (
"errors"
"fmt"
"sync"
"time"
"github.com/ethereum/go-ethereum/accounts/keystore"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/geth/account"
"github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/log"
)
const (
@ -52,22 +51,27 @@ type TxQueue struct {
// when this channel is closed, all queue channels processing must cease (incoming queue, processing queued items etc)
stopped chan struct{}
stoppedGroup sync.WaitGroup // to make sure that all routines are stopped
log log.Logger
}
// New creates a transaction queue.
func New() *TxQueue {
log.Info("initializing transaction queue")
logger := log.New("package", "status-go/geth/transactions/queue.TxQueue")
logger.Info("initializing transaction queue")
return &TxQueue{
transactions: make(map[common.QueuedTxID]*common.QueuedTx),
inprogress: make(map[common.QueuedTxID]empty),
evictableIDs: make(chan common.QueuedTxID, DefaultTxQueueCap), // will be used to evict in FIFO
enqueueTicker: make(chan struct{}),
log: logger,
}
}
// Start starts enqueue and eviction loops
func (q *TxQueue) Start() {
log.Info("starting transaction queue")
q.log.Info("starting transaction queue")
if q.stopped != nil {
return
@ -80,7 +84,7 @@ func (q *TxQueue) Start() {
// Stop stops transaction enqueue and eviction loops
func (q *TxQueue) Stop() {
log.Info("stopping transaction queue")
q.log.Info("stopping transaction queue")
if q.stopped == nil {
return
@ -90,7 +94,7 @@ func (q *TxQueue) Stop() {
q.stoppedGroup.Wait()
q.stopped = nil
log.Info("finally stopped transaction queue")
q.log.Info("finally stopped transaction queue")
}
// evictionLoop frees up queue to accommodate another transaction item
@ -109,7 +113,7 @@ func (q *TxQueue) evictionLoop() {
case <-q.enqueueTicker: // when manually requested
evict()
case <-q.stopped:
log.Info("transaction queue's eviction loop stopped")
q.log.Info("transaction queue's eviction loop stopped")
q.stoppedGroup.Done()
return
}
@ -128,7 +132,7 @@ func (q *TxQueue) Reset() {
// Enqueue enqueues incoming transaction
func (q *TxQueue) Enqueue(tx *common.QueuedTx) error {
log.Info(fmt.Sprintf("enqueue transaction: %s", tx.ID))
q.log.Info("enqueue transaction", "ID", tx.ID)
q.mu.RLock()
if _, ok := q.transactions[tx.ID]; ok {
q.mu.RUnlock()
@ -137,17 +141,17 @@ func (q *TxQueue) Enqueue(tx *common.QueuedTx) error {
q.mu.RUnlock()
// we can't hold a lock in this part
log.Debug("notifying eviction loop")
q.log.Debug("notifying eviction loop")
q.enqueueTicker <- struct{}{} // notify eviction loop that we are trying to insert new item
q.evictableIDs <- tx.ID // this will block when we hit DefaultTxQueueCap
log.Debug("notified eviction loop")
q.log.Debug("notified eviction loop")
q.mu.Lock()
q.transactions[tx.ID] = tx
q.mu.Unlock()
// notify handler
log.Info("calling txEnqueueHandler")
q.log.Info("calling txEnqueueHandler")
return nil
}

View File

@ -8,9 +8,10 @@ import (
ethereum "github.com/ethereum/go-ethereum"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/core/types"
"github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/params"
"github.com/status-im/status-go/geth/transactions/queue"
)
@ -37,6 +38,7 @@ type Manager struct {
addrLock *AddrLocker
localNonce sync.Map
log log.Logger
}
// NewManager returns a new Manager.
@ -50,6 +52,7 @@ func NewManager(nodeManager common.NodeManager, accountManager common.AccountMan
completionTimeout: DefaultTxSendCompletionTimeout,
rpcCallTimeout: defaultTimeout,
localNonce: sync.Map{},
log: log.New("package", "status-go/geth/transactions.Manager"),
}
}
@ -61,14 +64,14 @@ func (m *Manager) DisableNotificactions() {
// Start starts accepting new transactions into the queue.
func (m *Manager) Start() {
log.Info("start Manager")
m.log.Info("start Manager")
m.ethTxClient = NewEthTxClient(m.nodeManager.RPCClient())
m.txQueue.Start()
}
// Stop stops accepting new transactions into the queue.
func (m *Manager) Stop() {
log.Info("stop Manager")
m.log.Info("stop Manager")
m.txQueue.Stop()
}
@ -83,7 +86,7 @@ func (m *Manager) QueueTransaction(tx *common.QueuedTx) error {
if tx.Args.To != nil {
to = tx.Args.To.Hex()
}
log.Info("queue a new transaction", "id", tx.ID, "from", tx.Args.From.Hex(), "to", to)
m.log.Info("queue a new transaction", "id", tx.ID, "from", tx.Args.From.Hex(), "to", to)
if err := m.txQueue.Enqueue(tx); err != nil {
return err
}
@ -95,7 +98,7 @@ func (m *Manager) QueueTransaction(tx *common.QueuedTx) error {
func (m *Manager) txDone(tx *common.QueuedTx, hash gethcommon.Hash, err error) {
if err := m.txQueue.Done(tx.ID, hash, err); err == queue.ErrQueuedTxIDNotFound {
log.Warn("transaction is already removed from a queue", tx.ID)
m.log.Warn("transaction is already removed from a queue", "ID", tx.ID)
return
}
if m.notify {
@ -106,7 +109,7 @@ func (m *Manager) txDone(tx *common.QueuedTx, hash gethcommon.Hash, err error) {
// WaitForTransaction adds a transaction to the queue and blocks
// until it's completed, discarded or times out.
func (m *Manager) WaitForTransaction(tx *common.QueuedTx) common.TransactionResult {
log.Info("wait for transaction", "id", tx.ID)
m.log.Info("wait for transaction", "id", tx.ID)
// now wait up until transaction is:
// - completed (via CompleteQueuedTransaction),
// - discarded (via DiscardQueuedTransaction)
@ -123,14 +126,14 @@ func (m *Manager) WaitForTransaction(tx *common.QueuedTx) common.TransactionResu
// CompleteTransaction instructs backend to complete sending of a given transaction.
func (m *Manager) CompleteTransaction(id common.QueuedTxID, password string) (hash gethcommon.Hash, err error) {
log.Info("complete transaction", "id", id)
m.log.Info("complete transaction", "id", id)
tx, err := m.txQueue.Get(id)
if err != nil {
log.Warn("error getting a queued transaction", "err", err)
m.log.Warn("error getting a queued transaction", "err", err)
return hash, err
}
if err := m.txQueue.LockInprogress(id); err != nil {
log.Warn("can't process transaction", "err", err)
m.log.Warn("can't process transaction", "err", err)
return hash, err
}
config, err := m.nodeManager.NodeConfig()
@ -143,7 +146,7 @@ func (m *Manager) CompleteTransaction(id common.QueuedTxID, password string) (ha
return hash, err
}
hash, err = m.completeTransaction(config, account, tx)
log.Info("finally completed transaction", "id", tx.ID, "hash", hash, "err", err)
m.log.Info("finally completed transaction", "id", tx.ID, "hash", hash, "err", err)
m.txDone(tx, hash, err)
return hash, err
}
@ -151,24 +154,24 @@ func (m *Manager) CompleteTransaction(id common.QueuedTxID, password string) (ha
func (m *Manager) validateAccount(config *params.NodeConfig, tx *common.QueuedTx, password string) (*common.SelectedExtKey, error) {
selectedAccount, err := m.accountManager.SelectedAccount()
if err != nil {
log.Warn("failed to get a selected account", "err", err)
m.log.Warn("failed to get a selected account", "err", err)
return nil, err
}
// make sure that only account which created the tx can complete it
if tx.Args.From.Hex() != selectedAccount.Address.Hex() {
log.Warn("queued transaction does not belong to the selected account", "err", queue.ErrInvalidCompleteTxSender)
m.log.Warn("queued transaction does not belong to the selected account", "err", queue.ErrInvalidCompleteTxSender)
return nil, queue.ErrInvalidCompleteTxSender
}
_, err = m.accountManager.VerifyAccountPassword(config.KeyStoreDir, selectedAccount.Address.String(), password)
if err != nil {
log.Warn("failed to verify account", "account", selectedAccount.Address.String(), "error", err.Error())
m.log.Warn("failed to verify account", "account", selectedAccount.Address.String(), "error", err)
return nil, err
}
return selectedAccount, nil
}
func (m *Manager) completeTransaction(config *params.NodeConfig, selectedAccount *common.SelectedExtKey, queuedTx *common.QueuedTx) (hash gethcommon.Hash, err error) {
log.Info("complete transaction", "id", queuedTx.ID)
m.log.Info("complete transaction", "id", queuedTx.ID)
m.addrLock.LockAddr(queuedTx.Args.From)
var localNonce uint64
if val, ok := m.localNonce.Load(queuedTx.Args.From); ok {
@ -228,14 +231,14 @@ func (m *Manager) completeTransaction(config *params.NodeConfig, selectedAccount
return hash, err
}
if gas < defaultGas {
log.Info("default gas will be used. estimated gas", gas, "is lower than", defaultGas)
m.log.Info("default gas will be used. estimated gas", gas, "is lower than", defaultGas)
gas = defaultGas
}
} else {
gas = uint64(*args.Gas)
}
log.Info(
m.log.Info(
"preparing raw transaction",
"from", args.From.Hex(),
"to", toAddr.Hex(),
@ -301,7 +304,7 @@ func (m *Manager) DiscardTransactions(ids []common.QueuedTxID) map[common.Queued
// SendTransactionRPCHandler is a handler for eth_sendTransaction method.
// It accepts one param which is a slice with a map of transaction params.
func (m *Manager) SendTransactionRPCHandler(ctx context.Context, args ...interface{}) (interface{}, error) {
log.Info("SendTransactionRPCHandler called")
m.log.Info("SendTransactionRPCHandler called")
// TODO(adam): it's a hack to parse arguments as common.RPCCall can do that.
// We should refactor parsing these params to a separate struct.
rpcCall := common.RPCCall{Params: args}

View File

@ -7,13 +7,16 @@ import (
"os"
"github.com/NaySoftware/go-fcm"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/params"
"github.com/status-im/status-go/profiling"
"gopkg.in/go-playground/validator.v9"
)
// All general log messages in this package should be routed through this logger.
var logger = log.New("package", "status-go/lib")
//GenerateConfig for status node
//export GenerateConfig
func GenerateConfig(datadir *C.char, networkID C.int, devMode C.int) *C.char {
@ -209,7 +212,7 @@ func CompleteTransaction(id, password *C.char) *C.char {
}
outBytes, err := json.Marshal(out)
if err != nil {
log.Error("failed to marshal CompleteTransaction output", "error", err.Error())
logger.Error("failed to marshal CompleteTransaction output", "error", err)
return makeJSONResponse(err)
}
@ -248,7 +251,7 @@ func CompleteTransactions(ids, password *C.char) *C.char {
outBytes, err := json.Marshal(out)
if err != nil {
log.Error("failed to marshal CompleteTransactions output", "error", err.Error())
logger.Error("failed to marshal CompleteTransactions output", "error", err)
return makeJSONResponse(err)
}
@ -272,7 +275,7 @@ func DiscardTransaction(id *C.char) *C.char {
}
outBytes, err := json.Marshal(out)
if err != nil {
log.Error("failed to marshal DiscardTransaction output", "error", err.Error())
log.Error("failed to marshal DiscardTransaction output", "error", err)
return makeJSONResponse(err)
}
@ -310,7 +313,7 @@ func DiscardTransactions(ids *C.char) *C.char {
outBytes, err := json.Marshal(out)
if err != nil {
log.Error("failed to marshal DiscardTransactions output", "error", err.Error())
logger.Error("failed to marshal DiscardTransactions output", "error", err)
return makeJSONResponse(err)
}
@ -413,7 +416,7 @@ func NotifyUsers(message, payloadJSON, tokensArray *C.char) (outCBytes *C.char)
outBytes, err = json.Marshal(out)
if err != nil {
log.Error("failed to marshal Notify output", "error", err.Error())
logger.Error("failed to marshal Notify output", "error", err)
outCBytes = makeJSONResponse(err)
return
}

View File

@ -6,8 +6,8 @@ import (
"encoding/json"
"expvar"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/status-im/status-go/geth/log"
)
var (
@ -28,7 +28,7 @@ func updateNodeInfo(node *node.Node) {
func updateNodePeers(node *node.Node) {
server := node.Server()
if server == nil {
log.Warn("Failed to get a server")
logger.Warn("Failed to get a server")
return
}

View File

@ -4,25 +4,24 @@ package node
import (
"github.com/ethereum/go-ethereum/node"
"github.com/status-im/status-go/geth/log"
)
func updateNodeInfo(node *node.Node) {
server := node.Server()
if server == nil {
log.Warn("Failed to get a server")
logger.Warn("Failed to get a server")
return
}
log.Debug("Metrics node_info", "id", server.NodeInfo().ID)
logger.Debug("Metrics node_info", "id", server.NodeInfo().ID)
}
func updateNodePeers(node *node.Node) {
server := node.Server()
if server == nil {
log.Warn("Failed to get a server")
logger.Warn("Failed to get a server")
return
}
log.Debug("Metrics node_peers", "remote_addresses", getNodePeerRemoteAddresses(server))
logger.Debug("Metrics node_peers", "remote_addresses", getNodePeerRemoteAddresses(server))
}

View File

@ -3,9 +3,9 @@
package node
import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/prometheus/client_golang/prometheus"
"github.com/status-im/status-go/geth/log"
)
var (

View File

@ -4,15 +4,19 @@ import (
"context"
"errors"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/status-im/status-go/geth/log"
)
// All general log messages in this package should be routed through this logger.
var logger = log.New("package", "status-go/metrics/node")
// SubscribeServerEvents subscribes to server and listens to
// PeerEventTypeAdd and PeerEventTypeDrop events.
func SubscribeServerEvents(ctx context.Context, node *node.Node) error {
server := node.Server()
if server == nil {
return errors.New("server is unavailable")
}
@ -20,7 +24,7 @@ func SubscribeServerEvents(ctx context.Context, node *node.Node) error {
ch := make(chan *p2p.PeerEvent, server.MaxPeers)
subscription := server.SubscribeEvents(ch)
log.Debug("Subscribed to server events")
logger.Debug("Subscribed to server events")
for {
select {
@ -31,7 +35,7 @@ func SubscribeServerEvents(ctx context.Context, node *node.Node) error {
}
case err := <-subscription.Err():
if err != nil {
log.Warn("Subscription failed", "err", err.Error())
logger.Warn("Subscription failed", "err", err)
}
subscription.Unsubscribe()
return err

View File

@ -4,14 +4,17 @@
package whisper
import (
"github.com/ethereum/go-ethereum/log"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/log"
)
// EnvelopeTracer traces incoming envelopes.
type EnvelopeTracer struct{}
// All general log messages in this package should be routed through this logger.
var logger = log.New("package", "status-go/metrics/whisper")
// Trace is called for every incoming envelope.
func (t *EnvelopeTracer) Trace(envelope *whisper.EnvelopeMeta) {
log.Debug("Received Whisper envelope", "hash", envelope.Hash, "data", envelope)
logger.Debug("Received Whisper envelope", "hash", envelope.Hash, "data", envelope)
}

View File

@ -644,6 +644,7 @@ type bintree struct {
Func func() (*asset, error)
Children map[string]*bintree
}
var _bintree = &bintree{nil, map[string]*bintree{
"config": &bintree{nil, map[string]*bintree{
"cluster.json": &bintree{configClusterJson, map[string]*bintree{}},
@ -729,4 +730,3 @@ func _filePath(dir, name string) string {
cannonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
}

View File

@ -5,8 +5,8 @@ import (
"testing"
"time"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/geth/api"
"github.com/status-im/status-go/geth/log"
. "github.com/status-im/status-go/t/utils"
"github.com/ethereum/go-ethereum/p2p"

View File

@ -11,8 +11,8 @@ import (
"github.com/ethereum/go-ethereum/event"
"github.com/stretchr/testify/suite"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/geth/api"
"github.com/status-im/status-go/geth/log"
. "github.com/status-im/status-go/t/utils"
)

View File

@ -9,8 +9,8 @@ import (
"testing"
"time"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/geth/api"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/node"
"github.com/status-im/status-go/geth/params"
"github.com/status-im/status-go/geth/signal"

View File

@ -7,10 +7,10 @@ import (
"testing"
"time"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/geth/account"
"github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/jail"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/node"
"github.com/status-im/status-go/geth/params"
e2e "github.com/status-im/status-go/t/e2e"

View File

@ -1,11 +1,13 @@
package e2e
import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/les"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/status-im/status-go/geth/api"
"github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/node"
"github.com/status-im/status-go/geth/signal"
"github.com/status-im/status-go/geth/transactions"
@ -19,6 +21,9 @@ type NodeManagerTestSuite struct {
NodeManager *node.NodeManager
}
// All general log messages in this package should be routed through this logger.
var logger = log.New("package", "status-go/t/e2e")
func init() {
for id := range TestNetworkNames {
nodeConfig, err := MakeTestNodeConfig(id)
@ -135,7 +140,7 @@ func (s *BackendTestSuite) TxQueueManager() *transactions.Manager {
}
func importTestAccounts(keyStoreDir string) (err error) {
log.Debug("Import accounts to", keyStoreDir)
logger.Debug("Import accounts to", "dir", keyStoreDir)
err = common.ImportTestAccount(keyStoreDir, GetAccount1PKFile())
if err != nil {

View File

@ -14,8 +14,8 @@ import (
"testing"
"time"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/geth/common"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/geth/params"
_ "github.com/stretchr/testify/suite" // required to register testify flags
@ -46,6 +46,9 @@ var (
params.RinkebyNetworkID: "Rinkeby",
params.StatusChainNetworkID: "StatusChain",
}
// All general log messages in this package should be routed through this logger.
logger = log.New("package", "status-go/t/utils")
)
func init() {
@ -127,18 +130,18 @@ func EnsureNodeSync(nodeManager common.NodeManager) {
continue
}
if nodeManager.PeerCount() == 0 {
log.Debug("No establishished connections with a peers, continue waiting for a sync")
logger.Debug("No establishished connections with a peers, continue waiting for a sync")
continue
}
if downloader.Synchronising() {
log.Debug("synchronization is in progress")
logger.Debug("synchronization is in progress")
continue
}
progress := downloader.Progress()
if progress.CurrentBlock >= progress.HighestBlock {
return
}
log.Debug(
logger.Debug(
fmt.Sprintf("synchronization is not finished yet: current block %d < highest block %d",
progress.CurrentBlock, progress.HighestBlock),
)