From 09f3040baedcca72c42ea29bb4d0c6cbffdbdf60 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 23 May 2014 14:12:55 +0200 Subject: [PATCH] Fix required argument for --debug|-x. Refs #6276 --- doc/2-getting-started.md | 2 +- icinga-app/icinga.cpp | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/2-getting-started.md b/doc/2-getting-started.md index 2ef3b9618..9be4fa8e7 100644 --- a/doc/2-getting-started.md +++ b/doc/2-getting-started.md @@ -830,7 +830,7 @@ for historical reasons. -D [ --define] args define a constant -c [ --config ] arg parse a configuration file -C [ --validate ] exit after validating the configuration - -x [ --debug ] arg enable debugging with optional severity level specified + -x [ --debug ] arg enable debugging with severity level specified -d [ --daemonize ] detach from the controlling terminal -e [ --errorlog ] arg log fatal errors to the specified log file (only works in combination with --daemonize) diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index deefb405a..053accab0 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -334,7 +334,7 @@ int Main(void) ("config,c", po::value >(), "parse a configuration file") ("no-config,z", "start without a configuration file") ("validate,C", "exit after validating the configuration") - ("debug,x", po::value(), "enable debugging with optional severity level specified") + ("debug,x", po::value(), "enable debugging with severity level specified") ("errorlog,e", po::value(), "log fatal errors to the specified log file (only works in combination with --daemonize)") #ifndef _WIN32 ("reload-internal", po::value(), "used internally to implement config reload: do not call manually, send SIGHUP instead") @@ -431,10 +431,15 @@ int Main(void) if (g_AppParams.count("debug")) { Application::SetDebugging(true); - String debug_severity = g_AppParams["debug"].as(); + LogSeverity debug_severity; + try { + debug_severity = Logger::StringToSeverity(g_AppParams["debug"].as()); + } catch (std::exception&) { + //not set, use default + debug_severity = LogDebug; + } - if (!debug_severity.IsEmpty()) - Application::SetDebuggingSeverity(Logger::StringToSeverity(debug_severity)); + Application::SetDebuggingSeverity(debug_severity); } if (g_AppParams.count("help") || g_AppParams.count("version")) { -- 2.40.0