aboutsummaryrefslogtreecommitdiff
path: root/clog/clog.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-01-13 14:25:20 +0800
committerRunxi Yu <me@runxiyu.org>2025-01-13 14:25:20 +0800
commit2daa71bfa25602aace728831c46a12d640f6998f (patch)
treefd672cd4c112d11e6453204812c4309354d9e932 /clog/clog.go
parentReformat code (diff)
downloadgo-lindenii-common-2daa71bfa25602aace728831c46a12d640f6998f.tar.gz
go-lindenii-common-2daa71bfa25602aace728831c46a12d640f6998f.tar.zst
go-lindenii-common-2daa71bfa25602aace728831c46a12d640f6998f.zip
clog: Non-structured functionsHEADmaster
Diffstat (limited to '')
-rw-r--r--clog/clog.go39
1 files 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)
}