Add log_patterns to process config

log_patterns allow to filter the FFmpeg log messages based on regular
expressions. Each entry of log_patterns is interpreted as regular
expression and matched against every non-progress log line emitted from
FFmpeg. All matching lines are returned in the matches array of the
report.
This commit is contained in:
Ingo Oppermann
2023-03-27 15:50:25 +02:00
parent 814975dfee
commit 0a3117bbd0
12 changed files with 175 additions and 12 deletions

View File

@@ -878,3 +878,34 @@ func TestParserProgressPlayout(t *testing.T) {
Dup: 0,
}, progress)
}
func TestParserPatterns(t *testing.T) {
parser := New(Config{
Patterns: []string{
"^foobar",
"foobar$",
},
})
parser.Parse("some foobar more")
require.Empty(t, parser.Report().Matches)
parser.Parse("foobar some more")
require.Equal(t, 1, len(parser.Report().Matches))
require.Equal(t, "foobar some more", parser.Report().Matches[0])
parser.Parse("some more foobar")
require.Equal(t, 2, len(parser.Report().Matches))
require.Equal(t, "some more foobar", parser.Report().Matches[1])
}
func TestParserPatternsError(t *testing.T) {
parser := New(Config{
Patterns: []string{
"^foobar",
"foo(bar$",
},
})
require.Equal(t, 1, len(parser.Report().Matches))
}