Skip to content

Commit

Permalink
feat: configure log ttl
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Apr 9, 2023
1 parent ed5e9f0 commit 13c372f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion task/log/file_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/apex/log"
"github.com/crawlab-team/crawlab-core/utils"
"github.com/crawlab-team/go-trace"
"github.com/spf13/viper"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -207,7 +208,12 @@ func newFileLogDriver(options *FileLogDriverOptions) (driver Driver, err error)
// normalize Ttl
ttl := options.Ttl
if ttl == 0 {
ttl = 30 * 24 * time.Hour
ttlSeconds := viper.GetInt("log.ttl")
if ttlSeconds == 0 {
ttl = 30 * 24 * time.Hour
} else {
ttl = time.Second * time.Duration(ttlSeconds)
}
}
options.Ttl = ttl

Expand Down

0 comments on commit 13c372f

Please sign in to comment.