Browse Source

update log interface

pull/1780/head
Anton Kaliaev 8 years ago
parent
commit
1dc3629b1a
No known key found for this signature in database GPG Key ID: 7B6881D965918214
11 changed files with 31 additions and 29 deletions
  1. +2
    -1
      client/socket_client.go
  2. +2
    -2
      cmd/abci-cli/abci-cli.go
  3. +2
    -2
      cmd/counter/main.go
  4. +3
    -3
      cmd/dummy/main.go
  5. +2
    -2
      example/block_aware/block_aware_app.go
  6. +2
    -2
      example/block_aware/block_aware_test.go
  7. +6
    -7
      example/dummy/dummy_test.go
  8. +3
    -3
      example/example_test.go
  9. +5
    -5
      glide.lock
  10. +2
    -0
      server/socket_server.go
  11. +2
    -2
      tests/test_app/app.go

+ 2
- 1
client/socket_client.go View File

@ -53,7 +53,8 @@ func NewSocketClient(addr string, mustConnect bool) (*socketClient, error) {
resCb: nil,
}
cli.BaseService = *cmn.NewBaseService(nil, "socketClient", cli)
// FIXME we are loosing "Starting socketClient" message here
// add logger to params?
_, err := cli.Start() // Just start it, it's confusing for callers to remember to start.
return cli, err
}


+ 2
- 2
cmd/abci-cli/abci-cli.go View File

@ -139,7 +139,7 @@ func main() {
func before(c *cli.Context) error {
if logger == nil {
logger = log.NewTMLogger(os.Stdout)
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout))
}
if client == nil {
var err error
@ -148,7 +148,7 @@ func before(c *cli.Context) error {
logger.Error(err.Error())
os.Exit(1)
}
client.SetLogger(log.With(logger, "module", "abci-client"))
client.SetLogger(logger.With("module", "abci-client"))
}
return nil
}


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

@ -18,7 +18,7 @@ func main() {
flag.Parse()
app := counter.NewCounterApplication(*serialPtr)
logger := log.NewTMLogger(os.Stdout)
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
@ -26,7 +26,7 @@ func main() {
logger.Error(err.Error())
os.Exit(1)
}
srv.SetLogger(log.With(logger, "module", "abci-server"))
srv.SetLogger(logger.With("module", "abci-server"))
// Wait forever
cmn.TrapSignal(func() {


+ 3
- 3
cmd/dummy/main.go View File

@ -18,7 +18,7 @@ func main() {
persistencePtr := flag.String("persist", "", "directory to use for a database")
flag.Parse()
logger := log.NewTMLogger(os.Stdout)
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
// Create the application - in memory or persisted to disk
var app types.Application
@ -26,7 +26,7 @@ func main() {
app = dummy.NewDummyApplication()
} else {
app = dummy.NewPersistentDummyApplication(*persistencePtr)
app.(*dummy.PersistentDummyApplication).SetLogger(log.With(logger, "module", "dummy"))
app.(*dummy.PersistentDummyApplication).SetLogger(logger.With("module", "dummy"))
}
// Start the listener
@ -35,7 +35,7 @@ func main() {
logger.Error(err.Error())
os.Exit(1)
}
srv.SetLogger(log.With(logger, "module", "abci-server"))
srv.SetLogger(logger.With("module", "abci-server"))
// Wait forever
cmn.TrapSignal(func() {


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

@ -16,7 +16,7 @@ func main() {
abciPtr := flag.String("abci", "socket", "socket | grpc")
flag.Parse()
logger := log.NewTMLogger(os.Stdout)
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, NewChainAwareApplication())
@ -24,7 +24,7 @@ func main() {
logger.Error(err.Error())
os.Exit(1)
}
srv.SetLogger(log.With(logger, "module", "abci-server"))
srv.SetLogger(logger.With("module", "abci-server"))
// Wait forever
cmn.TrapSignal(func() {


+ 2
- 2
example/block_aware/block_aware_test.go View File

@ -19,7 +19,7 @@ func TestChainAware(t *testing.T) {
if err != nil {
t.Fatal(err)
}
srv.SetLogger(log.With(log.TestingLogger(), "module", "abci-server"))
srv.SetLogger(log.TestingLogger().With("module", "abci-server"))
defer srv.Stop()
// Connect to the socket
@ -27,7 +27,7 @@ func TestChainAware(t *testing.T) {
if err != nil {
t.Fatalf("Error starting socket client: %v", err.Error())
}
client.SetLogger(log.With(log.TestingLogger(), "module", "abci-client"))
client.SetLogger(log.TestingLogger().With("module", "abci-client"))
client.Start()
defer client.Stop()


+ 6
- 7
example/dummy/dummy_test.go View File

@ -3,7 +3,6 @@ package dummy
import (
"bytes"
"io/ioutil"
"os"
"sort"
"testing"
@ -213,13 +212,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)
logger := log.TestingLogger()
server, err := server.NewSocketServer(socket, app)
if err != nil {
return nil, nil, err
}
server.SetLogger(log.With(logger, "module", "abci-server"))
server.SetLogger(logger.With("module", "abci-server"))
// Connect to the socket
client, err := abcicli.NewSocketClient(socket, false)
@ -227,7 +226,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.SetLogger(logger.With("module", "abci-client"))
client.Start()
return client, server, err
@ -236,21 +235,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)
logger := log.TestingLogger()
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"))
server.SetLogger(logger.With("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"))
client.SetLogger(logger.With("module", "abci-client"))
return client, server, err
}


+ 3
- 3
example/example_test.go View File

@ -42,7 +42,7 @@ func testStream(t *testing.T, app types.Application) {
if err != nil {
t.Fatalf("Error starting socket server: %v", err.Error())
}
server.SetLogger(log.With(log.TestingLogger(), "module", "abci-server"))
server.SetLogger(log.TestingLogger().With("module", "abci-server"))
defer server.Stop()
// Connect to the socket
@ -50,7 +50,7 @@ func testStream(t *testing.T, app types.Application) {
if err != nil {
t.Fatalf("Error starting socket client: %v", err.Error())
}
client.SetLogger(log.With(log.TestingLogger(), "module", "abci-client"))
client.SetLogger(log.TestingLogger().With("module", "abci-client"))
client.Start()
defer client.Stop()
@ -116,7 +116,7 @@ func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
if err != nil {
t.Fatalf("Error starting GRPC server: %v", err.Error())
}
server.SetLogger(log.With(log.TestingLogger(), "module", "abci-server"))
server.SetLogger(log.TestingLogger().With("module", "abci-server"))
defer server.Stop()
// Connect to the socket


+ 5
- 5
glide.lock View File

@ -1,5 +1,5 @@
hash: c29114af0ddcb75dd9093d4006dd6b9039640a35540d5f44f9c19261b5730781
updated: 2017-05-03T07:33:18.832551385Z
updated: 2017-05-04T17:47:52.109070369Z
imports:
- name: github.com/btcsuite/btcd
version: 4b348c1d33373d672edd83fc576892d0e46686d2
@ -14,7 +14,7 @@ imports:
- name: github.com/go-logfmt/logfmt
version: 390ab7935ee28ec6b286364bba9b4dd6410cb3d5
- name: github.com/go-stack/stack
version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82
version: 7a2f19628aabfe68f0766b59e74d6315f8347d22
- name: github.com/golang/protobuf
version: 18c9bb3261723cd5401db4d0c9fbc5c3b6c70fe8
subpackages:
@ -59,7 +59,7 @@ imports:
subpackages:
- iavl
- name: github.com/tendermint/tmlibs
version: 8fc36b0097e1dfcfbba793d4b4cc87e96a03096f
version: a9a96064a0a494ef6a13c38b4395c20abee64996
subpackages:
- common
- db
@ -69,7 +69,7 @@ imports:
- name: github.com/urfave/cli
version: ab403a54a148f2d857920810291539e1f817ee7b
- name: golang.org/x/crypto
version: d1464577745bc7f4e74f65be9cfbd09436a729d6
version: 5a033cc77e57eca05bdb50522851d29e03569cbe
subpackages:
- nacl/secretbox
- openpgp/armor
@ -78,7 +78,7 @@ imports:
- ripemd160
- salsa20/salsa
- name: golang.org/x/net
version: 0819898fb4973868bba6de59b6aaad75beea9a6a
version: feeb485667d1fdabe727840fe00adc22431bc86e
subpackages:
- context
- http2


+ 2
- 0
server/socket_server.go View File

@ -40,6 +40,8 @@ func NewSocketServer(protoAddr string, app types.Application) (cmn.Service, erro
conns: make(map[int]net.Conn),
}
s.BaseService = *cmn.NewBaseService(nil, "ABCIServer", s)
// FIXME we are loosing "Starting ABCIServer" message here
// add logger to params?
_, err := s.Start() // Just start it
return s, err
}


+ 2
- 2
tests/test_app/app.go View File

@ -38,8 +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"))
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
client.SetLogger(logger.With("module", "abcicli"))
return client
}


Loading…
Cancel
Save