From e361ed6b122b6b13255f0bbf9849405d2eac53a2 Mon Sep 17 00:00:00 2001 From: Farhan Khan Date: Tue, 28 Jan 2025 16:45:43 +0000 Subject: [PATCH] Adding debug messages --- fedilogue/instance.go | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/fedilogue/instance.go b/fedilogue/instance.go index c4c524d..a27b97c 100644 --- a/fedilogue/instance.go +++ b/fedilogue/instance.go @@ -7,9 +7,6 @@ import ( "net/http" "time" - "os" - "fmt" - "git.farhan.codes/farhan/fedilogue/shared" ) @@ -95,7 +92,6 @@ func GetInstanceInfo(endpoint string, o shared.RunningInstance) shared.RunningIn resp, err := DoTries(&o, req) if err != nil { - fmt.Println("Exit 1") o.Software = "Unsupported" return o } else { @@ -103,7 +99,6 @@ func GetInstanceInfo(endpoint string, o shared.RunningInstance) shared.RunningIn } if resp.StatusCode != 200 { - fmt.Println("Exit 2") o.Software = "Unsupported" return o } @@ -111,7 +106,7 @@ func GetInstanceInfo(endpoint string, o shared.RunningInstance) shared.RunningIn var wellknownnodeinfo shared.WellKnownNodeInfo err = json.NewDecoder(resp.Body).Decode(&wellknownnodeinfo) if (err != nil) { - fmt.Println("Exit 3") + logDebug("GetInstanceInfo for ", endpoint, " Unable to decode " + wellknown_nodeinfo_uri) o.Software = "Unsupported" return o } @@ -119,7 +114,6 @@ func GetInstanceInfo(endpoint string, o shared.RunningInstance) shared.RunningIn // There can be multiple entries of /.well-known/nodeinfo entries, we want the last length := len(wellknownnodeinfo.Links) if length == 0 { - fmt.Println("Exit 4") o.Software = "Unsupported" return o } @@ -131,7 +125,7 @@ func GetInstanceInfo(endpoint string, o shared.RunningInstance) shared.RunningIn respActual, err := DoTries(&o, req) if err != nil { - fmt.Println("Exit 5") + logDebug("GetInstanceInfo for ", endpoint, " unable to connect receive " + wellknown_nodeinfo_uri) o.Software = "Unsupported" return o } else { @@ -139,7 +133,7 @@ func GetInstanceInfo(endpoint string, o shared.RunningInstance) shared.RunningIn } if respActual.StatusCode != 200 { - fmt.Println("Exit 6") + logDebug("GetInstanceInfo for ", endpoint, " Non-200 for " + wellknown_nodeinfo_uri) o.Software = "Unsupported" return o } @@ -147,15 +141,13 @@ func GetInstanceInfo(endpoint string, o shared.RunningInstance) shared.RunningIn var actualnodeinfo shared.ActualNodeInfo err = json.NewDecoder(respActual.Body).Decode(&actualnodeinfo) if (err != nil) { - fmt.Println("Exit 7") - fmt.Println(err) + logDebug("GetInstanceInfo for ", endpoint, " Unable to decode " + actual_nodeinfo_uri) o.Software = "Unsupported" return o } - fmt.Println(actualnodeinfo) - fmt.Println("Final exit") - os.Exit(1) + o.Software = actualnodeinfo.Software.Name + o.Version = actualnodeinfo.Software.Version return o }