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:
parent
1150bbfe36
commit
9134905f42
|
@ -6,12 +6,12 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/tendermint/abci/client"
|
"github.com/tendermint/abci/client"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ func main() {
|
||||||
app.Before = before
|
app.Before = before
|
||||||
err := app.Run(os.Args)
|
err := app.Run(os.Args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.Exit(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ func before(c *cli.Context) error {
|
||||||
var err error
|
var err error
|
||||||
client, err = abcicli.NewClient(c.GlobalString("address"), c.GlobalString("abci"), false)
|
client, err = abcicli.NewClient(c.GlobalString("address"), c.GlobalString("abci"), false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.Exit(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/tendermint/abci/example/counter"
|
"github.com/tendermint/abci/example/counter"
|
||||||
"github.com/tendermint/abci/server"
|
"github.com/tendermint/abci/server"
|
||||||
|
@ -19,7 +20,7 @@ func main() {
|
||||||
// Start the listener
|
// Start the listener
|
||||||
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
|
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.Exit(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait forever
|
// Wait forever
|
||||||
|
|
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/tendermint/abci/example/dummy"
|
"github.com/tendermint/abci/example/dummy"
|
||||||
"github.com/tendermint/abci/server"
|
"github.com/tendermint/abci/server"
|
||||||
|
@ -27,7 +28,7 @@ func main() {
|
||||||
// Start the listener
|
// Start the listener
|
||||||
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
|
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.Exit(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait forever
|
// Wait forever
|
||||||
|
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/tendermint/abci/server"
|
"github.com/tendermint/abci/server"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
|
@ -18,7 +19,7 @@ func main() {
|
||||||
// Start the listener
|
// Start the listener
|
||||||
srv, err := server.NewServer(*addrPtr, *abciPtr, NewChainAwareApplication())
|
srv, err := server.NewServer(*addrPtr, *abciPtr, NewChainAwareApplication())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.Exit(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait forever
|
// Wait forever
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -8,7 +10,6 @@ import (
|
||||||
"github.com/tendermint/abci/client"
|
"github.com/tendermint/abci/client"
|
||||||
"github.com/tendermint/abci/server"
|
"github.com/tendermint/abci/server"
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestChainAware(t *testing.T) {
|
func TestChainAware(t *testing.T) {
|
||||||
|
@ -25,7 +26,7 @@ func TestChainAware(t *testing.T) {
|
||||||
// Connect to the socket
|
// Connect to the socket
|
||||||
client, err := abcicli.NewSocketClient("unix://test.sock", false)
|
client, err := abcicli.NewSocketClient("unix://test.sock", false)
|
||||||
if err != nil {
|
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()
|
client.Start()
|
||||||
defer client.Stop()
|
defer client.Stop()
|
||||||
|
|
|
@ -136,7 +136,7 @@ func LoadLastBlock(db dbm.DB) (lastBlock LastBlockInfo) {
|
||||||
wire.ReadBinaryPtr(&lastBlock, r, 0, n, err)
|
wire.ReadBinaryPtr(&lastBlock, r, 0, n, err)
|
||||||
if *err != nil {
|
if *err != nil {
|
||||||
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
|
// 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.
|
// TODO: ensure that buf is completely read.
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package example
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -41,14 +42,14 @@ func testStream(t *testing.T, app types.Application) {
|
||||||
// Start the listener
|
// Start the listener
|
||||||
server, err := server.NewSocketServer("unix://test.sock", app)
|
server, err := server.NewSocketServer("unix://test.sock", app)
|
||||||
if err != nil {
|
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()
|
defer server.Stop()
|
||||||
|
|
||||||
// Connect to the socket
|
// Connect to the socket
|
||||||
client, err := abcicli.NewSocketClient("unix://test.sock", false)
|
client, err := abcicli.NewSocketClient("unix://test.sock", false)
|
||||||
if err != nil {
|
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()
|
client.Start()
|
||||||
defer client.Stop()
|
defer client.Stop()
|
||||||
|
@ -104,7 +105,7 @@ func testStream(t *testing.T, app types.Application) {
|
||||||
// test grpc
|
// test grpc
|
||||||
|
|
||||||
func dialerFunc(addr string, timeout time.Duration) (net.Conn, error) {
|
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) {
|
func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
|
||||||
|
@ -114,14 +115,14 @@ func testGRPCSync(t *testing.T, app *types.GRPCApplication) {
|
||||||
// Start the listener
|
// Start the listener
|
||||||
server, err := server.NewGRPCServer("unix://test.sock", app)
|
server, err := server.NewGRPCServer("unix://test.sock", app)
|
||||||
if err != nil {
|
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()
|
defer server.Stop()
|
||||||
|
|
||||||
// Connect to the socket
|
// Connect to the socket
|
||||||
conn, err := grpc.Dial("unix://test.sock", grpc.WithInsecure(), grpc.WithDialer(dialerFunc))
|
conn, err := grpc.Dial("unix://test.sock", grpc.WithInsecure(), grpc.WithDialer(dialerFunc))
|
||||||
if err != nil {
|
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()
|
defer conn.Close()
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ func (s *SocketServer) acceptConnectionsRoutine() {
|
||||||
if !s.IsRunning() {
|
if !s.IsRunning() {
|
||||||
return // Ignore error from listener closing.
|
return // Ignore error from listener closing.
|
||||||
}
|
}
|
||||||
common.Exit("Failed to accept connection: " + err.Error())
|
log.Crit("Failed to accept connection: " + err.Error())
|
||||||
} else {
|
} else {
|
||||||
log.Notice("Accepted a new connection")
|
log.Notice("Accepted a new connection")
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
common "github.com/tendermint/go-common"
|
common "github.com/tendermint/go-common"
|
||||||
|
@ -12,7 +13,7 @@ func main() {
|
||||||
|
|
||||||
conn, err := common.Connect("unix://test.sock")
|
conn, err := common.Connect("unix://test.sock")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.Exit(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read a bunch of responses
|
// Read a bunch of responses
|
||||||
|
@ -22,7 +23,7 @@ func main() {
|
||||||
var res = &types.Response{}
|
var res = &types.Response{}
|
||||||
err := types.ReadMessage(conn, res)
|
err := types.ReadMessage(conn, res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.Exit(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
counter += 1
|
counter += 1
|
||||||
if counter%1000 == 0 {
|
if counter%1000 == 0 {
|
||||||
|
@ -39,11 +40,11 @@ func main() {
|
||||||
|
|
||||||
err := types.WriteMessage(req, bufWriter)
|
err := types.WriteMessage(req, bufWriter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.Exit(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
err = bufWriter.Flush()
|
err = bufWriter.Flush()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.Exit(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
counter += 1
|
counter += 1
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ func main() {
|
||||||
|
|
||||||
conn, err := common.Connect("unix://test.sock")
|
conn, err := common.Connect("unix://test.sock")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.Exit(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a bunch of requests
|
// Make a bunch of requests
|
||||||
|
@ -24,7 +25,7 @@ func main() {
|
||||||
req := types.ToRequestEcho("foobar")
|
req := types.ToRequestEcho("foobar")
|
||||||
_, err := makeRequest(conn, req)
|
_, err := makeRequest(conn, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.Exit(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
counter += 1
|
counter += 1
|
||||||
if counter%1000 == 0 {
|
if counter%1000 == 0 {
|
||||||
|
|
Loading…
Reference in New Issue