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

Later we can pick another logger that has fatal, like zap?
This commit is contained in:
Tzu-Jung Lee
2017-01-16 23:23:19 -08:00
parent 1150bbfe36
commit 9134905f42
10 changed files with 28 additions and 21 deletions
+2 -1
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
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
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
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()