From 13c372f3d0af4e00ec9addf6cb4fa30f26e4d418 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Sun, 9 Apr 2023 11:39:10 +0800 Subject: [PATCH] feat: configure log ttl --- task/log/file_driver.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/task/log/file_driver.go b/task/log/file_driver.go index 474aa96..0024738 100644 --- a/task/log/file_driver.go +++ b/task/log/file_driver.go @@ -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" @@ -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