Browse Source

new logging

pull/1780/head
Anton Kaliaev 8 years ago
parent
commit
986bdd00a5
No known key found for this signature in database GPG Key ID: 7B6881D965918214
20 changed files with 141 additions and 102 deletions
  1. +1
    -3
      .gitignore
  2. +2
    -2
      client/grpc_client.go
  3. +1
    -1
      client/local_client.go
  4. +0
    -7
      client/log.go
  5. +4
    -4
      client/socket_client.go
  6. +7
    -4
      cmd/abci-cli/abci-cli.go
  7. +6
    -2
      cmd/counter/main.go
  8. +8
    -2
      cmd/dummy/main.go
  9. +6
    -2
      example/block_aware/block_aware_app.go
  10. +7
    -5
      example/block_aware/block_aware_test.go
  11. +10
    -1
      example/dummy/dummy_test.go
  12. +0
    -7
      example/dummy/log.go
  13. +20
    -10
      example/dummy/persistent_dummy.go
  14. +13
    -6
      example/example_test.go
  15. +42
    -29
      glide.lock
  16. +3
    -2
      glide.yaml
  17. +0
    -7
      server/log.go
  18. +7
    -7
      server/socket_server.go
  19. +0
    -0
      tests/test.sh
  20. +4
    -1
      tests/test_app/app.go

+ 1
- 3
.gitignore View File

@ -1,4 +1,2 @@
*.swp
*.swo
*.pyc
vendor
.glide

+ 2
- 2
client/grpc_client.go View File

@ -51,7 +51,7 @@ RETRY_LOOP:
if cli.mustConnect {
return err
}
log.Warn(fmt.Sprintf("abci.grpcClient failed to connect to %v. Retrying...\n", cli.addr))
cli.Logger.Error(fmt.Sprintf("abci.grpcClient failed to connect to %v. Retrying...\n", cli.addr))
time.Sleep(time.Second * 3)
continue RETRY_LOOP
}
@ -93,7 +93,7 @@ func (cli *grpcClient) StopForError(err error) {
}
cli.mtx.Unlock()
log.Warn(fmt.Sprintf("Stopping abci.grpcClient for error: %v", err.Error()))
cli.Logger.Error(fmt.Sprintf("Stopping abci.grpcClient for error: %v", err.Error()))
cli.Stop()
}


+ 1
- 1
client/local_client.go View File

@ -22,7 +22,7 @@ func NewLocalClient(mtx *sync.Mutex, app types.Application) *localClient {
mtx: mtx,
Application: app,
}
cli.BaseService = *cmn.NewBaseService(log, "localClient", cli)
cli.BaseService = *cmn.NewBaseService(nil, "localClient", cli)
return cli
}


+ 0
- 7
client/log.go View File

@ -1,7 +0,0 @@
package abcicli
import (
"github.com/tendermint/tmlibs/logger"
)
var log = logger.New("module", "abcicli")

+ 4
- 4
client/socket_client.go View File

@ -70,7 +70,7 @@ RETRY_LOOP:
if cli.mustConnect {
return err
}
log.Warn(fmt.Sprintf("abci.socketClient failed to connect to %v. Retrying...", cli.addr))
cli.Logger.Error(fmt.Sprintf("abci.socketClient failed to connect to %v. Retrying...", cli.addr))
time.Sleep(time.Second * 3)
continue RETRY_LOOP
}
@ -107,7 +107,7 @@ func (cli *socketClient) StopForError(err error) {
}
cli.mtx.Unlock()
log.Warn(fmt.Sprintf("Stopping abci.socketClient for error: %v", err.Error()))
cli.Logger.Error(fmt.Sprintf("Stopping abci.socketClient for error: %v", err.Error()))
cli.Stop()
}
@ -147,7 +147,7 @@ func (cli *socketClient) sendRequestsRoutine(conn net.Conn) {
cli.StopForError(fmt.Errorf("Error writing msg: %v", err))
return
}
// log.Debug("Sent request", "requestType", reflect.TypeOf(reqres.Request), "request", reqres.Request)
// cli.Logger.Debug("Sent request", "requestType", reflect.TypeOf(reqres.Request), "request", reqres.Request)
if _, ok := reqres.Request.Value.(*types.Request_Flush); ok {
err = w.Flush()
if err != nil {
@ -175,7 +175,7 @@ func (cli *socketClient) recvResponseRoutine(conn net.Conn) {
cli.StopForError(errors.New(r.Exception.Error))
return
default:
// log.Debug("Received response", "responseType", reflect.TypeOf(res), "response", res)
// cli.Logger.Debug("Received response", "responseType", reflect.TypeOf(res), "response", res)
err := cli.didRecvResponse(res)
if err != nil {
cli.StopForError(err)


+ 7
- 4
cmd/abci-cli/abci-cli.go View File

@ -6,13 +6,14 @@ import (
"errors"
"fmt"
"io"
"log"
stdlog "log"
"os"
"strings"
"github.com/tendermint/abci/client"
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/types"
"github.com/tendermint/abci/version"
"github.com/tendermint/tmlibs/log"
"github.com/urfave/cli"
)
@ -129,7 +130,7 @@ func main() {
app.Before = before
err := app.Run(os.Args)
if err != nil {
log.Fatal(err.Error())
stdlog.Fatal(err.Error())
}
}
@ -139,8 +140,10 @@ func before(c *cli.Context) error {
var err error
client, err = abcicli.NewClient(c.GlobalString("address"), c.GlobalString("abci"), false)
if err != nil {
log.Fatal(err.Error())
stdlog.Fatal(err.Error())
}
logger := log.NewTmLogger(os.Stdout)
client.SetLogger(log.With(logger, "module", "abci-client"))
}
return nil
}


+ 6
- 2
cmd/counter/main.go View File

@ -2,11 +2,13 @@ package main
import (
"flag"
"log"
stdlog "log"
"os"
"github.com/tendermint/abci/example/counter"
"github.com/tendermint/abci/server"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
)
func main() {
@ -20,8 +22,10 @@ func main() {
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
if err != nil {
log.Fatal(err.Error())
stdlog.Fatal(err.Error())
}
logger := log.NewTmLogger(os.Stdout)
srv.SetLogger(log.With(logger, "module", "abci-server"))
// Wait forever
cmn.TrapSignal(func() {


+ 8
- 2
cmd/dummy/main.go View File

@ -2,12 +2,14 @@ package main
import (
"flag"
"log"
stdlog "log"
"os"
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
)
func main() {
@ -17,19 +19,23 @@ func main() {
persistencePtr := flag.String("persist", "", "directory to use for a database")
flag.Parse()
logger := log.NewTmLogger(os.Stdout)
// Create the application - in memory or persisted to disk
var app types.Application
if *persistencePtr == "" {
app = dummy.NewDummyApplication()
} else {
app = dummy.NewPersistentDummyApplication(*persistencePtr)
app.(*dummy.PersistentDummyApplication).SetLogger(log.With(logger, "module", "dummy"))
}
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
if err != nil {
log.Fatal(err.Error())
stdlog.Fatal(err.Error())
}
srv.SetLogger(log.With(logger, "module", "abci-server"))
// Wait forever
cmn.TrapSignal(func() {


+ 6
- 2
example/block_aware/block_aware_app.go View File

@ -2,11 +2,13 @@ package main
import (
"flag"
"log"
stdlog "log"
"os"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
)
func main() {
@ -18,8 +20,10 @@ func main() {
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, NewChainAwareApplication())
if err != nil {
log.Fatal(err.Error())
stdlog.Fatal(err.Error())
}
logger := log.NewTmLogger(os.Stdout)
srv.SetLogger(log.With(logger, "module", "abci-server"))
// Wait forever
cmn.TrapSignal(func() {


+ 7
- 5
example/block_aware/block_aware_test.go View File

@ -1,33 +1,35 @@
package main
import (
"fmt"
"log"
"os"
"strconv"
"strings"
"testing"
"github.com/tendermint/abci/client"
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
"github.com/tendermint/tmlibs/log"
)
func TestChainAware(t *testing.T) {
app := NewChainAwareApplication()
logger := log.NewTmLogger(os.Stdout)
// Start the listener
srv, err := server.NewServer("unix://test.sock", "socket", app)
if err != nil {
t.Fatal(err)
}
srv.SetLogger(log.With(logger, "module", "abci-server"))
defer srv.Stop()
// Connect to the socket
client, err := abcicli.NewSocketClient("unix://test.sock", false)
if err != nil {
log.Fatal(fmt.Sprintf("Error starting socket client: %v", err.Error()))
t.Fatalf("Error starting socket client: %v", err.Error())
}
client.SetLogger(log.With(logger, "module", "abci-client"))
client.Start()
defer client.Stop()


+ 10
- 1
example/dummy/dummy_test.go View File

@ -3,6 +3,7 @@ package dummy
import (
"bytes"
"io/ioutil"
"os"
"sort"
"testing"
@ -10,9 +11,10 @@ import (
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
"github.com/tendermint/go-crypto"
crypto "github.com/tendermint/go-crypto"
"github.com/tendermint/merkleeyes/iavl"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
)
func testDummy(t *testing.T, app types.Application, tx []byte, key, value string) {
@ -211,10 +213,13 @@ func valsEqual(t *testing.T, vals1, vals2 []*types.Validator) {
func makeSocketClientServer(app types.Application, name string) (abcicli.Client, cmn.Service, error) {
// Start the listener
socket := cmn.Fmt("unix://%s.sock", name)
logger := log.NewTmLogger(os.Stdout)
server, err := server.NewSocketServer(socket, app)
if err != nil {
return nil, nil, err
}
server.SetLogger(log.With(logger, "module", "abci-server"))
// Connect to the socket
client, err := abcicli.NewSocketClient(socket, false)
@ -222,6 +227,7 @@ func makeSocketClientServer(app types.Application, name string) (abcicli.Client,
server.Stop()
return nil, nil, err
}
client.SetLogger(log.With(logger, "module", "abci-client"))
client.Start()
return client, server, err
@ -230,18 +236,21 @@ func makeSocketClientServer(app types.Application, name string) (abcicli.Client,
func makeGRPCClientServer(app types.Application, name string) (abcicli.Client, cmn.Service, error) {
// Start the listener
socket := cmn.Fmt("unix://%s.sock", name)
logger := log.NewTmLogger(os.Stdout)
gapp := types.NewGRPCApplication(app)
server, err := server.NewGRPCServer(socket, gapp)
if err != nil {
return nil, nil, err
}
server.SetLogger(log.With(logger, "module", "abci-server"))
client, err := abcicli.NewGRPCClient(socket, true)
if err != nil {
server.Stop()
return nil, nil, err
}
client.SetLogger(log.With(logger, "module", "abci-client"))
return client, server, err
}


+ 0
- 7
example/dummy/log.go View File

@ -1,7 +0,0 @@
package dummy
import (
"github.com/tendermint/tmlibs/logger"
)
var log = logger.New("module", "dummy")

+ 20
- 10
example/dummy/persistent_dummy.go View File

@ -6,11 +6,13 @@ import (
"strconv"
"strings"
"github.com/pkg/errors"
"github.com/tendermint/abci/types"
"github.com/tendermint/go-wire"
wire "github.com/tendermint/go-wire"
"github.com/tendermint/merkleeyes/iavl"
cmn "github.com/tendermint/tmlibs/common"
dbm "github.com/tendermint/tmlibs/db"
"github.com/tendermint/tmlibs/log"
)
const (
@ -29,6 +31,8 @@ type PersistentDummyApplication struct {
// validator set
changes []*types.Validator
logger log.Logger
}
func NewPersistentDummyApplication(dbDir string) *PersistentDummyApplication {
@ -38,14 +42,19 @@ func NewPersistentDummyApplication(dbDir string) *PersistentDummyApplication {
stateTree := iavl.NewIAVLTree(0, db)
stateTree.Load(lastBlock.AppHash)
log.Notice("Loaded state", "block", lastBlock.Height, "root", stateTree.Hash())
// log.Notice("Loaded state", "block", lastBlock.Height, "root", stateTree.Hash())
return &PersistentDummyApplication{
app: &DummyApplication{state: stateTree},
db: db,
app: &DummyApplication{state: stateTree},
db: db,
logger: log.NewNopLogger(),
}
}
func (app *PersistentDummyApplication) SetLogger(l log.Logger) {
app.logger = l
}
func (app *PersistentDummyApplication) Info() (resInfo types.ResponseInfo) {
resInfo = app.app.Info()
lastBlock := LoadLastBlock(app.db)
@ -79,13 +88,16 @@ func (app *PersistentDummyApplication) CheckTx(tx []byte) types.Result {
func (app *PersistentDummyApplication) Commit() types.Result {
// Save
appHash := app.app.state.Save()
log.Info("Saved state", "root", appHash)
app.logger.Info("Saved state", "root", appHash)
lastBlock := LastBlockInfo{
Height: app.blockHeader.Height,
AppHash: appHash, // this hash will be in the next block header
}
app.logger.Info("Saving block", "height", lastBlock.Height, "root", lastBlock.AppHash)
SaveLastBlock(app.db, lastBlock)
return types.NewResultOK(appHash, "")
}
@ -98,7 +110,7 @@ func (app *PersistentDummyApplication) InitChain(validators []*types.Validator)
for _, v := range validators {
r := app.updateValidator(v)
if r.IsErr() {
log.Error("Error updating validators", "r", r)
app.logger.Error("Error updating validators", "r", r)
}
}
}
@ -134,8 +146,7 @@ func LoadLastBlock(db dbm.DB) (lastBlock LastBlockInfo) {
r, n, err := bytes.NewReader(buf), new(int), new(error)
wire.ReadBinaryPtr(&lastBlock, r, 0, n, err)
if *err != nil {
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
log.Crit(cmn.Fmt("Data has been corrupted or its spec has changed: %v\n", *err))
cmn.PanicCrisis(errors.Wrap(*err, "cannot load last block (data has been corrupted or its spec has changed)"))
}
// TODO: ensure that buf is completely read.
}
@ -144,12 +155,11 @@ func LoadLastBlock(db dbm.DB) (lastBlock LastBlockInfo) {
}
func SaveLastBlock(db dbm.DB, lastBlock LastBlockInfo) {
log.Notice("Saving block", "height", lastBlock.Height, "root", lastBlock.AppHash)
buf, n, err := new(bytes.Buffer), new(int), new(error)
wire.WriteBinary(lastBlock, buf, n, err)
if *err != nil {
// TODO
cmn.PanicCrisis(*err)
cmn.PanicCrisis(errors.Wrap(*err, "cannot save last block"))
}
db.Set(lastBlockKey, buf.Bytes())
}


+ 13
- 6
example/example_test.go View File

@ -2,8 +2,9 @@ package example
import (
"fmt"
"log"
stdlog "log"
"net"
"os"
"reflect"
"testing"
"time"
@ -12,11 +13,12 @@ import (
"golang.org/x/net/context"
"github.com/tendermint/abci/client"
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log"
)
func TestDummy(t *testing.T) {
@ -37,19 +39,22 @@ func TestGRPC(t *testing.T) {
func testStream(t *testing.T, app types.Application) {
numDeliverTxs := 200000
logger := log.NewTmLogger(os.Stdout)
// Start the listener
server, err := server.NewSocketServer("unix://test.sock", app)
if err != nil {
log.Fatal(cmn.Fmt("Error starting socket server: %v", err.Error()))
stdlog.Fatal(cmn.Fmt("Error starting socket server: %v", err.Error()))
}
server.SetLogger(log.With(logger, "module", "abci-server"))
defer server.Stop()
// Connect to the socket
client, err := abcicli.NewSocketClient("unix://test.sock", false)
if err != nil {
log.Fatal(cmn.Fmt("Error starting socket client: %v", err.Error()))
stdlog.Fatal(cmn.Fmt("Error starting socket client: %v", err.Error()))
}
client.SetLogger(log.With(logger, "module", "abci-client"))
client.Start()
defer client.Stop()
@ -110,18 +115,20 @@ func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) {
func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
numDeliverTxs := 2000
logger := log.NewTmLogger(os.Stdout)
// Start the listener
server, err := server.NewGRPCServer("unix://test.sock", app)
if err != nil {
log.Fatal(cmn.Fmt("Error starting GRPC server: %v", err.Error()))
stdlog.Fatal(cmn.Fmt("Error starting GRPC server: %v", err.Error()))
}
server.SetLogger(log.With(logger, "module", "abci-server"))
defer server.Stop()
// Connect to the socket
conn, err := grpc.Dial("unix://test.sock", grpc.WithInsecure(), grpc.WithDialer(dialerFunc))
if err != nil {
log.Fatal(cmn.Fmt("Error dialing GRPC server: %v", err.Error()))
stdlog.Fatal(cmn.Fmt("Error dialing GRPC server: %v", err.Error()))
}
defer conn.Close()


+ 42
- 29
glide.lock View File

@ -1,28 +1,35 @@
hash: 13c7dac029851e5177bf78ff26ce6ccd047360111795a9a65af4ba6a0b87f4b3
updated: 2017-04-21T18:38:50.4243289-04:00
hash: 3918a6fe902116fbac5ac474580edf246bee125df6e63e3bd8378f068fa8f819
updated: 2017-05-01T08:59:45.550273823Z
imports:
- name: github.com/btcsuite/btcd
version: 583684b21bfbde9b5fc4403916fd7c807feb0289
version: 4b348c1d33373d672edd83fc576892d0e46686d2
subpackages:
- btcec
- name: github.com/go-kit/kit
version: 8a2988aa81f699fc1e647c3c9dddce0113ef1bfb
subpackages:
- log
- log/level
- log/term
- name: github.com/go-logfmt/logfmt
version: 390ab7935ee28ec6b286364bba9b4dd6410cb3d5
- name: github.com/go-stack/stack
version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82
- name: github.com/golang/protobuf
version: 8ee79997227bf9b34611aee7946ae64735e6fd93
version: 18c9bb3261723cd5401db4d0c9fbc5c3b6c70fe8
subpackages:
- proto
- ptypes/any
- name: github.com/golang/snappy
version: d9eb7a3d35ec988b8585d4a0068e462c27d28380
version: 553a641470496b2327abcac10b36396bd98e45c9
- name: github.com/jmhodges/levigo
version: c42d9e0ca023e2198120196f842701bb4c55d7b9
- name: github.com/mattn/go-colorable
version: d228849504861217f796da67fae4f6e347643f15
- name: github.com/mattn/go-isatty
version: 30a891c33c7cde7b02a981314b4228ec99380cca
- name: github.com/kr/logfmt
version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0
- name: github.com/pkg/errors
version: 645ef00459ed84a119197bfb8d8205042c6df63d
version: ff09b135c25aae272398c51a07235b90a75aa4f0
- name: github.com/syndtr/goleveldb
version: 23851d93a2292dcc56e71a18ec9e0624d84a0f65
version: 8c81ea47d4c41a385645e133e15510fc6a2a74b4
subpackages:
- leveldb
- leveldb/cache
@ -42,31 +49,27 @@ imports:
- edwards25519
- extra25519
- name: github.com/tendermint/go-crypto
version: 9b95da8fa4187f6799558d89b271dc8ab6485615
version: 197a2b270fd94ee03824b158e738fce62862d0b8
- name: github.com/tendermint/go-wire
version: 334005c236d19c632fb5f073f9de3b0fab6a522b
version: b53add0b622662731985485f3a19be7f684660b8
subpackages:
- data
- name: github.com/tendermint/log15
version: ae0f3d6450da9eac7074b439c8e1c3cabf0d5ce6
subpackages:
- term
- name: github.com/tendermint/merkleeyes
version: 6fd69aa0871a4e685a5570aa7ab3d12e4068a722
version: d0aa363fd4e015e509038c3a0ec493bc62ee0b8a
subpackages:
- iavl
- name: github.com/tendermint/tmlibs
version: df250b69416a35a943a6e2a92118667e9ef031d4
version: dc50d7d3c19771377fb4aa6e703354205050053a
subpackages:
- common
- db
- logger
- log
- merkle
- process
- name: github.com/urfave/cli
version: 0bdeddeeb0f650497d603c4ad7b20cfe685682f6
version: ab403a54a148f2d857920810291539e1f817ee7b
- name: golang.org/x/crypto
version: 7c6cc321c680f03b9ef0764448e780704f486b51
version: c7af5bf2638a1164f2eb5467c39c6cffbd13a02e
subpackages:
- nacl/secretbox
- openpgp/armor
@ -75,7 +78,7 @@ imports:
- ripemd160
- salsa20/salsa
- name: golang.org/x/net
version: 61557ac0112b576429a0df080e1c2cef5dfbb642
version: da118f7b8e5954f39d0d2130ab35d4bf0e3cb344
subpackages:
- context
- http2
@ -84,26 +87,36 @@ imports:
- internal/timeseries
- lex/httplex
- trace
- name: golang.org/x/sys
version: d75a52659825e75fff6158388dddc6a5b04f9ba5
- name: golang.org/x/text
version: 470f45bf29f4147d6fbd7dfd0a02a848e49f5bf4
subpackages:
- secure/bidirule
- transform
- unicode/bidi
- unicode/norm
- name: google.golang.org/genproto
version: 411e09b969b1170a9f0c467558eb4c4c110d9c77
subpackages:
- unix
- googleapis/rpc/status
- name: google.golang.org/grpc
version: cbcceb2942a489498cf22b2f918536e819d33f0a
version: 0eb507a2ca07f13baf499f89d66cc566bf644643
subpackages:
- codes
- credentials
- grpclb/grpc_lb_v1
- grpclog
- internal
- keepalive
- metadata
- naming
- peer
- stats
- status
- tap
- transport
testImports:
- name: github.com/davecgh/go-spew
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
version: 04cdfd42973bb9c8589fd6a731800cf222fde1a9
subpackages:
- spew
- name: github.com/pmezard/go-difflib
@ -111,7 +124,7 @@ testImports:
subpackages:
- difflib
- name: github.com/stretchr/testify
version: 69483b4bd14f5845b5a1e55bca19e954e827f1d0
version: 4d4bfba8f1d1027c4fdbe371823030df51419987
subpackages:
- assert
- require

+ 3
- 2
glide.yaml View File

@ -3,6 +3,7 @@ import:
- package: github.com/golang/protobuf
subpackages:
- proto
- package: github.com/pkg/errors
- package: github.com/tendermint/go-crypto
version: develop
- package: github.com/tendermint/go-wire
@ -12,11 +13,11 @@ import:
subpackages:
- iavl
- package: github.com/tendermint/tmlibs
version: develop
version: feature/new-logging
subpackages:
- common
- db
- logger
- log
- merkle
- process
- package: github.com/urfave/cli


+ 0
- 7
server/log.go View File

@ -1,7 +0,0 @@
package server
import (
"github.com/tendermint/tmlibs/logger"
)
var log = logger.New("module", "abci-server")

+ 7
- 7
server/socket_server.go View File

@ -94,15 +94,15 @@ func (s *SocketServer) acceptConnectionsRoutine() {
// semaphore <- struct{}{}
// Accept a connection
log.Notice("Waiting for new connection...")
s.Logger.Info("Waiting for new connection...")
conn, err := s.listener.Accept()
if err != nil {
if !s.IsRunning() {
return // Ignore error from listener closing.
}
log.Crit("Failed to accept connection: " + err.Error())
s.Logger.Error("Failed to accept connection: " + err.Error())
} else {
log.Notice("Accepted a new connection")
s.Logger.Info("Accepted a new connection")
}
connID := s.addConn(conn)
@ -119,18 +119,18 @@ func (s *SocketServer) acceptConnectionsRoutine() {
// Wait until signal to close connection
errClose := <-closeConn
if err == io.EOF {
log.Warn("Connection was closed by client")
s.Logger.Error("Connection was closed by client")
} else if errClose != nil {
log.Warn("Connection error", "error", errClose)
s.Logger.Error("Connection error", "error", errClose)
} else {
// never happens
log.Warn("Connection was closed.")
s.Logger.Error("Connection was closed.")
}
// Close the connection
err := s.rmConn(connID, conn)
if err != nil {
log.Warn("Error in closing connection", "error", err)
s.Logger.Error("Error in closing connection", "error", err)
}
// <-semaphore


+ 0
- 0
tests/test.sh View File


+ 4
- 1
tests/test_app/app.go View File

@ -6,8 +6,9 @@ import (
"os"
"time"
"github.com/tendermint/abci/client"
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/types"
"github.com/tendermint/tmlibs/log"
"github.com/tendermint/tmlibs/process"
)
@ -37,6 +38,8 @@ func startClient(abciType string) abcicli.Client {
if err != nil {
panic("connecting to abci_app: " + err.Error())
}
logger := log.NewTmLogger(os.Stdout)
client.SetLogger(log.With(logger, "module", "abcicli"))
return client
}


Loading…
Cancel
Save