feat: log level config

feat: ffmpeg args placeholder
This commit is contained in:
2024-10-29 03:35:21 +08:00
parent 2afcac48dc
commit dfdb6003ea
23 changed files with 212 additions and 71 deletions

14
config/config.go Normal file → Executable file
View File

@@ -24,7 +24,8 @@ type InputItem struct {
}
type LogConfig struct {
PlayState bool `json:"play_state"`
Level string `json:"level"`
PlayState bool `json:"play_state"`
}
type ServerConfig struct {
@@ -42,10 +43,10 @@ type Config struct {
Server ServerConfig `json:"server"`
}
var GlobalConfig Config
var GlobalConfig *Config
func init() {
GlobalConfig = Config{}
GlobalConfig = &Config{}
err := readConfig("config.json")
if len(GlobalConfig.Input) == 0 {
log.Fatal("No input video found")
@@ -91,9 +92,16 @@ func validateConfig() error {
if err := validateServerConfig(); err != nil {
return err
}
validateLogConfig()
return nil
}
func validateLogConfig() {
if GlobalConfig.Log.Level == "" {
GlobalConfig.Log.Level = "info"
}
}
func validateInputConfig() error {
if GlobalConfig.Input == nil {
return errors.New("video_path is nil")