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

49 lines
978 B

/*
------------------------------------------------------------------------------------------------------------------------
####### logger ####### Copyright (c) 2021-2022 losyme ############################################## MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package logger
import (
"sync"
"time"
)
var _logPool = newLogPool()
type Log struct {
Time time.Time
Logger *Logger
Level Level
Msg string
KV []interface{}
}
type logPool struct {
sp *sync.Pool
}
func newLogPool() *logPool {
return &logPool{
sp: &sync.Pool{
New: func() interface{} {
return new(Log)
},
},
}
}
func (lp *logPool) Get() *Log {
return lp.sp.Get().(*Log)
}
func (lp *logPool) Put(l *Log) {
l.KV = l.KV[:0]
lp.sp.Put(l)
}
/*
######################################################################################################## @(°_°)@ #######
*/