summaryrefslogtreecommitdiff
path: root/flags.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-12-31 10:45:04 -0600
committerJeff Carr <[email protected]>2023-12-31 10:45:04 -0600
commitf98207af0a8783465f003bbcdc7819f545090f43 (patch)
tree9c88dbfc6802f356ca261e2b61dd9b296eb32769 /flags.go
parentae261633933db2a4870a8556dd4ed11727adc6b7 (diff)
more comments and code re-arrangement
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'flags.go')
-rw-r--r--flags.go69
1 files changed, 69 insertions, 0 deletions
diff --git a/flags.go b/flags.go
new file mode 100644
index 0000000..08e9c8d
--- /dev/null
+++ b/flags.go
@@ -0,0 +1,69 @@
+package log
+
+import (
+ "errors"
+)
+
+var INFO bool = true
+var WARN bool = true
+var ERROR bool = true
+
+var VERBOSE bool = false
+var SPEW bool = false
+
+func All(b bool) {
+ Set("SPEW", b)
+ Set("INFO", b)
+ Set("WARN", b)
+ Set("ERROR", b)
+ Set("VERBOSE", b)
+}
+
+func ListAll() []string {
+ var all []string
+
+ all = []string{"SPEW","INFO", "WARN", "ERROR", "VERBOSE"}
+
+ return all
+}
+
+func Set(flag string, b bool) {
+ switch flag {
+ case "INFO":
+ INFO = b
+ case "WARN":
+ WARN = b
+ case "SPEW":
+ SPEW = b
+ case "ERROR":
+ ERROR = b
+ case "VERBOSE":
+ VERBOSE = b
+ default:
+ Error(errors.New("unknown flag"), "Flag name sent:", flag)
+ }
+}
+
+func Get(flag string) bool {
+ switch flag {
+ case "INFO":
+ return INFO
+ case "WARN":
+ return WARN
+ case "SPEW":
+ return SPEW
+ case "ERROR":
+ return ERROR
+ case "VERBOSE":
+ return VERBOSE
+ default:
+ Error(errors.New("unknown flag"), "Flag name sent:", flag)
+ }
+ return false
+}
+
+// register a variable name from a subsystem
+// this is used for custom log flags
+func Register(subsystem string, name string) {
+ Info("log.Register() got subsystem", subsystem, "with name =", name)
+}