gnucash maint: Bug 798008 - Option '--log' cannot be specified more than once
Geert Janssens
gjanssens at code.gnucash.org
Fri Nov 13 04:58:22 EST 2020
Updated via https://github.com/Gnucash/gnucash/commit/e9a117b2 (commit)
from https://github.com/Gnucash/gnucash/commit/79951e09 (commit)
commit e9a117b21bda9c9810cff2f543efa9b283d95c08
Author: Geert Janssens <geert at kobaltwit.be>
Date: Fri Nov 13 10:58:14 2020 +0100
Bug 798008 - Option '--log' cannot be specified more than once
Wrapping the std::vector to hold the log flags is unneeded and actually harmful.
Just work on the vector directly. If user doesn't specify any '--log' options
the vector will just be empty.
diff --git a/gnucash/gnucash-core-app.cpp b/gnucash/gnucash-core-app.cpp
index 6a6b6a80d..451b1f712 100644
--- a/gnucash/gnucash-core-app.cpp
+++ b/gnucash/gnucash-core-app.cpp
@@ -346,7 +346,7 @@ load_user_config(void)
static void
-gnc_log_init (const boost::optional <std::vector <std::string>> &log_flags,
+gnc_log_init (const std::vector <std::string> log_flags,
const boost::optional <std::string> &log_to_filename)
{
if (log_to_filename && !log_to_filename->empty())
@@ -389,24 +389,21 @@ gnc_log_init (const boost::optional <std::vector <std::string>> &log_flags,
qof_log_parse_log_config (log_config_filename);
g_free (log_config_filename);
- if (log_flags && !log_flags->empty())
+ for (auto log_flag : log_flags)
{
- for (auto log_flag : *log_flags)
+ if (log_flag.empty () ||
+ log_flag[0] == '=' ||
+ log_flag[log_flag.length () - 1] == '=')
{
- if (log_flag.empty () ||
- log_flag[0] == '=' ||
- log_flag[log_flag.length () - 1] == '=')
- {
- g_warning ("string [%s] not parseable", log_flag.c_str());
- continue;
- }
+ g_warning ("string [%s] not parseable", log_flag.c_str());
+ continue;
+ }
- std::vector<std::string> split_flag;
- boost::split (split_flag, log_flag, [](char c){return c == '=';});
+ std::vector<std::string> split_flag;
+ boost::split (split_flag, log_flag, [](char c){return c == '=';});
- auto level = qof_log_level_from_string (split_flag[1].c_str());
- qof_log_set_level (split_flag[0].c_str(), level);
- }
+ auto level = qof_log_level_from_string (split_flag[1].c_str());
+ qof_log_set_level (split_flag[0].c_str(), level);
}
}
diff --git a/gnucash/gnucash-core-app.hpp b/gnucash/gnucash-core-app.hpp
index 37dea122d..ed61af1f2 100644
--- a/gnucash/gnucash-core-app.hpp
+++ b/gnucash/gnucash-core-app.hpp
@@ -65,7 +65,7 @@ private:
bool m_debug = false;
bool m_extra = false;
boost::optional <std::string> m_gsettings_prefix;
- boost::optional <std::vector <std::string>> m_log_flags;
+ std::vector <std::string> m_log_flags;
char *sys_locale = nullptr;
};
Summary of changes:
gnucash/gnucash-core-app.cpp | 27 ++++++++++++---------------
gnucash/gnucash-core-app.hpp | 2 +-
2 files changed, 13 insertions(+), 16 deletions(-)
More information about the gnucash-changes
mailing list