mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 08:48:32 +02:00
feat: tunable rotate interval
This commit is contained in:
@@ -66,8 +66,8 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
flushInterval = 30 * time.Second
|
||||
rotateInterval = time.Hour
|
||||
flushInterval = 30 * time.Second
|
||||
defaultRotateInterval = time.Hour
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -117,6 +117,9 @@ func NewAccessLoggerWithIO(parent task.Parent, writer WriterWithName, anyCfg Any
|
||||
if _, ok := writer.(*os.File); ok {
|
||||
cfg.BufferSize = StdoutbufSize
|
||||
}
|
||||
if cfg.RotateInterval == 0 {
|
||||
cfg.RotateInterval = defaultRotateInterval
|
||||
}
|
||||
|
||||
l := &AccessLogger{
|
||||
task: parent.Subtask("accesslog."+writer.Name(), true),
|
||||
@@ -238,7 +241,7 @@ func (l *AccessLogger) start() {
|
||||
flushTicker := time.NewTicker(30 * time.Second)
|
||||
defer flushTicker.Stop()
|
||||
|
||||
rotateTicker := time.NewTicker(rotateInterval)
|
||||
rotateTicker := time.NewTicker(l.cfg.RotateInterval)
|
||||
defer rotateTicker.Stop()
|
||||
|
||||
for {
|
||||
|
||||
Reference in New Issue
Block a user