rpc use new logger

This commit is contained in:
2024-10-10 10:26:33 +02:00
parent 528faedfb4
commit f2e25cb402

View File

@@ -13,6 +13,7 @@ import (
"github.com/k4lipso/pentapass/storage"
"github.com/k4lipso/pentapass/crypto"
"github.com/k4lipso/pentapass/crypto/age"
. "github.com/k4lipso/pentapass/internal/log"
)
var StorageHandler *storage.StorageHandler
@@ -95,7 +96,7 @@ func (t *Query) AddPeer(np *NamespacePeer, success *bool) error {
peer, err := storage.PeerFromString(np.Peer)
if err != nil {
fmt.Printf("Error parsing peer string: %s\n", err)
Logger.Infof("Error parsing peer string: %s\n", err)
*success = false
return err
}
@@ -117,7 +118,7 @@ func (t *Query) DeletePeer(np *NamespacePeer, success *bool) error {
peer, err := storage.PeerFromString(np.Peer)
if err != nil {
fmt.Printf("Error parsing peer string: %s\n", err)
Logger.Infof("Error parsing peer string: %s\n", err)
*success = false
return err
}
@@ -162,8 +163,7 @@ func (t *Query) ListNamespaces(_ *int, reply *[]string) error {
}
func (t *Query) GetAllNames(namespace *string, reply *[]string) error {
fmt.Println("RPC Request: Query::LoadedTriggers")
fmt.Printf("Listing content of %s", *namespace)
Logger.Infof("Listing content of %s", *namespace)
val, ok := StorageHandler.Namespaces[*namespace]
@@ -182,7 +182,7 @@ func Serve(path string) {
l, err := net.Listen("unix", path + "/rpc_test.socket")
if err != nil {
fmt.Printf("Error while listening on unix socket: %s\n", err)
Logger.Errorf("Error while listening on unix socket: %s\n", err)
}
go http.Serve(l, nil)
@@ -191,7 +191,7 @@ func Serve(path string) {
signal.Notify(sigc, os.Interrupt, syscall.SIGTERM)
func(ln net.Listener, c chan os.Signal) {
sig := <-c
fmt.Printf("Caught signal %s: shutting down.\n", sig)
Logger.Infof("Caught signal %s: shutting down.\n", sig)
ln.Close()
os.Exit(0)
}(l, sigc)
@@ -201,7 +201,7 @@ func Receive(path string) (*rpc.Client, error) {
client, err := rpc.DialHTTP("unix", path + "/rpc_test.socket")
if err != nil {
fmt.Printf("Cant connect to RPC server: %s\n", err)
Logger.Errorf("Cant connect to RPC server: %s\n", err)
}
return client, err