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.
324 lines
5.4 KiB
Go
324 lines
5.4 KiB
Go
package starlog
|
|
|
|
import (
|
|
"fmt"
|
|
"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.Fatalln(str...)
|
|
Std.isStd = false
|
|
}
|
|
|
|
func Print(str ...interface{}) {
|
|
Std.Print(str...)
|
|
}
|
|
|
|
func Printf(format string, str ...interface{}) {
|
|
Std.Printf(format, str...)
|
|
}
|
|
|
|
func Println(str ...interface{}) {
|
|
Std.Println(str...)
|
|
}
|
|
|
|
func Log(isShow bool, level int, str ...interface{}) {
|
|
stdmu.Lock()
|
|
defer stdmu.Unlock()
|
|
Std.isStd = true
|
|
Std.Log(isShow, level, str...)
|
|
Std.isStd = false
|
|
}
|
|
|
|
func Logf(isShow bool, level int, format string, str ...interface{}) {
|
|
stdmu.Lock()
|
|
defer stdmu.Unlock()
|
|
Std.isStd = true
|
|
Std.Logf(isShow, level, format, str...)
|
|
Std.isStd = false
|
|
}
|
|
|
|
func Logln(isShow bool, level int, str ...interface{}) {
|
|
stdmu.Lock()
|
|
defer stdmu.Unlock()
|
|
Std.isStd = true
|
|
Std.Logln(isShow, level, str...)
|
|
Std.isStd = false
|
|
}
|
|
|
|
func StdPrint(attr []Attr, str ...interface{}) {
|
|
strs := fmt.Sprint(str...)
|
|
NewColor(attr...).Fprint(stdScreen, strs)
|
|
}
|
|
|
|
func StdPrintf(attr []Attr, format string, str ...interface{}) {
|
|
strs := fmt.Sprintf(format, str...)
|
|
NewColor(attr...).Fprint(stdScreen, strs)
|
|
}
|
|
|
|
func StdPrintln(attr []Attr, str ...interface{}) {
|
|
strs := fmt.Sprintln(str...)
|
|
NewColor(attr...).Fprint(stdScreen, strs)
|
|
}
|
|
|
|
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()
|
|
}
|