Browse Source

remove stdlog

pull/1780/head
Anton Kaliaev 8 years ago
parent
commit
9a6d190282
No known key found for this signature in database GPG Key ID: 7B6881D965918214
5 changed files with 23 additions and 17 deletions
  1. +9
    -4
      cmd/abci-cli/abci-cli.go
  2. +4
    -3
      cmd/counter/main.go
  3. +2
    -2
      cmd/dummy/main.go
  4. +4
    -3
      example/block_aware/block_aware_app.go
  5. +4
    -5
      example/example_test.go

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

@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
stdlog "log"
"os"
"strings"
@ -37,6 +36,8 @@ type queryResponse struct {
// client is a global variable so it can be reused by the console
var client abcicli.Client
var logger log.Logger
func main() {
//workaround for the cli library (https://github.com/urfave/cli/issues/565)
@ -130,19 +131,23 @@ func main() {
app.Before = before
err := app.Run(os.Args)
if err != nil {
stdlog.Fatal(err.Error())
logger.Error(err.Error())
os.Exit(1)
}
}
func before(c *cli.Context) error {
if logger == nil {
logger = log.NewTmLogger(os.Stdout)
}
if client == nil {
var err error
client, err = abcicli.NewClient(c.GlobalString("address"), c.GlobalString("abci"), false)
if err != nil {
stdlog.Fatal(err.Error())
logger.Error(err.Error())
os.Exit(1)
}
logger := log.NewTmLogger(os.Stdout)
client.SetLogger(log.With(logger, "module", "abci-client"))
}
return nil


+ 4
- 3
cmd/counter/main.go View File

@ -2,7 +2,6 @@ package main
import (
"flag"
stdlog "log"
"os"
"github.com/tendermint/abci/example/counter"
@ -19,12 +18,14 @@ func main() {
flag.Parse()
app := counter.NewCounterApplication(*serialPtr)
logger := log.NewTmLogger(os.Stdout)
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
if err != nil {
stdlog.Fatal(err.Error())
logger.Error(err.Error())
os.Exit(1)
}
logger := log.NewTmLogger(os.Stdout)
srv.SetLogger(log.With(logger, "module", "abci-server"))
// Wait forever


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

@ -2,7 +2,6 @@ package main
import (
"flag"
stdlog "log"
"os"
"github.com/tendermint/abci/example/dummy"
@ -33,7 +32,8 @@ func main() {
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
if err != nil {
stdlog.Fatal(err.Error())
logger.Error(err.Error())
os.Exit(1)
}
srv.SetLogger(log.With(logger, "module", "abci-server"))


+ 4
- 3
example/block_aware/block_aware_app.go View File

@ -2,7 +2,6 @@ package main
import (
"flag"
stdlog "log"
"os"
"github.com/tendermint/abci/server"
@ -17,12 +16,14 @@ func main() {
abciPtr := flag.String("abci", "socket", "socket | grpc")
flag.Parse()
logger := log.NewTmLogger(os.Stdout)
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, NewChainAwareApplication())
if err != nil {
stdlog.Fatal(err.Error())
logger.Error(err.Error())
os.Exit(1)
}
logger := log.NewTmLogger(os.Stdout)
srv.SetLogger(log.With(logger, "module", "abci-server"))
// Wait forever


+ 4
- 5
example/example_test.go View File

@ -2,7 +2,6 @@ package example
import (
"fmt"
stdlog "log"
"net"
"os"
"reflect"
@ -44,7 +43,7 @@ func testStream(t *testing.T, app types.Application) {
// Start the listener
server, err := server.NewSocketServer("unix://test.sock", app)
if err != nil {
stdlog.Fatal(cmn.Fmt("Error starting socket server: %v", err.Error()))
t.Fatalf("Error starting socket server: %v", err.Error())
}
server.SetLogger(log.With(logger, "module", "abci-server"))
defer server.Stop()
@ -52,7 +51,7 @@ func testStream(t *testing.T, app types.Application) {
// Connect to the socket
client, err := abcicli.NewSocketClient("unix://test.sock", false)
if err != nil {
stdlog.Fatal(cmn.Fmt("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()
@ -120,7 +119,7 @@ func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
// Start the listener
server, err := server.NewGRPCServer("unix://test.sock", app)
if err != nil {
stdlog.Fatal(cmn.Fmt("Error starting GRPC server: %v", err.Error()))
t.Fatalf("Error starting GRPC server: %v", err.Error())
}
server.SetLogger(log.With(logger, "module", "abci-server"))
defer server.Stop()
@ -128,7 +127,7 @@ func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
// Connect to the socket
conn, err := grpc.Dial("unix://test.sock", grpc.WithInsecure(), grpc.WithDialer(dialerFunc))
if err != nil {
stdlog.Fatal(cmn.Fmt("Error dialing GRPC server: %v", err.Error()))
t.Fatalf("Error dialing GRPC server: %v", err.Error())
}
defer conn.Close()


Loading…
Cancel
Save