MCPcopy Create free account
hub / github.com/blues/note / DebugSet

Function DebugSet

lib/debug.go:63–91  ·  view source on GitHub ↗

DebugSet sets the debug variable

(which string, value string)

Source from the content-addressed store, hash-verified

61
62// DebugSet sets the debug variable
63func DebugSet(which string, value string) {
64 // Convert the value as appropriate
65 boolValue := false
66 lcValue := strings.ToLower(value)
67 if lcValue == "t" || lcValue == "true" || lcValue == "on" {
68 boolValue = true
69 } else if lcValue == "f" || lcValue == "false" || lcValue == "off" {
70 boolValue = false
71 } else {
72 i, err := strconv.Atoi(value)
73 if err == nil {
74 if i != 0 {
75 boolValue = true
76 }
77 }
78 }
79
80 // Find the string
81 for i := range text {
82 if text[i] == which {
83 *(vars[i]) = boolValue
84 logInfo(context.Background(), "%s is now %t", which, boolValue)
85 return
86 }
87 }
88
89 // Failure
90 logError(context.Background(), "notelib debug setting %s not found", which)
91}
92
93// Get the value of a boolean environment variable
94func debugEnv(which string) (isAvail bool, value bool) {

Callers

nothing calls this directly

Calls 2

logInfoFunction · 0.85
logErrorFunction · 0.85

Tested by

no test coverage detected