added logrptate policy
This commit is contained in:
parent
27c1d2ff41
commit
9b8d325761
|
@ -5,6 +5,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"log"
|
"log"
|
||||||
"amuz.es/src/infra/goutils/logger"
|
"amuz.es/src/infra/goutils/logger"
|
||||||
|
"github.com/lestrrat-go/file-rotatelogs"
|
||||||
)
|
)
|
||||||
|
|
||||||
var loggers RotateSyncerSet
|
var loggers RotateSyncerSet
|
||||||
|
@ -21,7 +22,8 @@ func NewLogWriter(FileName string, logDir string, options ...Option) (logger.Rot
|
||||||
logpath = path.Join(logDir, FileName)
|
logpath = path.Join(logDir, FileName)
|
||||||
}
|
}
|
||||||
log.Println(" Attention!! log writes to ", logpath)
|
log.Println(" Attention!! log writes to ", logpath)
|
||||||
if logWriter, err := NewRotater(logpath, options...); err != nil {
|
options=append(options,rotatelogs.WithLinkName(logpath))
|
||||||
|
if logWriter, err := NewRotater(logpath+".%Y%M%D", options...); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
loggers.Store(logWriter)
|
loggers.Store(logWriter)
|
||||||
|
|
Reference in New Issue