Adding debug messages

This commit is contained in:
farhan 2025-01-28 16:45:43 +00:00
parent e646ec1b0c
commit e361ed6b12

View File

@ -7,9 +7,6 @@ import (
"net/http" "net/http"
"time" "time"
"os"
"fmt"
"git.farhan.codes/farhan/fedilogue/shared" "git.farhan.codes/farhan/fedilogue/shared"
) )
@ -95,7 +92,6 @@ func GetInstanceInfo(endpoint string, o shared.RunningInstance) shared.RunningIn
resp, err := DoTries(&o, req) resp, err := DoTries(&o, req)
if err != nil { if err != nil {
fmt.Println("Exit 1")
o.Software = "Unsupported" o.Software = "Unsupported"
return o return o
} else { } else {
@ -103,7 +99,6 @@ func GetInstanceInfo(endpoint string, o shared.RunningInstance) shared.RunningIn
} }
if resp.StatusCode != 200 { if resp.StatusCode != 200 {
fmt.Println("Exit 2")
o.Software = "Unsupported" o.Software = "Unsupported"
return o return o
} }
@ -111,7 +106,7 @@ func GetInstanceInfo(endpoint string, o shared.RunningInstance) shared.RunningIn
var wellknownnodeinfo shared.WellKnownNodeInfo var wellknownnodeinfo shared.WellKnownNodeInfo
err = json.NewDecoder(resp.Body).Decode(&wellknownnodeinfo) err = json.NewDecoder(resp.Body).Decode(&wellknownnodeinfo)
if (err != nil) { if (err != nil) {
fmt.Println("Exit 3") logDebug("GetInstanceInfo for ", endpoint, " Unable to decode " + wellknown_nodeinfo_uri)
o.Software = "Unsupported" o.Software = "Unsupported"
return o 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 // There can be multiple entries of /.well-known/nodeinfo entries, we want the last
length := len(wellknownnodeinfo.Links) length := len(wellknownnodeinfo.Links)
if length == 0 { if length == 0 {
fmt.Println("Exit 4")
o.Software = "Unsupported" o.Software = "Unsupported"
return o return o
} }
@ -131,7 +125,7 @@ func GetInstanceInfo(endpoint string, o shared.RunningInstance) shared.RunningIn
respActual, err := DoTries(&o, req) respActual, err := DoTries(&o, req)
if err != nil { if err != nil {
fmt.Println("Exit 5") logDebug("GetInstanceInfo for ", endpoint, " unable to connect receive " + wellknown_nodeinfo_uri)
o.Software = "Unsupported" o.Software = "Unsupported"
return o return o
} else { } else {
@ -139,7 +133,7 @@ func GetInstanceInfo(endpoint string, o shared.RunningInstance) shared.RunningIn
} }
if respActual.StatusCode != 200 { if respActual.StatusCode != 200 {
fmt.Println("Exit 6") logDebug("GetInstanceInfo for ", endpoint, " Non-200 for " + wellknown_nodeinfo_uri)
o.Software = "Unsupported" o.Software = "Unsupported"
return o return o
} }
@ -147,15 +141,13 @@ func GetInstanceInfo(endpoint string, o shared.RunningInstance) shared.RunningIn
var actualnodeinfo shared.ActualNodeInfo var actualnodeinfo shared.ActualNodeInfo
err = json.NewDecoder(respActual.Body).Decode(&actualnodeinfo) err = json.NewDecoder(respActual.Body).Decode(&actualnodeinfo)
if (err != nil) { if (err != nil) {
fmt.Println("Exit 7") logDebug("GetInstanceInfo for ", endpoint, " Unable to decode " + actual_nodeinfo_uri)
fmt.Println(err)
o.Software = "Unsupported" o.Software = "Unsupported"
return o return o
} }
fmt.Println(actualnodeinfo) o.Software = actualnodeinfo.Software.Name
fmt.Println("Final exit") o.Version = actualnodeinfo.Software.Version
os.Exit(1)
return o return o
} }