aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2024-12-29 18:50:15 +0000
committerRunxi Yu <me@runxiyu.org>2024-12-29 18:50:15 +0000
commit8a44a65d66335696c9c38a9a04b43bac61545b22 (patch)
treec4315bd5e4d314a35ba2ee1a39f014962578b8fd
parentAdd ~emersion/go-scfg as a subdirectory (diff)
downloadgo-lindenii-common-8a44a65d66335696c9c38a9a04b43bac61545b22.tar.gz
go-lindenii-common-8a44a65d66335696c9c38a9a04b43bac61545b22.tar.zst
go-lindenii-common-8a44a65d66335696c9c38a9a04b43bac61545b22.zip
Add clog
-rw-r--r--clog/clog.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/clog/clog.go b/clog/clog.go
new file mode 100644
index 0000000..464c193
--- /dev/null
+++ b/clog/clog.go
@@ -0,0 +1,28 @@
+package clog
+
+import (
+ "fmt"
+ "os"
+)
+
+func log(str string, keyvals []any) {
+ fmt.Print(str + " ")
+ for i, j := range keyvals {
+ if i&1 == 0 {
+ fmt.Fprintf(os.Stderr, "%v=", j)
+ } else if i == len(keyvals)-1 {
+ fmt.Fprintf(os.Stderr, "%#v", j)
+ } else {
+ fmt.Fprintf(os.Stderr, "%#v ", j)
+ }
+ }
+ fmt.Fprintln(os.Stderr, "\n")
+}
+
+func Error(str string, keyvals ...any) {
+ log("ERROR "+str, keyvals)
+}
+
+func Debug(str string, keyvals ...any) {
+ log("DEBUG "+str, keyvals)
+}