Skip to content

Commit

Permalink
Add log level for ffmpeg module
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed May 27, 2024
1 parent 3932dba commit 8cb513c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func Init() {

cfg.Mod = map[string]string{
"format": "color",
"level": zerolog.LevelInfoValue,
"level": "info",
"output": "stdout", // TODO: change to stderr someday
"time": zerolog.TimeFormatUnixMs,
}
Expand Down
11 changes: 9 additions & 2 deletions internal/ffmpeg/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,22 @@ import (
func Init() {
var cfg struct {
Mod map[string]string `yaml:"ffmpeg"`
Log struct {
Level string `yaml:"ffmpeg"`
} `yaml:"log"`
}

cfg.Mod = defaults // will be overriden from yaml
cfg.Log.Level = "error"

app.LoadConfig(&cfg)

if app.GetLogger("exec").GetLevel() >= 0 {
defaults["global"] += " -v error"
// zerolog levels: trace debug info warn error fatal panic disabled
// FFmpeg levels: trace debug verbose info warning error fatal panic quiet
if cfg.Log.Level == "warn" {
cfg.Log.Level = "warning"
}
defaults["global"] += " -v " + cfg.Log.Level

streams.RedirectFunc("ffmpeg", func(url string) (string, error) {
if _, err := Version(); err != nil {
Expand Down

0 comments on commit 8cb513c

Please sign in to comment.