From 4f8e4772fb2d528e9bba9697d07453819ae46b07 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Tue, 12 Aug 2014 00:12:46 +0200 Subject: [PATCH] Added --debug and --verbose command line arguments --- src/supertux/command_line_arguments.cpp | 15 ++++++++++++++- src/supertux/command_line_arguments.hpp | 3 +++ src/supertux/main.cpp | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/supertux/command_line_arguments.cpp b/src/supertux/command_line_arguments.cpp index 50d16ca95..f69496c53 100644 --- a/src/supertux/command_line_arguments.cpp +++ b/src/supertux/command_line_arguments.cpp @@ -23,11 +23,11 @@ #include "supertux/gameconfig.hpp" #include "supertux/main.hpp" #include "util/gettext.hpp" -#include "util/log.hpp" #include "version.h" CommandLineArguments::CommandLineArguments() : m_action(NO_ACTION), + m_log_level(LOG_WARNING), fullscreen_size(), fullscreen_refresh_rate(), window_size(), @@ -73,6 +73,8 @@ CommandLineArguments::print_help(const char* argv0) "\n" "Usage: %s [OPTIONS] [LEVELFILE]\n\n" "CommandLineArguments:\n" + " --verbose Print verbose messages\n" + " --debug Print extra verbose messages\n" " -f, --fullscreen Run in fullscreen mode\n" " -w, --window Run in window mode\n" " -g, --geometry WIDTHxHEIGHT Run SuperTux in given resolution\n" @@ -127,6 +129,17 @@ CommandLineArguments::parse_args(int argc, char** argv) { m_action = PRINT_DATADIR; } + else if (arg == "--debug") + { + m_log_level = LOG_DEBUG; + } + else if (arg == "--verbose") + { + if (m_log_level < LOG_INFO) + { + m_log_level = LOG_INFO; + } + } else if (arg == "--fullscreen" || arg == "-f") { use_fullscreen = true; diff --git a/src/supertux/command_line_arguments.hpp b/src/supertux/command_line_arguments.hpp index 903278613..9fadc6301 100644 --- a/src/supertux/command_line_arguments.hpp +++ b/src/supertux/command_line_arguments.hpp @@ -20,6 +20,7 @@ #include #include "math/size.hpp" +#include "util/log.hpp" #include "video/video_systems.hpp" class Config; @@ -38,6 +39,7 @@ public: private: Action m_action; + LogLevel m_log_level; public: boost::optional fullscreen_size; @@ -69,6 +71,7 @@ public: ~CommandLineArguments(); Action get_action() const { return m_action; } + LogLevel get_log_level() const { return m_log_level; } void parse_args(int argc, char** argv); diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp index c231938f3..682b85c57 100644 --- a/src/supertux/main.cpp +++ b/src/supertux/main.cpp @@ -282,6 +282,7 @@ Main::run(int argc, char** argv) try { args.parse_args(argc, argv); + g_log_level = args.get_log_level(); } catch(const std::exception& err) { -- 2.11.0