You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
starlog/standed.go

272 lines
4.3 KiB
Go

package starlog
import (
"io"
"math/rand"
"sync"
"time"
)
var Std *StarLogger
var stdmu sync.Mutex
func init() {
rand.Seed(time.Now().UnixNano())
stackStopChan = make(chan int)
StartStacks()
Std = NewStarlog(nil)
}
func SetShowColor(val bool) {
Std.SetShowColor(val)
}
func GetShowColor() bool {
return Std.GetShowColor()
}
func SetLevelColor(level int, color []Attr) {
Std.SetLevelColor(level, color)
}
func GetLevelColor(level int) []Attr {
return Std.GetLevelColor(level)
}
func Debug(str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Debug(str...)
Std.isStd = false
}
func Debugf(format string, str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Debugf(format, str...)
Std.isStd = false
}
func Debugln(str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Debugln(str...)
Std.isStd = false
}
func Info(str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Info(str...)
Std.isStd = false
}
func Infof(format string, str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Infof(format, str...)
Std.isStd = false
}
func Infoln(str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Infoln(str...)
Std.isStd = false
}
func Notice(str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Notice(str...)
Std.isStd = false
}
func Noticef(format string, str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Noticef(format, str...)
Std.isStd = false
}
func Noticeln(str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Noticeln(str...)
Std.isStd = false
}
func Warning(str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Warning(str...)
Std.isStd = false
}
func Warningf(format string, str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Warningf(format, str...)
Std.isStd = false
}
func Warningln(str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Warningln(str...)
Std.isStd = false
}
func Error(str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Error(str...)
Std.isStd = false
}
func Errorf(format string, str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Errorf(format, str...)
Std.isStd = false
}
func Errorln(str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Errorln(str...)
Std.isStd = false
}
func Critical(str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Critical(str...)
Std.isStd = false
}
func Criticalf(format string, str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Criticalf(format, str...)
Std.isStd = false
}
func Criticalln(str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Criticalln(str...)
Std.isStd = false
}
func Fatal(str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Fatal(str...)
Std.isStd = false
}
func Fatalf(format string, str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Fatalf(format, str...)
Std.isStd = false
}
func Panicln(str ...interface{}) {
stdmu.Lock()
defer stdmu.Unlock()
Std.isStd = true
Std.Fatal(str...)
Std.isStd = false
}
func SetWriter(wr io.Writer) {
Std.SetWriter(wr)
}
func GetWriter() io.Writer {
return Std.GetWriter()
}
func SetHandler(f func([]Attr, string)) {
Std.SetHandler(f)
}
func GetHandler() func([]Attr, string) {
return Std.GetHandler()
}
func SetSwitching(sw bool) {
Std.SetSwitching(sw)
}
func SetShowOriginFile(val bool) {
Std.SetShowOriginFile(val)
}
func GetShowOriginFile() bool {
return Std.GetShowOriginFile()
}
func SetShowFuncName(val bool) {
Std.logcore.showFuncName = val
}
func GetShowFuncName() bool {
return Std.logcore.showFuncName
}
func SetShowLevel(val bool) {
Std.SetShowLevel(val)
}
func GetShowLevel() bool {
return Std.GetShowLevel()
}
func SetShowFlag(val bool) {
Std.SetShowFlag(val)
}
func GetShowFlag() bool {
return Std.GetShowFlag()
}
func SetShowStd(val bool) {
Std.SetShowStd(val)
}
func GetShowStd() bool {
return Std.GetShowStd()
}
func StopWrite() {
Std.StopWrite()
}
func EnbaleWrite() {
Std.EnbaleWrite()
}
func IsWriteStoed() bool {
return Std.IsWriteStoed()
}