feat: log level config
feat: ffmpeg args placeholder
This commit is contained in:
14
config/config.go
Normal file → Executable file
14
config/config.go
Normal file → Executable 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")
|
||||
|
||||
Reference in New Issue
Block a user