mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 22:01:29 +00:00
Merge pull request #1837 from JessonChan/develop
add function of beego/logs
This commit is contained in:
commit
220cf91180
19
logs/log.go
19
logs/log.go
@ -152,13 +152,16 @@ func NewLogger(channelLens ...int64) *BeeLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Async set the log to asynchronous and start the goroutine
|
// Async set the log to asynchronous and start the goroutine
|
||||||
func (bl *BeeLogger) Async() *BeeLogger {
|
func (bl *BeeLogger) Async(msgLen ...int64) *BeeLogger {
|
||||||
bl.lock.Lock()
|
bl.lock.Lock()
|
||||||
defer bl.lock.Unlock()
|
defer bl.lock.Unlock()
|
||||||
if bl.asynchronous {
|
if bl.asynchronous {
|
||||||
return bl
|
return bl
|
||||||
}
|
}
|
||||||
bl.asynchronous = true
|
bl.asynchronous = true
|
||||||
|
if len(msgLen) > 0 && msgLen[0] > 0 {
|
||||||
|
bl.msgChanLen = msgLen[0]
|
||||||
|
}
|
||||||
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{} {
|
||||||
@ -515,8 +518,8 @@ func Reset() {
|
|||||||
beeLogger.Reset()
|
beeLogger.Reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
func Async() *BeeLogger {
|
func Async(msgLen ...int64) *BeeLogger {
|
||||||
return beeLogger.Async()
|
return beeLogger.Async(msgLen...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLevel sets the global log level used by the simple logger.
|
// SetLevel sets the global log level used by the simple logger.
|
||||||
@ -524,12 +527,22 @@ func SetLevel(l int) {
|
|||||||
beeLogger.SetLevel(l)
|
beeLogger.SetLevel(l)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EnableFuncCallDepth enable log funcCallDepth
|
||||||
|
func EnableFuncCallDepth(b bool) {
|
||||||
|
beeLogger.enableFuncCallDepth = b
|
||||||
|
}
|
||||||
|
|
||||||
// SetLogFuncCall set the CallDepth, default is 3
|
// SetLogFuncCall set the CallDepth, default is 3
|
||||||
func SetLogFuncCall(b bool) {
|
func SetLogFuncCall(b bool) {
|
||||||
beeLogger.EnableFuncCallDepth(b)
|
beeLogger.EnableFuncCallDepth(b)
|
||||||
beeLogger.SetLogFuncCallDepth(3)
|
beeLogger.SetLogFuncCallDepth(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetLogFuncCallDepth set log funcCallDepth
|
||||||
|
func SetLogFuncCallDepth(d int) {
|
||||||
|
beeLogger.loggerFuncCallDepth = d
|
||||||
|
}
|
||||||
|
|
||||||
// SetLogger sets a new logger.
|
// SetLogger sets a new logger.
|
||||||
func SetLogger(adapter string, config ...string) error {
|
func SetLogger(adapter string, config ...string) error {
|
||||||
err := beeLogger.SetLogger(adapter, config...)
|
err := beeLogger.SetLogger(adapter, config...)
|
||||||
|
Loading…
Reference in New Issue
Block a user