summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-12-29 17:24:39 -0600
committerJeff Carr <[email protected]>2023-12-29 17:24:39 -0600
commit424a1b42e294e89a6f893196ebf23ba3d20572db (patch)
tree7a890f12827edc6d2cbb4cb9221322149ecac3a6
parent5766e86595bb7bc4c16c37f8ed47bcf0db25d82b (diff)
using args.Register()
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--args.go22
-rw-r--r--bool.go10
-rw-r--r--log.go8
3 files changed, 40 insertions, 0 deletions
diff --git a/args.go b/args.go
new file mode 100644
index 0000000..87deb0f
--- /dev/null
+++ b/args.go
@@ -0,0 +1,22 @@
+package log
+
+import (
+ arg "github.com/alexflint/go-arg"
+)
+
+//
+// Attempt to switch logging to syslog on linux
+//
+
+var argLog ArgLog
+
+// This struct can be used with the go-arg package
+type ArgLog struct {
+ LogTmp bool `arg:"--log-tmp" help:"send all output /tmp"`
+ LogStdout bool `arg:"--log-stdout" help:"send all output to STDOUT"`
+ LogQuiet bool `arg:"--log-quiet" help:"suppress all output"`
+}
+
+func init() {
+ arg.Register(&argLog)
+}
diff --git a/bool.go b/bool.go
new file mode 100644
index 0000000..f2d638d
--- /dev/null
+++ b/bool.go
@@ -0,0 +1,10 @@
+package log
+
+import (
+ golanglog "log"
+)
+
+func Bool(b bool, a ...any) {
+ if ! b {return}
+ golanglog.Println(a...)
+}
diff --git a/log.go b/log.go
index e294b73..675bfe3 100644
--- a/log.go
+++ b/log.go
@@ -7,3 +7,11 @@ import (
func Println(a ...any) {
origlog.Println(a...)
}
+
+func Fatalf(s string, a ...any) {
+ origlog.Fatalf(s, a...)
+}
+
+func Fatal(s string, a ...any) {
+ origlog.Fatalf(s, a...)
+}