aboutsummaryrefslogtreecommitdiff
path: root/meselog/meselog.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2024-12-12 08:05:46 +0800
committerRunxi Yu <me@runxiyu.org>2024-12-12 08:05:46 +0800
commit3b7e9385f3004fa70ce4ee5b3e8e6abdb7bd2f10 (patch)
treea9c6a02223b1e4f18390e075ea9fd0351953b4c0 /meselog/meselog.go
parentUse CID instead of connection pointers while logging (diff)
downloadmeseircd-3b7e9385f3004fa70ce4ee5b3e8e6abdb7bd2f10.tar.gz
meseircd-3b7e9385f3004fa70ce4ee5b3e8e6abdb7bd2f10.tar.zst
meseircd-3b7e9385f3004fa70ce4ee5b3e8e6abdb7bd2f10.zip
Use meselog instead of slog
Diffstat (limited to 'meselog/meselog.go')
-rw-r--r--meselog/meselog.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/meselog/meselog.go b/meselog/meselog.go
new file mode 100644
index 0000000..d9c84f5
--- /dev/null
+++ b/meselog/meselog.go
@@ -0,0 +1,26 @@
+package meselog
+
+import (
+ "fmt"
+)
+
+func log(str string, keyvals []any) {
+ fmt.Print(str+" ")
+ for i, j := range keyvals {
+ if i & 1 == 0 {
+ fmt.Printf("%v=", j)
+ } else if i == len(keyvals) - 1 {
+ fmt.Printf("%#v", j)
+ } else {
+ fmt.Printf("%#v ", j)
+ }
+ }
+ fmt.Print("\n")
+}
+
+func Error(str string, keyvals ...any) {
+ log("ERROR "+str, keyvals)
+}
+func Debug(str string, keyvals ...any) {
+ log("DEBUG "+str, keyvals)
+}