more logging
This commit is contained in:
@@ -3,9 +3,11 @@ package tasks
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"vctp/db/queries"
|
"vctp/db/queries"
|
||||||
@@ -111,6 +113,12 @@ func (c *CronTask) AddVmToInventory(vmObject *mo.VirtualMachine, vc *vcenter.Vce
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.Logger.Debug("found VM")
|
c.Logger.Debug("found VM")
|
||||||
|
|
||||||
|
if vmObject.Name == "DBRaaS_testVMTemplate" {
|
||||||
|
c.Logger.Debug("Found problematic VM")
|
||||||
|
prettyPrint(vmObject)
|
||||||
|
}
|
||||||
|
|
||||||
srmPlaceholder = "FALSE" // Default assumption
|
srmPlaceholder = "FALSE" // Default assumption
|
||||||
//prettyPrint(vmObject)
|
//prettyPrint(vmObject)
|
||||||
|
|
||||||
@@ -230,3 +238,31 @@ func (c *CronTask) AddVmToInventory(vmObject *mo.VirtualMachine, vc *vcenter.Vce
|
|||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prettyPrint comes from https://gist.github.com/sfate/9d45f6c5405dc4c9bf63bf95fe6d1a7c
|
||||||
|
func prettyPrint(args ...interface{}) {
|
||||||
|
var caller string
|
||||||
|
|
||||||
|
timeNow := time.Now().Format("01-02-2006 15:04:05")
|
||||||
|
prefix := fmt.Sprintf("[%s] %s -- ", "PrettyPrint", timeNow)
|
||||||
|
_, fileName, fileLine, ok := runtime.Caller(1)
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
caller = fmt.Sprintf("%s:%d", fileName, fileLine)
|
||||||
|
} else {
|
||||||
|
caller = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("\n%s%s\n", prefix, caller)
|
||||||
|
|
||||||
|
if len(args) == 2 {
|
||||||
|
label := args[0]
|
||||||
|
value := args[1]
|
||||||
|
|
||||||
|
s, _ := json.MarshalIndent(value, "", "\t")
|
||||||
|
fmt.Printf("%s%s: %s\n", prefix, label, string(s))
|
||||||
|
} else {
|
||||||
|
s, _ := json.MarshalIndent(args, "", "\t")
|
||||||
|
fmt.Printf("%s%s\n", prefix, string(s))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user