logger模块移入go-admin-core仓库,修改log用法暂时折中

fixme:后期要尽快改成统一的log处理方式
This commit is contained in:
linwenxiang committed 2020-10-26 22:37:44 +08:00
1 parent a68e58f93b
commit da4637d285
27 files changed
+119 -784

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
package mycasbin
import (
"sync/atomic"
"github.com/go-admin-team/go-admin-core/logger"
)
// Logger is the implementation for a Logger using golang log.
type Logger struct {
enable int32
}
func (l *Logger) EnableLog(enable bool) {
i := 0
if enable {
i = 1
}
atomic.StoreInt32(&(l.enable), int32(i))
}
func (l *Logger) IsEnabled() bool {
return atomic.LoadInt32(&(l.enable)) != 0
}
func (l *Logger) Print(v ...interface{}) {
if l.IsEnabled() {
logger.DefaultLogger.Log(logger.InfoLevel, v...)
}
}
func (l *Logger) Printf(format string, v ...interface{}) {
if l.IsEnabled() {
logger.DefaultLogger.Logf(logger.InfoLevel, format, v...)
}
}