Standalone grabber: Add --debug switch

This commit is contained in:
LordGrey
2021-05-11 21:06:03 +02:00
parent 2035a3cfab
commit 3b843c0d23
8 changed files with 94 additions and 16 deletions

View File

@@ -24,6 +24,9 @@ void saveScreenshot(QString filename, const Image<ColorRgb> & image)
int main(int argc, char ** argv)
{
Logger *log = Logger::getInstance("X11GRABBER");
Logger::setLogLevel(Logger::INFO);
std::cout
<< "hyperion-x11:" << std::endl
<< "\tVersion : " << HYPERION_VERSION << " (" << HYPERION_BUILD_ID << ")" << std::endl
@@ -49,11 +52,18 @@ int main(int argc, char ** argv)
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
BooleanOption & argDebug = parser.add<BooleanOption>(0x0, "debug", "Enable debug logging");
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help", "Show this help message and exit");
// parse all options
parser.process(app);
// check if debug logging is required
if (parser.isSet(argDebug))
{
Logger::setLogLevel(Logger::DEBUG);
}
// check if we need to display the usage. exit if we do.
if (parser.isSet(argHelp))
{
@@ -106,8 +116,8 @@ int main(int argc, char ** argv)
}
catch (const std::runtime_error & e)
{
// An error occured. Display error and quit
Error(Logger::getInstance("X11GRABBER"), "%s", e.what());
// An error occurred. Display error and quit
Error(log, "%s", e.what());
return -1;
}