mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-09 03:27:39 +08:00
feat: support log rotation
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user