Browse Source

cleanup: replace common.Exit with log.Crit or log.Fatal

Later we can pick another logger that has fatal, like zap?
pull/1780/head
Tzu-Jung Lee 8 years ago
parent
commit
9134905f42
10 changed files with 28 additions and 21 deletions
  1. +3
    -3
      cmd/abci-cli/tmsp-cli.go
  2. +2
    -1
      cmd/counter/main.go
  3. +2
    -1
      cmd/dummy/main.go
  4. +2
    -1
      example/chain_aware/chain_aware_app.go
  5. +3
    -2
      example/chain_aware/chain_aware_test.go
  6. +1
    -1
      example/dummy/persistent_dummy.go
  7. +6
    -5
      example/example_test.go
  8. +1
    -1
      server/socket_server.go
  9. +5
    -4
      tests/benchmarks/parallel/parallel.go
  10. +3
    -2
      tests/benchmarks/simple/simple.go

+ 3
- 3
cmd/abci-cli/tmsp-cli.go View File

@ -6,12 +6,12 @@ import (
"errors"
"fmt"
"io"
"log"
"os"
"strings"
"github.com/tendermint/abci/client"
"github.com/tendermint/abci/types"
common "github.com/tendermint/go-common"
"github.com/urfave/cli"
)
@ -135,7 +135,7 @@ func main() {
app.Before = before
err := app.Run(os.Args)
if err != nil {
common.Exit(err.Error())
log.Fatal(err.Error())
}
}
@ -145,7 +145,7 @@ func before(c *cli.Context) error {
var err error
client, err = abcicli.NewClient(c.GlobalString("address"), c.GlobalString("abci"), false)
if err != nil {
common.Exit(err.Error())
log.Fatal(err.Error())
}
}
return nil


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

@ -2,6 +2,7 @@ package main
import (
"flag"
"log"
"github.com/tendermint/abci/example/counter"
"github.com/tendermint/abci/server"
@ -19,7 +20,7 @@ func main() {
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
if err != nil {
common.Exit(err.Error())
log.Fatal(err.Error())
}
// Wait forever


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

@ -2,6 +2,7 @@ package main
import (
"flag"
"log"
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/server"
@ -27,7 +28,7 @@ func main() {
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
if err != nil {
common.Exit(err.Error())
log.Fatal(err.Error())
}
// Wait forever


+ 2
- 1
example/chain_aware/chain_aware_app.go View File

@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"log"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
@ -18,7 +19,7 @@ func main() {
// Start the listener
srv, err := server.NewServer(*addrPtr, *abciPtr, NewChainAwareApplication())
if err != nil {
common.Exit(err.Error())
log.Fatal(err.Error())
}
// Wait forever


+ 3
- 2
example/chain_aware/chain_aware_test.go View File

@ -1,6 +1,8 @@
package main
import (
"fmt"
"log"
"strconv"
"strings"
"testing"
@ -8,7 +10,6 @@ import (
"github.com/tendermint/abci/client"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
common "github.com/tendermint/go-common"
)
func TestChainAware(t *testing.T) {
@ -25,7 +26,7 @@ func TestChainAware(t *testing.T) {
// Connect to the socket
client, err := abcicli.NewSocketClient("unix://test.sock", false)
if err != nil {
common.Exit(Fmt("Error starting socket client: %v", err.Error()))
log.Fatal(fmt.Sprintf("Error starting socket client: %v", err.Error()))
}
client.Start()
defer client.Stop()


+ 1
- 1
example/dummy/persistent_dummy.go View File

@ -136,7 +136,7 @@ func LoadLastBlock(db dbm.DB) (lastBlock LastBlockInfo) {
wire.ReadBinaryPtr(&lastBlock, r, 0, n, err)
if *err != nil {
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
common.Exit(fmt.Sprintf("Data has been corrupted or its spec has changed: %v\n", *err))
log.Crit(fmt.Sprintf("Data has been corrupted or its spec has changed: %v\n", *err))
}
// TODO: ensure that buf is completely read.
}


+ 6
- 5
example/example_test.go View File

@ -2,6 +2,7 @@ package example
import (
"fmt"
"log"
"net"
"reflect"
"testing"
@ -41,14 +42,14 @@ func testStream(t *testing.T, app types.Application) {
// Start the listener
server, err := server.NewSocketServer("unix://test.sock", app)
if err != nil {
common.Exit(fmt.Sprintf("Error starting socket server: %v", err.Error()))
log.Fatal(fmt.Sprintf("Error starting socket server: %v", err.Error()))
}
defer server.Stop()
// Connect to the socket
client, err := abcicli.NewSocketClient("unix://test.sock", false)
if err != nil {
common.Exit(fmt.Sprintf("Error starting socket client: %v", err.Error()))
log.Fatal(fmt.Sprintf("Error starting socket client: %v", err.Error()))
}
client.Start()
defer client.Stop()
@ -104,7 +105,7 @@ func testStream(t *testing.T, app types.Application) {
// test grpc
func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) {
return Connect(addr)
return common.Connect(addr)
}
func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
@ -114,14 +115,14 @@ func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
// Start the listener
server, err := server.NewGRPCServer("unix://test.sock", app)
if err != nil {
common.Exit(fmt.Sprintf("Error starting GRPC server: %v", err.Error()))
log.Fatal(fmt.Sprintf("Error starting GRPC server: %v", err.Error()))
}
defer server.Stop()
// Connect to the socket
conn, err := grpc.Dial("unix://test.sock", grpc.WithInsecure(), grpc.WithDialer(dialerFunc))
if err != nil {
common.Exit(fmt.Sprintf("Error dialing GRPC server: %v", err.Error()))
log.Fatal(fmt.Sprintf("Error dialing GRPC server: %v", err.Error()))
}
defer conn.Close()


+ 1
- 1
server/socket_server.go View File

@ -100,7 +100,7 @@ func (s *SocketServer) acceptConnectionsRoutine() {
if !s.IsRunning() {
return // Ignore error from listener closing.
}
common.Exit("Failed to accept connection: " + err.Error())
log.Crit("Failed to accept connection: " + err.Error())
} else {
log.Notice("Accepted a new connection")
}


+ 5
- 4
tests/benchmarks/parallel/parallel.go View File

@ -3,6 +3,7 @@ package main
import (
"bufio"
"fmt"
"log"
"github.com/tendermint/abci/types"
common "github.com/tendermint/go-common"
@ -12,7 +13,7 @@ func main() {
conn, err := common.Connect("unix://test.sock")
if err != nil {
common.Exit(err.Error())
log.Fatal(err.Error())
}
// Read a bunch of responses
@ -22,7 +23,7 @@ func main() {
var res = &types.Response{}
err := types.ReadMessage(conn, res)
if err != nil {
common.Exit(err.Error())
log.Fatal(err.Error())
}
counter += 1
if counter%1000 == 0 {
@ -39,11 +40,11 @@ func main() {
err := types.WriteMessage(req, bufWriter)
if err != nil {
common.Exit(err.Error())
log.Fatal(err.Error())
}
err = bufWriter.Flush()
if err != nil {
common.Exit(err.Error())
log.Fatal(err.Error())
}
counter += 1


+ 3
- 2
tests/benchmarks/simple/simple.go View File

@ -4,6 +4,7 @@ import (
"bufio"
"errors"
"fmt"
"log"
"net"
"reflect"
@ -15,7 +16,7 @@ func main() {
conn, err := common.Connect("unix://test.sock")
if err != nil {
common.Exit(err.Error())
log.Fatal(err.Error())
}
// Make a bunch of requests
@ -24,7 +25,7 @@ func main() {
req := types.ToRequestEcho("foobar")
_, err := makeRequest(conn, req)
if err != nil {
common.Exit(err.Error())
log.Fatal(err.Error())
}
counter += 1
if counter%1000 == 0 {


Loading…
Cancel
Save