klog/std.go

115 lines
1.8 KiB
Go

package klog
import (
"io"
"text/template"
"kumoly.io/lib/klog/color"
)
var std = New("")
func DefaultLogger() *Logger {
return std
}
func M(s interface{}, attrs ...color.Attribute) string {
return std.M(s, attrs...)
}
func Sub(sys string) *Logger {
return std.Sub(sys)
}
func SetColor(c bool) {
std.SetColor(c)
}
func SetColorAll(c bool) {
std.SetColorAll(c)
}
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()
}
func DefaultFuncMap() template.FuncMap {
return std.DefaultFuncMap()
}
func ParseTmpl() error {
return std.ParseTmpl()
}
func SetTmpl(formatter *LogFormater, funcMap template.FuncMap) {
std.SetTmpl(formatter, funcMap)
}
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...)
}