Commit 3461580b authored by Max Kellermann's avatar Max Kellermann

test/run_input: add option "--verbose"

parent fcfdeac1
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "event/Thread.hxx" #include "event/Thread.hxx"
#include "thread/Cond.hxx" #include "thread/Cond.hxx"
#include "Log.hxx" #include "Log.hxx"
#include "LogBackend.hxx"
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "fs/io/BufferedOutputStream.hxx" #include "fs/io/BufferedOutputStream.hxx"
#include "fs/io/StdioOutputStream.hxx" #include "fs/io/StdioOutputStream.hxx"
...@@ -46,14 +47,18 @@ struct CommandLine { ...@@ -46,14 +47,18 @@ struct CommandLine {
const char *uri = nullptr; const char *uri = nullptr;
Path config_path = nullptr; Path config_path = nullptr;
bool verbose = false;
}; };
enum Option { enum Option {
OPTION_CONFIG, OPTION_CONFIG,
OPTION_VERBOSE,
}; };
static constexpr OptionDef option_defs[] = { static constexpr OptionDef option_defs[] = {
{"config", 0, true, "Load a MPD configuration file"}, {"config", 0, true, "Load a MPD configuration file"},
{"verbose", 'v', false, "Verbose logging"},
}; };
static CommandLine static CommandLine
...@@ -67,12 +72,16 @@ ParseCommandLine(int argc, char **argv) ...@@ -67,12 +72,16 @@ ParseCommandLine(int argc, char **argv)
case OPTION_CONFIG: case OPTION_CONFIG:
c.config_path = Path::FromFS(o.value); c.config_path = Path::FromFS(o.value);
break; break;
case OPTION_VERBOSE:
c.verbose = true;
break;
} }
} }
auto args = option_parser.GetRemaining(); auto args = option_parser.GetRemaining();
if (args.size != 1) 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(); c.uri = args.front();
return c; return c;
...@@ -82,7 +91,9 @@ class GlobalInit { ...@@ -82,7 +91,9 @@ class GlobalInit {
EventThread io_thread; EventThread io_thread;
public: public:
GlobalInit(Path config_path) { GlobalInit(Path config_path, bool verbose) {
SetLogThreshold(verbose ? LogLevel::DEBUG : LogLevel::INFO);
io_thread.Start(); io_thread.Start();
config_global_init(); config_global_init();
...@@ -155,7 +166,7 @@ try { ...@@ -155,7 +166,7 @@ try {
/* initialize MPD */ /* initialize MPD */
const GlobalInit init(c.config_path); const GlobalInit init(c.config_path, c.verbose);
/* open the stream and dump it */ /* open the stream and dump it */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment