From 8d40e68dec09c9d33794f8ebf2929b2f5286657d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 11 Mar 2020 20:06:33 +0100 Subject: test/run_convert: add option --verbose --- test/run_convert.cxx | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/run_convert.cxx b/test/run_convert.cxx index 734e2c918..b5491446d 100644 --- a/test/run_convert.cxx +++ b/test/run_convert.cxx @@ -28,8 +28,11 @@ #include "pcm/Convert.hxx" #include "util/ConstBuffer.hxx" #include "util/StaticFifoBuffer.hxx" +#include "util/OptionDef.hxx" #include "util/OptionParser.hxx" #include "util/PrintException.hxx" +#include "Log.hxx" +#include "LogBackend.hxx" #include @@ -41,6 +44,16 @@ struct CommandLine { AudioFormat in_audio_format, out_audio_format; + + bool verbose = false; +}; + +enum Option { + OPTION_VERBOSE, +}; + +static constexpr OptionDef option_defs[] = { + {"verbose", 'v', false, "Verbose logging"}, }; static CommandLine @@ -48,8 +61,13 @@ ParseCommandLine(int argc, char **argv) { CommandLine c; - OptionParser option_parser(nullptr, argc, argv); - while (option_parser.Next()) { + OptionParser option_parser(option_defs, argc, argv); + while (auto o = option_parser.Next()) { + switch (Option(o.index)) { + case OPTION_VERBOSE: + c.verbose = true; + break; + } } auto args = option_parser.GetRemaining(); @@ -66,6 +84,8 @@ main(int argc, char **argv) try { const auto c = ParseCommandLine(argc, argv); + SetLogThreshold(c.verbose ? LogLevel::DEBUG : LogLevel::INFO); + const size_t in_frame_size = c.in_audio_format.GetFrameSize(); PcmConvert state(c.in_audio_format, c.out_audio_format); -- cgit v1.2.3