Browse Source

Use log instead of fmt for errors

master
parent
commit
dac4e09854
Signed by: chris GPG Key ID: 3025DCBD46F81C0F
  1. 6
      cmd/gateway/main.go
  2. 7
      cmd/server/main.go

6
cmd/gateway/main.go

@ -24,7 +24,7 @@ func main() {
// Create the connection to the server.
conn, err := grpc.Dial(fmt.Sprintf("%s:%d", *serverAddr, *serverPort))
if err != nil {
fmt.Printf("Failed to connect: %v", err)
log.Fatal(err)
}
// Defer closing the connection.
@ -41,8 +41,8 @@ func main() {
http.HandleFunc("/change_password", gateway.ChangePassword(client))
// Listen for requests.
fmt.Printf("Forwarding from :%d to %s:%d", *port, *serverAddr, *serverPort)
log.Printf("Forwarding from :%d to %s:%d", *port, *serverAddr, *serverPort)
if err := http.ListenAndServe(fmt.Sprintf(":%d", *port), nil); err != nil {
fmt.Printf("Failed to listen: %v", err)
log.Fatal(err)
}
}

7
cmd/server/main.go

@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"log"
"net"
"git.chrishayward.xyz/x/users/proto"
@ -33,7 +34,7 @@ func main() {
// If the secret has not been set print it to the console.
if *secret == secretDefault {
fmt.Printf("SECRET=%s\n", secretDefault)
log.Printf("SECRET=%s\n", secretDefault)
}
// Initialize the database.
@ -52,12 +53,12 @@ func main() {
// Create the network listener.
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", *port))
if err != nil {
fmt.Printf("Failed to listen: %v", err)
log.Fatal(err)
}
// Start listening for requests.
srv := grpc.NewServer()
proto.RegisterUsersServer(srv, server.NewUsersServer(secret, db))
fmt.Printf("Listening on :%d", *port)
log.Printf("Listening on :%d", *port)
srv.Serve(lis)
}
Loading…
Cancel
Save