From 2daa71bfa25602aace728831c46a12d640f6998f Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Mon, 13 Jan 2025 14:25:20 +0800 Subject: clog: Non-structured functions --- clog/clog.go | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/clog/clog.go b/clog/clog.go index 0483585..1b1d8c3 100644 --- a/clog/clog.go +++ b/clog/clog.go @@ -6,7 +6,7 @@ import ( "os" ) -func log(str string, keyvals []any) { +func logs(str string, keyvals []any) { fmt.Fprint(os.Stderr, str) if len(keyvals) != 0 { fmt.Fprint(os.Stderr, " ") @@ -23,23 +23,48 @@ func log(str string, keyvals []any) { fmt.Fprintln(os.Stderr) } -func Error(str string, keyvals ...any) { - log("\x1b[1;91mERROR: "+str, keyvals) +func Errors(str string, keyvals ...any) { + logs("\x1b[1;91mERROR: "+str, keyvals) +} + +func Warns(str string, keyvals ...any) { + logs("\x1b[1;93mWARNING: "+str, keyvals) +} + +func Debugs(str string, keyvals ...any) { + logs("\x1b[90mDEBUG: "+str, keyvals) +} + +func Infos(str string, keyvals ...any) { + logs("\x1b[0mINFO: "+str, keyvals) +} + +func Fatals(exit int, str string, keyvals ...any) { + logs("\x1b[1;35mFATAL: "+str, keyvals) + os.Exit(exit) +} + +func log(str string) { + fmt.Fprintln(os.Stderr, str) +} + +func Error(str string) { + log("\x1b[1;91mERROR: "+str) } func Warn(str string, keyvals ...any) { - log("\x1b[1;93mWARNING: "+str, keyvals) + log("\x1b[1;93mWARNING: "+str) } func Debug(str string, keyvals ...any) { - log("\x1b[90mDEBUG: "+str, keyvals) + log("\x1b[90mDEBUG: "+str) } func Info(str string, keyvals ...any) { - log("\x1b[0mINFO: "+str, keyvals) + log("\x1b[0mINFO: "+str) } func Fatal(exit int, str string, keyvals ...any) { - log("\x1b[1;35mFATAL: "+str, keyvals) + log("\x1b[1;35mFATAL: "+str) os.Exit(exit) } -- cgit v1.2.3