mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 13:50:54 +00:00
remove from init method
This commit is contained in:
parent
e59271662c
commit
826f81f479
3
log.go
3
log.go
@ -32,6 +32,9 @@ const (
|
|||||||
LevelDebug
|
LevelDebug
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// BeeLogger references the used application logger.
|
||||||
|
var BeeLogger = logs.GetBeeLogger()
|
||||||
|
|
||||||
// SetLevel sets the global log level used by the simple logger.
|
// SetLevel sets the global log level used by the simple logger.
|
||||||
func SetLevel(l int) {
|
func SetLevel(l int) {
|
||||||
logs.SetLevel(l)
|
logs.SetLevel(l)
|
||||||
|
18
logs/log.go
18
logs/log.go
@ -120,6 +120,8 @@ type BeeLogger struct {
|
|||||||
outputs []*nameLogger
|
outputs []*nameLogger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaultAsyncMsgLen = 1e3
|
||||||
|
|
||||||
type nameLogger struct {
|
type nameLogger struct {
|
||||||
Logger
|
Logger
|
||||||
name string
|
name string
|
||||||
@ -157,6 +159,9 @@ func (bl *BeeLogger) Async() *BeeLogger {
|
|||||||
return bl
|
return bl
|
||||||
}
|
}
|
||||||
bl.asynchronous = true
|
bl.asynchronous = true
|
||||||
|
if bl.msgChanLen <= 0 {
|
||||||
|
bl.msgChanLen = defaultAsyncMsgLen
|
||||||
|
}
|
||||||
bl.msgChan = make(chan *logMsg, bl.msgChanLen)
|
bl.msgChan = make(chan *logMsg, bl.msgChanLen)
|
||||||
logMsgPool = &sync.Pool{
|
logMsgPool = &sync.Pool{
|
||||||
New: func() interface{} {
|
New: func() interface{} {
|
||||||
@ -250,6 +255,11 @@ func (bl *BeeLogger) Write(p []byte) (n int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (bl *BeeLogger) writeMsg(logLevel int, msg string, v ...interface{}) error {
|
func (bl *BeeLogger) writeMsg(logLevel int, msg string, v ...interface{}) error {
|
||||||
|
if !beeLogger.init {
|
||||||
|
bl.lock.Lock()
|
||||||
|
bl.setLogger(AdapterConsole)
|
||||||
|
bl.lock.Unlock()
|
||||||
|
}
|
||||||
if logLevel == levelLoggerImpl {
|
if logLevel == levelLoggerImpl {
|
||||||
// set to emergency to ensure all log will be print out correctly
|
// set to emergency to ensure all log will be print out correctly
|
||||||
logLevel = LevelEmergency
|
logLevel = LevelEmergency
|
||||||
@ -465,12 +475,8 @@ func (bl *BeeLogger) flush() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BeeLogger references the used application logger.
|
// beeLogger references the used application logger.
|
||||||
var beeLogger *BeeLogger
|
var beeLogger *BeeLogger = NewLogger()
|
||||||
|
|
||||||
func init() {
|
|
||||||
beeLogger = NewLogger()
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetLogger returns the default BeeLogger
|
// GetLogger returns the default BeeLogger
|
||||||
func GetBeeLogger() *BeeLogger {
|
func GetBeeLogger() *BeeLogger {
|
||||||
|
Loading…
Reference in New Issue
Block a user