feat: support log rotation

This commit is contained in:
Simon Ding
2024-07-26 13:59:10 +08:00
parent 2cb6a15c0b
commit f5f8434832
4 changed files with 27 additions and 13 deletions

View File

@@ -14,6 +14,7 @@ import (
type GeneralSettings struct {
TmdbApiKey string `json:"tmdb_api_key"`
DownloadDir string `json:"download_dir"`
LogLevel string `json:"log_level"`
}
func (s *Server) SetSetting(c *gin.Context) (interface{}, error) {
@@ -32,6 +33,9 @@ func (s *Server) SetSetting(c *gin.Context) (interface{}, error) {
return nil, errors.Wrap(err, "save download dir")
}
}
if in.LogLevel != "" {
log.SetLogLevel(in.LogLevel)
}
return nil, nil
}
@@ -97,7 +101,6 @@ func (s *Server) getDownloadClient() (*transmission.Client, error) {
return trc, nil
}
type downloadClientIn struct {
Name string `json:"name" binding:"required"`
URL string `json:"url" binding:"required"`
@@ -113,8 +116,8 @@ func (s *Server) AddDownloadClient(c *gin.Context) (interface{}, error) {
}
//test connection
_, err := transmission.NewClient(transmission.Config{
URL: in.URL,
User: in.User,
URL: in.URL,
User: in.User,
Password: in.Password,
})
if err != nil {
@@ -155,4 +158,4 @@ func (s *Server) SetLogLevel(c *gin.Context) (interface{}, error) {
}
log.SetLogLevel(in.Level)
return "success", nil
}
}