From 3b7e9385f3004fa70ce4ee5b3e8e6abdb7bd2f10 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 12 Dec 2024 08:05:46 +0800 Subject: Use meselog instead of slog --- meselog/meselog.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 meselog/meselog.go (limited to 'meselog/meselog.go') 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) +} -- cgit v1.2.3