diff options
author | Max Kellermann <max@musicpd.org> | 2018-01-24 15:29:27 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-01-24 15:29:30 +0100 |
commit | 3461580b347e934fead8039d12fdfd22cfa0a811 (patch) | |
tree | 6e99ac7496e09690b7204c21ad770a2ec8bec70c /test/run_input.cxx | |
parent | fcfdeac1c76f749ea88d72b139e20db0e0549fe5 (diff) |
test/run_input: add option "--verbose"
Diffstat (limited to 'test/run_input.cxx')
-rw-r--r-- | test/run_input.cxx | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/test/run_input.cxx b/test/run_input.cxx index 5fc8a8211..288df57e6 100644 --- a/test/run_input.cxx +++ b/test/run_input.cxx @@ -26,6 +26,7 @@ #include "event/Thread.hxx" #include "thread/Cond.hxx" #include "Log.hxx" +#include "LogBackend.hxx" #include "fs/Path.hxx" #include "fs/io/BufferedOutputStream.hxx" #include "fs/io/StdioOutputStream.hxx" @@ -46,14 +47,18 @@ struct CommandLine { const char *uri = nullptr; Path config_path = nullptr; + + bool verbose = false; }; enum Option { OPTION_CONFIG, + OPTION_VERBOSE, }; static constexpr OptionDef option_defs[] = { {"config", 0, true, "Load a MPD configuration file"}, + {"verbose", 'v', false, "Verbose logging"}, }; static CommandLine @@ -67,12 +72,16 @@ ParseCommandLine(int argc, char **argv) case OPTION_CONFIG: c.config_path = Path::FromFS(o.value); break; + + case OPTION_VERBOSE: + c.verbose = true; + break; } } auto args = option_parser.GetRemaining(); if (args.size != 1) - throw std::runtime_error("Usage: run_input [--config=FILE] URI"); + throw std::runtime_error("Usage: run_input [--verbose] [--config=FILE] URI"); c.uri = args.front(); return c; @@ -82,7 +91,9 @@ class GlobalInit { EventThread io_thread; public: - GlobalInit(Path config_path) { + GlobalInit(Path config_path, bool verbose) { + SetLogThreshold(verbose ? LogLevel::DEBUG : LogLevel::INFO); + io_thread.Start(); config_global_init(); @@ -155,7 +166,7 @@ try { /* initialize MPD */ - const GlobalInit init(c.config_path); + const GlobalInit init(c.config_path, c.verbose); /* open the stream and dump it */ |