mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-09 19:47:47 +08:00
feat: add log level setting
This commit is contained in:
@@ -35,6 +35,10 @@ func (s *Server) SetSetting(c *gin.Context) (interface{}, error) {
|
||||
}
|
||||
if in.LogLevel != "" {
|
||||
log.SetLogLevel(in.LogLevel)
|
||||
if err := s.db.SetSetting(db.SettingLogLevel, in.LogLevel); err != nil {
|
||||
return nil, errors.Wrap(err, "save log level")
|
||||
}
|
||||
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
@@ -42,10 +46,11 @@ func (s *Server) SetSetting(c *gin.Context) (interface{}, error) {
|
||||
func (s *Server) GetSetting(c *gin.Context) (interface{}, error) {
|
||||
tmdb := s.db.GetSetting(db.SettingTmdbApiKey)
|
||||
downloadDir := s.db.GetSetting(db.SettingDownloadDir)
|
||||
|
||||
logLevel := s.db.GetSetting(db.SettingLogLevel)
|
||||
return &GeneralSettings{
|
||||
TmdbApiKey: tmdb,
|
||||
DownloadDir: downloadDir,
|
||||
LogLevel: logLevel,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -146,16 +151,3 @@ func (s *Server) DeleteDownloadCLient(c *gin.Context) (interface{}, error) {
|
||||
s.db.DeleteDownloadCLient(id)
|
||||
return "success", nil
|
||||
}
|
||||
|
||||
type logLovelIn struct {
|
||||
Level string `json:"level"`
|
||||
}
|
||||
|
||||
func (s *Server) SetLogLevel(c *gin.Context) (interface{}, error) {
|
||||
var in logLovelIn
|
||||
if err := c.ShouldBindJSON(&in); err != nil {
|
||||
return nil, errors.Wrap(err, "bind json")
|
||||
}
|
||||
log.SetLogLevel(in.Level)
|
||||
return "success", nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user