klog/std.go

88 lines
1.3 KiB
Go
Raw Permalink Normal View History

2021-11-03 19:02:27 +00:00
package klog
2021-11-01 14:41:11 +00:00
2021-11-03 05:51:59 +00:00
import (
"io"
2021-11-03 18:56:46 +00:00
"kumoly.io/lib/klog/color"
2021-11-03 05:51:59 +00:00
)
2021-11-02 03:08:23 +00:00
var std = New("")
2021-11-01 14:41:11 +00:00
2021-11-03 15:05:38 +00:00
func DefaultLogger() *Logger {
return std
}
2021-11-05 07:41:54 +00:00
func SetPrinter(p Printer) {
std.printer = p
}
func SetPrinterAll(p Printer) {
for _, v := range getAllOffsprings(std) {
v.SetPrinter(p)
}
}
2021-11-03 05:51:59 +00:00
func M(s interface{}, attrs ...color.Attribute) string {
return std.M(s, attrs...)
}
2021-11-01 18:07:05 +00:00
func Sub(sys string) *Logger {
2021-11-01 14:41:11 +00:00
return std.Sub(sys)
}
2021-11-02 03:08:23 +00:00
func SetColor(c bool) {
std.SetColor(c)
}
2021-11-02 07:26:10 +00:00
func SetColorAll(c bool) {
std.SetColorAll(c)
}
2021-11-02 03:08:23 +00:00
func SetErrOutput(err io.Writer) {
std.SetErrOutput(err)
}
func SetErrOutputAll(err io.Writer) {
std.SetErrOutputAll(err)
}
func SetOutput(out io.Writer) {
std.SetOutput(out)
}
func SetOutputAll(out io.Writer) {
std.SetOutputAll(out)
}
2021-11-01 14:41:11 +00:00
func ErrorF(fields H, v ...interface{}) {
2021-11-05 07:41:54 +00:00
std.output(Lerror, 3, fields, v...)
2021-11-01 14:41:11 +00:00
}
func Error(v ...interface{}) {
2021-11-05 07:41:54 +00:00
std.output(Lerror, 3, H{}, v...)
2021-11-01 14:41:11 +00:00
}
func DebugF(fields H, v ...interface{}) {
2021-11-05 07:41:54 +00:00
std.output(Ldebug, 3, fields, v...)
2021-11-01 14:41:11 +00:00
}
func Debug(v ...interface{}) {
2021-11-05 07:41:54 +00:00
std.output(Ldebug, 3, H{}, v...)
2021-11-01 14:41:11 +00:00
}
func WarnF(fields H, v ...interface{}) {
2021-11-05 07:41:54 +00:00
std.output(Lwarn, 3, fields, v...)
2021-11-01 14:41:11 +00:00
}
func Warn(v ...interface{}) {
2021-11-05 07:41:54 +00:00
std.output(Lwarn, 3, H{}, v...)
2021-11-01 14:41:11 +00:00
}
func InfoF(fields H, v ...interface{}) {
2021-11-05 07:41:54 +00:00
std.output(Linfo, 3, fields, v...)
2021-11-01 14:41:11 +00:00
}
func Info(v ...interface{}) {
2021-11-05 07:41:54 +00:00
std.output(Linfo, 3, H{}, v...)
2021-11-01 14:41:11 +00:00
}