klog/std.go

115 lines
1.8 KiB
Go
Raw Normal View History

2021-11-01 14:41:11 +00:00
package log
2021-11-03 05:51:59 +00:00
import (
"io"
"text/template"
"kumoly.io/core/log/color"
)
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-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)
}
func Reload() error {
return std.Reload()
}
func ReloadAll() error {
return std.ReloadAll()
}
2021-11-03 05:51:59 +00:00
func DefaultFuncMap() template.FuncMap {
return std.DefaultFuncMap()
}
func ParseTmpl() error {
return std.ParseTmpl()
}
func SetTmpl(formatter *LogFormater, funcMap template.FuncMap) {
std.SetTmpl(formatter, funcMap)
}
2021-11-01 14:41:11 +00:00
func ErrorF(fields H, v ...interface{}) {
if PROD {
std.output(terror, 3, "", fields, v...)
} else {
std.output(terror, 3, stack(), fields, v...)
}
}
func Error(v ...interface{}) {
if PROD {
std.output(terror, 3, "", H{}, v...)
} else {
std.output(terror, 3, stack(), H{}, v...)
}
}
func DebugF(fields H, v ...interface{}) {
if PROD {
std.output(tdebug, 3, "", fields, v...)
} else {
std.output(tdebug, 3, stack(), fields, v...)
}
}
func Debug(v ...interface{}) {
if PROD {
std.output(tdebug, 3, "", H{}, v...)
} else {
std.output(tdebug, 3, stack(), H{}, v...)
}
}
func WarnF(fields H, v ...interface{}) {
std.output(twarn, 3, "", fields, v...)
}
func Warn(v ...interface{}) {
std.output(twarn, 3, "", H{}, v...)
}
func InfoF(fields H, v ...interface{}) {
std.output(tinfo, 3, "", fields, v...)
}
func Info(v ...interface{}) {
std.output(tinfo, 3, "", H{}, v...)
}