Updated logs for middleware and status of nodes at node balancer

pull/519/head
kompotkot 2022-01-11 21:21:50 +00:00
rodzic de0ef49825
commit d0ebd4782f
3 zmienionych plików z 9 dodań i 4 usunięć

Wyświetl plik

@ -113,7 +113,6 @@ func (bpool *BlockchainPool) GetNextNode(blockchain string) *Node {
continue
}
fmt.Printf("Used node: %s with hi block: %d\n", np.Nodes[idx].GethURL, np.Nodes[idx].CurrentBlock)
return np.Nodes[idx]
}
}
@ -180,7 +179,7 @@ func (bpool *BlockchainPool) HealthCheck() {
n.SetCurrentBlock(statusResponse.CurrentBlock)
}
log.Printf("Node %s is alive: %t with current block: %d\n", n.StatusURL, true, statusResponse.CurrentBlock)
log.Printf("Node %s is alive: %t with current block: %d blockchain called: %d times\n", n.StatusURL, true, statusResponse.CurrentBlock, b.Current)
}
}
}

Wyświetl plik

@ -93,5 +93,5 @@ func (cpool *ClientPool) CleanInactiveClientNodes() {
}
}
log.Printf("Active clients: %d", len(cpool.Clients))
log.Printf("Active clients: %d\n", len(cpool.Clients))
}

Wyświetl plik

@ -5,6 +5,7 @@ package cmd
import (
"log"
"net"
"net/http"
humbug "github.com/bugout-dev/humbug/go/pkg"
@ -31,6 +32,11 @@ func panicMiddleware(next http.Handler) http.Handler {
func logMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
next.ServeHTTP(w, r)
log.Printf("%s %s %s\n", r.Method, r.URL.Path, r.RemoteAddr)
ip, _, err := net.SplitHostPort(r.RemoteAddr)
if err != nil {
log.Printf("Unable to parse client IP: %s\n", r.RemoteAddr)
} else {
log.Printf("%s %s %s\n", ip, r.Method, r.URL.Path)
}
})
}