2
0
abhishek9686 2 долоо хоног өмнө
parent
commit
e81d50cbb4
2 өөрчлөгдсөн 13 нэмэгдсэн , 3 устгасан
  1. 5 0
      logic/hosts.go
  2. 8 3
      utils/utils.go

+ 5 - 0
logic/hosts.go

@@ -617,6 +617,11 @@ func GetRelatedHosts(hostID string) []models.Host {
 // with the same endpoint have different listen ports
 // in the case of 64535 hosts or more with same endpoint, ports will not be changed
 func CheckHostPorts(h *models.Host) (changed bool) {
+	utils.TraceCaller()
+	fmt.Println("=======> CHECKING HOST PORTS for HOST", h.Name, h.ListenPort)
+	defer func() {
+		fmt.Println("=======> CHECKED HOST PORTS for HOST", h.Name, h.ListenPort)
+	}()
 	portsInUse := make(map[int]bool, 0)
 	hosts, err := GetAllHosts()
 	if err != nil {

+ 8 - 3
utils/utils.go

@@ -57,13 +57,18 @@ func TraceCaller() {
 		slog.Debug("Unable to get caller information")
 		return
 	}
-
+	tracePc, _, _, ok := runtime.Caller(1)
+	if !ok {
+		slog.Debug("Unable to get caller information")
+		return
+	}
+	traceFuncName := runtime.FuncForPC(tracePc).Name()
 	// Get function name from the program counter (pc)
 	funcName := runtime.FuncForPC(pc).Name()
 
 	// Print trace details
-	slog.Debug("Called from function: %s\n", "func", funcName)
-	slog.Debug("File: %s, Line: %d\n", "file", file, "line", line)
+	fmt.Println("## TRACE -> Called from function: ", "tracing-func-name", traceFuncName, "caller-func-name", funcName)
+	fmt.Println("## TRACE -> Caller File Info", "file", file, "line-no", line)
 }
 
 // NoEmptyStringToCsv takes a bunch of strings, filters out empty ones and returns a csv version of the string